@Override public void onBackPressed() { // TODO Auto-generated method stub if (mFileViewFragment == null) finish(); if (sm.isMenuShowing()) { sm.showContent(); } else if (!mFileViewFragment.onBack()) { exit(); } }
// 显示选择的碎片 public final void setShowSelFragments(MenuItemType menutype) { mCurrentmenuItemType = menutype; getSlidingMenu().showContent(); // 显示内容Fragment,隐藏Menu bmenuVisible = mSlidingMenuFragment.SelMenu(menutype); if (menutype == MenuItemType.MENU_DEVICE) { setTitle(R.string.my_device); setFileNum(mFileViewFragment.getAllFiles().size(), mCurrentmenuItemType); mfragmentTransaction = getSupportFragmentManager().beginTransaction(); mfragmentTransaction.show(getSupportFragmentManager().findFragmentById(R.id.file_fragment)); mfragmentTransaction.hide( getSupportFragmentManager().findFragmentById(R.id.category_fragment)); mfragmentTransaction.hide(getSupportFragmentManager().findFragmentById(R.id.ftp_fragment)); mfragmentTransaction.commitAllowingStateLoss(); return; } if (menutype == MenuItemType.MENU_WIFI) { setTitle(R.string.wifi); filenum.setText(""); ; mfragmentTransaction = getSupportFragmentManager().beginTransaction(); mfragmentTransaction.hide(getSupportFragmentManager().findFragmentById(R.id.file_fragment)); mfragmentTransaction.hide( getSupportFragmentManager().findFragmentById(R.id.category_fragment)); mfragmentTransaction.show(getSupportFragmentManager().findFragmentById(R.id.ftp_fragment)); mfragmentTransaction.commitAllowingStateLoss(); return; } mfragmentTransaction = getSupportFragmentManager().beginTransaction(); mfragmentTransaction.hide(getSupportFragmentManager().findFragmentById(R.id.file_fragment)); mfragmentTransaction.show(getSupportFragmentManager().findFragmentById(R.id.category_fragment)); mfragmentTransaction.hide(getSupportFragmentManager().findFragmentById(R.id.ftp_fragment)); mfragmentTransaction.commitAllowingStateLoss(); switch (menutype) { case MENU_FAVORITE: setTitle(R.string.star); mFileCategoryFragment.onCategorySelected(FileCategoryType.Favorite); break; case MENU_IMAGE: setTitle(R.string.image); setFileNum( (int) mSlidingMenuFragment.getFilenum(FileCategoryType.Picture), mCurrentmenuItemType); mFileCategoryFragment.onCategorySelected(FileCategoryType.Picture); break; case MENU_VIDEO: setTitle(R.string.video); setFileNum( (int) mSlidingMenuFragment.getFilenum(FileCategoryType.Video), mCurrentmenuItemType); mFileCategoryFragment.onCategorySelected(FileCategoryType.Video); break; case MENU_DOCUMENT: setTitle(R.string.document); setFileNum( (int) mSlidingMenuFragment.getFilenum(FileCategoryType.Doc), mCurrentmenuItemType); mFileCategoryFragment.onCategorySelected(FileCategoryType.Doc); break; case MENU_ZIP: setTitle(R.string.zip); setFileNum( (int) mSlidingMenuFragment.getFilenum(FileCategoryType.Zip), mCurrentmenuItemType); mFileCategoryFragment.onCategorySelected(FileCategoryType.Zip); break; case MENU_APK: setTitle(R.string.apk); setFileNum( (int) mSlidingMenuFragment.getFilenum(FileCategoryType.Apk), mCurrentmenuItemType); mFileCategoryFragment.onCategorySelected(FileCategoryType.Apk); break; case MENU_MUSIC: setTitle(R.string.music); setFileNum( (int) mSlidingMenuFragment.getFilenum(FileCategoryType.Music), mCurrentmenuItemType); mFileCategoryFragment.onCategorySelected(FileCategoryType.Music); break; default: break; } }