/** * @MethodName: showPage @Functions:显示相关页面 * * @param p :传入参数 * @return :void */ private void showPage(ViewPage p) { if (curViewPage == p) return; curViewPage = p; showView(R.id.file_path_list, false); showView(R.id.navigation_bar, false); showView(R.id.category_page, false); showView(R.id.operation_bar, false); showView(R.id.sd_not_available_page, false); mFavoriteList.show(false); showEmptyView(false); switch (p) { case Home: // 显示分类主页 showView(R.id.category_page, true); FileManagerTabActivity.bar.getSelectedTab().setText(R.string.tab_category); if (mConfigurationChanged) { ((FileManagerTabActivity) mActivity).reInstantiateCategoryTab(); mConfigurationChanged = false; } break; case Favorite: // 显示收藏界面 showView(R.id.navigation_bar, true); // 显示文件目录bar mFavoriteList.show(true); showEmptyView(mFavoriteList.getCount() == 0); break; case Category: // 显示文件列表 showView(R.id.navigation_bar, false); // chb change true——>false showView(R.id.file_path_list, true); showEmptyView(mAdapter.getCount() == 0); break; case NoSD: // 如果SD卡不存在,显示 showView(R.id.sd_not_available_page, true); break; default: break; } }
public void refreshCategoryInfo() { SDCardInfo sdCardInfo = Util.getSDCardInfo(); if (sdCardInfo != null) { mCategoryBar.setFullValue(sdCardInfo.total); setTextView( R.id.sd_card_capacity, getString(R.string.sd_card_size, Util.convertStorage(sdCardInfo.total))); setTextView( R.id.sd_card_available, getString(R.string.sd_card_available, Util.convertStorage(sdCardInfo.free))); } mFileCagetoryHelper.refreshCategoryInfo(); // the other category size should include those files didn't get scanned. long size = 0; for (FileCategory fc : FileCategoryHelper.sCategories) { CategoryInfo categoryInfo = mFileCagetoryHelper.getCategoryInfos().get(fc); setCategoryCount(fc, categoryInfo.count); // other category size should be set separately with calibration if (fc == FileCategory.Other) continue; setCategorySize(fc, categoryInfo.size); setCategoryBarValue(fc, categoryInfo.size); size += categoryInfo.size; } if (sdCardInfo != null) { long otherSize = sdCardInfo.total - sdCardInfo.free - size; setCategorySize(FileCategory.Other, otherSize); setCategoryBarValue(FileCategory.Other, otherSize); } setCategoryCount(FileCategory.Favorite, mFavoriteList.getCount()); if (mCategoryBar.getVisibility() == View.VISIBLE) { mCategoryBar.startAnimation(); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity(); /*mFileViewActivity = (FileViewActivity) ((FileManagerTabActivity) mActivity) .getFragment(Util.SDCARD_TAB_INDEX);*/ mRootView = inflater.inflate(R.layout.mlt_file_manager_category, container, false); // 加载布局界面 curViewPage = ViewPage.Invalid; mFileViewInteractionHub = new FileViewInteractionHub(this); mFileViewInteractionHub.setMode(Mode.View); mFileViewInteractionHub.setRootPath("/"); mFileIconHelper = new FileIconHelper(mActivity); mFavoriteList = new FavoriteList( mActivity, (ListView) mRootView.findViewById(R.id.favorite_list), this, mFileIconHelper); mFavoriteList.initList(); mAdapter = new FileListCursorAdapter(mActivity, null, mFileViewInteractionHub, mFileIconHelper); // chb add begin mPhoneCardLayout = (LinearLayout) mRootView.findViewById(R.id.phone_linearlayout); mPhoneCardLayout.setOnClickListener(mOnClickLististener); mFtpViewLayout = (LinearLayout) mRootView.findViewById(R.id.ftp_list); mFtpViewLayout.setOnClickListener(mOnClickLististener); // chb add end ListView fileListView = (ListView) mRootView.findViewById(R.id.file_path_list); // 文件列表 fileListView.setAdapter(mAdapter); setupClick(); setupCategoryInfo(); updateUI(); registerScannerReceiver(); // 注册广播过滤器 return mRootView; }
// update the count of favorite @Override public void onFavoriteDatabaseChanged() { setCategoryCount(FileCategory.Favorite, mFavoriteList.getCount()); }