@Override protected void onResume() { super.onResume(); // Set "All posts" selected blog.setCurrentPage(1); if (mViewPager != null) { mViewPager.setCurrentItem(1); } // Reset alarm on app start if (MainActivity.newPostAlarm != null) { MainActivity.newPostAlarm.cancelAlarm(this); } else { MainActivity.newPostAlarm = new NewPostAlarm(); } MainActivity.newPostAlarm.setAlarm(this); // Google Analytics track if (Utils.checkPlayServices(this)) { Tracker t = this.getTracker(TrackerName.APP_TRACKER); t.setScreenName("capture"); t.send(new HitBuilders.AppViewBuilder().build()); } // Close the Drawer mNavigationDrawerFragment.getDrawerLayout().closeDrawers(); }
@Override public void onNavigationDrawerItemSelected(int position) { switch (position) { // SHOW ALL POSTS case 1: if (!blog.getActiveFilter().equals(Blog.FILTER_ALL)) { blog.setActiveFilter(Blog.FILTER_ALL); blog.setCurrentPage(1); } // Force to refresh by changing the title mSectionsPagerAdapter.changeTitle(1, getString(R.string.navigation_drawer_section1)); mViewPager.setCurrentItem(1); actionBar.setTitle(getString(R.string.app_name)); break; // SCROLL TO CATEGORIES case 2: mViewPager.setCurrentItem(0); break; // SCROLL TO AUTHORS case 3: mViewPager.setCurrentItem(2); break; // SHOW FAVOURITES POSTS case 4: if (!blog.getActiveFilter().equals(Blog.FILTER_FAVOURITES)) { blog.setActiveFilter(Blog.FILTER_FAVOURITES); blog.setCurrentPage(1); } // Force to refresh by changing the title mSectionsPagerAdapter.changeTitle(1, getString(R.string.navigation_drawer_section4)); actionBar.setTitle(getString(R.string.navigation_drawer_section4)); mViewPager.setCurrentItem(1); break; // LAUCH DEFAULT EMAIL APP case 5: Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/message"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"}); intent.putExtra(Intent.EXTRA_SUBJECT, ""); intent.putExtra(Intent.EXTRA_TEXT, ""); Intent mailer = Intent.createChooser(intent, null); startActivity(mailer); break; } }