Select 'New' tab on start if there are new items

This commit is contained in:
daniel oeh 2012-10-13 12:00:27 +02:00
parent 0b22262186
commit f76ac9ed42
1 changed files with 15 additions and 3 deletions

View File

@ -42,6 +42,8 @@ public class MainActivity extends SherlockFragmentActivity {
private TabPageIndicator tabs; private TabPageIndicator tabs;
private ExternalPlayerFragment externalPlayerFragment; private ExternalPlayerFragment externalPlayerFragment;
private static boolean appLaunched = false;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -62,6 +64,16 @@ public class MainActivity extends SherlockFragmentActivity {
externalPlayerFragment = new ExternalPlayerFragment(); externalPlayerFragment = new ExternalPlayerFragment();
transaction.replace(R.id.playerFragment, externalPlayerFragment); transaction.replace(R.id.playerFragment, externalPlayerFragment);
transaction.commit(); transaction.commit();
// executed on application start
if (!appLaunched && getIntent().getAction() != null
&& getIntent().getAction().equals(Intent.ACTION_MAIN)) {
appLaunched = true;
if (manager.getUnreadItems().size() > 0) {
viewpager.setCurrentItem(MainPagerAdapter.POS_NEW_ITEMS);
}
}
} }
@Override @Override
@ -154,9 +166,9 @@ public class MainActivity extends SherlockFragmentActivity {
public static class MainPagerAdapter extends FragmentStatePagerAdapter { public static class MainPagerAdapter extends FragmentStatePagerAdapter {
private static final int NUM_ITEMS = 3; private static final int NUM_ITEMS = 3;
private static final int POS_FEEDLIST = 0; public static final int POS_FEEDLIST = 0;
private static final int POS_NEW_ITEMS = 1; public static final int POS_NEW_ITEMS = 1;
private static final int POS_QUEUE = 2; public static final int POS_QUEUE = 2;
private Context context; private Context context;