Fix statusbar indicator when navigating from the PVR channel group to the channels list
This commit is contained in:
parent
a6845c2e79
commit
eca7d2b2ad
|
@ -42,11 +42,17 @@ public class PVRActivity extends BaseActivity
|
||||||
public static final String CHANNELID = "channel_id";
|
public static final String CHANNELID = "channel_id";
|
||||||
public static final String CHANNELTITLE = "channel_title";
|
public static final String CHANNELTITLE = "channel_title";
|
||||||
|
|
||||||
|
public static final String CHANNELGROUPID = "channelgroupid";
|
||||||
|
public static final String CHANNELGROUPTITLE = "channelgrouptitle";
|
||||||
|
|
||||||
private static final String LISTFRAGMENTTAG = "listfragmenttag";
|
private static final String LISTFRAGMENTTAG = "listfragmenttag";
|
||||||
|
|
||||||
private int selectedChannelId = -1;
|
private int selectedChannelId = -1;
|
||||||
private String selectedChannelTitle = null;
|
private String selectedChannelTitle = null;
|
||||||
|
|
||||||
|
private int selectedChannelGroupId = -1;
|
||||||
|
private String selectedChannelGroupTitle = null;
|
||||||
|
|
||||||
private NavigationDrawerFragment navigationDrawerFragment;
|
private NavigationDrawerFragment navigationDrawerFragment;
|
||||||
|
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
|
@ -81,9 +87,12 @@ public class PVRActivity extends BaseActivity
|
||||||
} else {
|
} else {
|
||||||
selectedChannelId = savedInstanceState.getInt(CHANNELID, -1);
|
selectedChannelId = savedInstanceState.getInt(CHANNELID, -1);
|
||||||
selectedChannelTitle = savedInstanceState.getString(CHANNELTITLE, null);
|
selectedChannelTitle = savedInstanceState.getString(CHANNELTITLE, null);
|
||||||
|
|
||||||
|
selectedChannelGroupId = savedInstanceState.getInt(CHANNELGROUPID, -1);
|
||||||
|
selectedChannelGroupTitle = savedInstanceState.getString(CHANNELGROUPTITLE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupActionBar(selectedChannelTitle);
|
setupActionBar(selectedChannelGroupTitle, selectedChannelTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,6 +110,9 @@ public class PVRActivity extends BaseActivity
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putInt(CHANNELID, selectedChannelId);
|
outState.putInt(CHANNELID, selectedChannelId);
|
||||||
outState.putString(CHANNELTITLE, selectedChannelTitle);
|
outState.putString(CHANNELTITLE, selectedChannelTitle);
|
||||||
|
|
||||||
|
outState.putInt(CHANNELGROUPID, selectedChannelGroupId);
|
||||||
|
outState.putString(CHANNELGROUPTITLE, selectedChannelGroupTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,9 +135,19 @@ public class PVRActivity extends BaseActivity
|
||||||
if (selectedChannelId != -1) {
|
if (selectedChannelId != -1) {
|
||||||
selectedChannelId = -1;
|
selectedChannelId = -1;
|
||||||
selectedChannelTitle = null;
|
selectedChannelTitle = null;
|
||||||
setupActionBar(null);
|
setupActionBar(selectedChannelGroupTitle, null);
|
||||||
getSupportFragmentManager().popBackStack();
|
getSupportFragmentManager().popBackStack();
|
||||||
return true;
|
return true;
|
||||||
|
} else if (selectedChannelGroupId != -1) {
|
||||||
|
selectedChannelGroupId = -1;
|
||||||
|
selectedChannelGroupTitle = null;
|
||||||
|
setupActionBar(null, null);
|
||||||
|
|
||||||
|
PVRListFragment fragment = (PVRListFragment)getSupportFragmentManager().findFragmentByTag(LISTFRAGMENTTAG);
|
||||||
|
if (fragment != null) {
|
||||||
|
fragment.onBackPressed();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -142,8 +164,13 @@ public class PVRActivity extends BaseActivity
|
||||||
if (selectedChannelId != -1) {
|
if (selectedChannelId != -1) {
|
||||||
selectedChannelId = -1;
|
selectedChannelId = -1;
|
||||||
selectedChannelTitle = null;
|
selectedChannelTitle = null;
|
||||||
setupActionBar(null);
|
setupActionBar(selectedChannelGroupTitle, null);
|
||||||
} else {
|
} else {
|
||||||
|
if (selectedChannelGroupId != -1) {
|
||||||
|
selectedChannelGroupId = -1;
|
||||||
|
selectedChannelGroupTitle = null;
|
||||||
|
setupActionBar(null, null);
|
||||||
|
}
|
||||||
PVRListFragment fragment = (PVRListFragment)getSupportFragmentManager().findFragmentByTag(LISTFRAGMENTTAG);
|
PVRListFragment fragment = (PVRListFragment)getSupportFragmentManager().findFragmentByTag(LISTFRAGMENTTAG);
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
handled = fragment.onBackPressed();
|
handled = fragment.onBackPressed();
|
||||||
|
@ -154,7 +181,7 @@ public class PVRActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean drawerIndicatorIsArrow = false;
|
private boolean drawerIndicatorIsArrow = false;
|
||||||
private void setupActionBar(String channelTitle) {
|
private void setupActionBar(String channelGroupTitle, String channelTitle) {
|
||||||
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
@ -162,12 +189,12 @@ public class PVRActivity extends BaseActivity
|
||||||
if (actionBar == null) return;
|
if (actionBar == null) return;
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (channelTitle != null) {
|
if ((channelTitle != null) || (channelGroupTitle != null)) {
|
||||||
if (!drawerIndicatorIsArrow) {
|
if (!drawerIndicatorIsArrow) {
|
||||||
navigationDrawerFragment.animateDrawerToggle(true);
|
navigationDrawerFragment.animateDrawerToggle(true);
|
||||||
drawerIndicatorIsArrow = true;
|
drawerIndicatorIsArrow = true;
|
||||||
}
|
}
|
||||||
actionBar.setTitle(channelTitle);
|
actionBar.setTitle(channelTitle == null? channelGroupTitle : channelTitle);
|
||||||
} else {
|
} else {
|
||||||
if (drawerIndicatorIsArrow) {
|
if (drawerIndicatorIsArrow) {
|
||||||
navigationDrawerFragment.animateDrawerToggle(false);
|
navigationDrawerFragment.animateDrawerToggle(false);
|
||||||
|
@ -207,6 +234,19 @@ public class PVRActivity extends BaseActivity
|
||||||
fragTrans.replace(R.id.fragment_container, pvrEPGFragment)
|
fragTrans.replace(R.id.fragment_container, pvrEPGFragment)
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
setupActionBar(selectedChannelTitle);
|
setupActionBar(selectedChannelGroupTitle, selectedChannelTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback from list fragment when a channel group is selected
|
||||||
|
* Just setup action bar
|
||||||
|
* @param channelGroupId Channel group selected
|
||||||
|
* @param channelGroupTitle Title
|
||||||
|
*/
|
||||||
|
public void onChannelGroupSelected(int channelGroupId, String channelGroupTitle) {
|
||||||
|
selectedChannelGroupId = channelGroupId;
|
||||||
|
selectedChannelGroupTitle = channelGroupTitle;
|
||||||
|
|
||||||
|
setupActionBar(selectedChannelGroupTitle, selectedChannelTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ public class PVRChannelsListFragment extends Fragment
|
||||||
public static final String SINGLECHANNELGROUP = "singlechannelgroup";
|
public static final String SINGLECHANNELGROUP = "singlechannelgroup";
|
||||||
|
|
||||||
public interface OnPVRChannelSelectedListener {
|
public interface OnPVRChannelSelectedListener {
|
||||||
public void onChannelGuideSelected(int channelId, String channelTitle);
|
void onChannelGuideSelected(int channelId, String channelTitle);
|
||||||
|
void onChannelGroupSelected(int channelGroupId, String channelGroupTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activity listener
|
// Activity listener
|
||||||
|
@ -264,6 +265,7 @@ public class PVRChannelsListFragment extends Fragment
|
||||||
ChannelGroupViewHolder tag = (ChannelGroupViewHolder) view.getTag();
|
ChannelGroupViewHolder tag = (ChannelGroupViewHolder) view.getTag();
|
||||||
selectedChannelGroupId = tag.channelGroupId;
|
selectedChannelGroupId = tag.channelGroupId;
|
||||||
// Notify the activity and show the channels
|
// Notify the activity and show the channels
|
||||||
|
listenerActivity.onChannelGroupSelected(tag.channelGroupId, tag.channelGroupName);
|
||||||
browseChannels(tag.channelGroupId);
|
browseChannels(tag.channelGroupId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -277,7 +279,7 @@ public class PVRChannelsListFragment extends Fragment
|
||||||
* Gets and displays the channels of a channelgroup
|
* Gets and displays the channels of a channelgroup
|
||||||
* @param channelGroupId id
|
* @param channelGroupId id
|
||||||
*/
|
*/
|
||||||
private void browseChannels(int channelGroupId) {
|
private void browseChannels(final int channelGroupId) {
|
||||||
String[] properties = PVRType.FieldsChannel.allValues;
|
String[] properties = PVRType.FieldsChannel.allValues;
|
||||||
LogUtils.LOGD(TAG, "Getting channels");
|
LogUtils.LOGD(TAG, "Getting channels");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue