Skip to content

Commit

Permalink
Fix PVR section back navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
SyncedSynapse authored and poisdeux committed Mar 12, 2018
1 parent 2206b90 commit 94ed40a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions app/src/main/java/org/xbmc/kore/ui/sections/video/PVRActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class PVRActivity extends BaseMediaActivity

public static final String CHANNELGROUPID = "channelgroupid";
public static final String CHANNELGROUPTITLE = "channelgrouptitle";
public static final String SINGLECHANNELGROUPTITLE = "singlechannelgrouptitle";

private static final String LISTFRAGMENTTAG = "listfragmenttag";

Expand All @@ -49,6 +50,8 @@ public class PVRActivity extends BaseMediaActivity
private int selectedChannelGroupId = -1;
private String selectedChannelGroupTitle = null;

private boolean singleChannelGroup = false;

@Override
protected String getActionBarTitle() {
if ( selectedChannelTitle != null ) {
Expand All @@ -72,6 +75,8 @@ protected void onCreate(Bundle savedInstanceState) {

selectedChannelGroupId = savedInstanceState.getInt(CHANNELGROUPID, -1);
selectedChannelGroupTitle = savedInstanceState.getString(CHANNELGROUPTITLE, null);

singleChannelGroup = savedInstanceState.getBoolean(SINGLECHANNELGROUPTITLE, false);
}
super.onCreate(savedInstanceState);
}
Expand All @@ -84,6 +89,8 @@ protected void onSaveInstanceState(Bundle outState) {

outState.putInt(CHANNELGROUPID, selectedChannelGroupId);
outState.putString(CHANNELGROUPTITLE, selectedChannelGroupTitle);

outState.putBoolean(SINGLECHANNELGROUPTITLE, singleChannelGroup);
}

@Override
Expand All @@ -94,7 +101,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (selectedChannelId != -1) {
selectedChannelId = -1;
selectedChannelTitle = null;
updateActionBar(getActionBarTitle(), true);
updateActionBar(getActionBarTitle(), !singleChannelGroup);
getSupportFragmentManager().popBackStack();
return true;
} else if (selectedChannelGroupId != -1) {
Expand Down Expand Up @@ -123,7 +130,7 @@ public void onBackPressed() {
if (selectedChannelId != -1) {
selectedChannelId = -1;
selectedChannelTitle = null;
updateActionBar(getActionBarTitle(), true);
updateActionBar(getActionBarTitle(), !singleChannelGroup);
} else {
if (selectedChannelGroupId != -1) {
selectedChannelGroupId = -1;
Expand All @@ -146,9 +153,10 @@ public void onBackPressed() {
* @param channelTitle Title
*/
@TargetApi(21)
public void onChannelGuideSelected(int channelId, String channelTitle) {
selectedChannelId = channelId;
selectedChannelTitle = channelTitle;
public void onChannelGuideSelected(int channelId, String channelTitle, boolean singleChannelGroup) {
this.selectedChannelId = channelId;
this.selectedChannelTitle = channelTitle;
this.singleChannelGroup = singleChannelGroup;

// Replace list fragment
PVRChannelEPGListFragment pvrEPGFragment = PVRChannelEPGListFragment.newInstance(channelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class PVRChannelsListFragment extends Fragment
public static final String SINGLECHANNELGROUP = "singlechannelgroup";

public interface OnPVRChannelSelectedListener {
void onChannelGuideSelected(int channelId, String channelTitle);
void onChannelGuideSelected(int channelId, String channelTitle, boolean singleChannelGroup);
void onChannelGroupSelected(int channelGroupId, String channelGroupTitle);
}

Expand Down Expand Up @@ -435,7 +435,7 @@ public void onError(int errorCode, String description) {
}, callbackHandler);
return true;
case R.id.action_epg_item:
listenerActivity.onChannelGuideSelected(channelId, channelName);
listenerActivity.onChannelGuideSelected(channelId, channelName, singleChannelGroup);
return true;
}
return false;
Expand Down

0 comments on commit 94ed40a

Please sign in to comment.