@Override public void onBackPressed() { if (mDrawer.isDrawerOpen(GravityCompat.START)) { mDrawer.closeDrawer(GravityCompat.START); return; } // handle back button for all fragment Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); if (fragment instanceof FavoriteBoardFragment) { if (!favoriteBoardFragment.atFavoriteRoot()) { favoriteBoardFragment.popFavoritePath(); favoriteBoardFragment.RefreshFavoriteBoards(); return; } } if (fragment != hotTopicFragment) { // return to hottopic if we are not there yet String title = "首页导读"; FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction().replace(R.id.content_frame, hotTopicFragment).commit(); setTitle(SMTHApplication.App_Title_Prefix + title); return; } // for other cases, double back to exit app DoubleBackToExit(); }
@Override public void onBoardFragmentInteraction(Board item) { // shared by FavoriteBoard & AllBoard fragment Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); if (fragment == favoriteBoardFragment) { // favorite fragment, we might enter a folder if (item.isFolder()) { favoriteBoardFragment.pushFavoritePath(item.getFolderID(), item.getFolderName()); favoriteBoardFragment.RefreshFavoriteBoards(); } else { startBoardTopicActivity(item); } } else if (fragment == allBoardFragment) { startBoardTopicActivity(item); } }