public void updateCurrentTab(int position) {
    TabInfo tab = mTabs.get(position);
    mCurTab = tab;

    // Put things in the correct paused/resumed state.
    if (mActivityResumed) {
      mCurTab.build(mInflater, mContentContainer, mRootView);
      mCurTab.resume(mSortOrder);
    } else {
      mCurTab.pause();
    }
    for (int i = 0; i < mTabs.size(); i++) {
      TabInfo t = mTabs.get(i);
      if (t != mCurTab) {
        t.pause();
      }
    }

    mCurTab.updateStorageUsage();
    updateOptionsMenu();
    final Activity host = getActivity();
    if (host != null) {
      host.invalidateOptionsMenu();
    }
  }
 @Override
 public void onResume() {
   super.onResume();
   mActivityResumed = true;
   updateCurrentTab(mViewPager.getCurrentItem());
   updateOptionsMenu();
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Log.i(TAG, "onCreateOptionsMenu in " + this + ": " + menu);
    mOptionsMenu = menu;

    /*begin: mzikun modify for add menu icon*/
    // note: icons removed for now because the cause the new action
    // bar UI to be very confusing.
    menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha)
        // .setIcon(android.R.drawable.ic_menu_sort_alphabetically)
        .setIcon(R.drawable.ic_sort_order_alpha)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
        // .setIcon(android.R.drawable.ic_menu_sort_by_size)
        .setIcon(R.drawable.ic_sort_order_size)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services)
        .setIcon(R.drawable.ic_running_services)
        // .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes)
        .setIcon(R.drawable.ic_background_processes)
        // .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    /*end: mzikun modify for add menu icon*/
    updateOptionsMenu();
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int menuId = item.getItemId();
   if ((menuId == SORT_ORDER_ALPHA) || (menuId == SORT_ORDER_SIZE)) {
     mSortOrder = menuId;
     if (mCurTab != null && mCurTab.mApplications != null) {
       mCurTab.mApplications.rebuild(mSortOrder);
     }
   } else if (menuId == SHOW_RUNNING_SERVICES) {
     mShowBackground = false;
     if (mCurTab != null && mCurTab.mRunningProcessesView != null) {
       mCurTab.mRunningProcessesView.mAdapter.setShowBackground(false);
     }
   } else if (menuId == SHOW_BACKGROUND_PROCESSES) {
     mShowBackground = true;
     if (mCurTab != null && mCurTab.mRunningProcessesView != null) {
       mCurTab.mRunningProcessesView.mAdapter.setShowBackground(true);
     }
   } else if (menuId == RESET_APP_PREFERENCES) {
     buildResetDialog();
   } else {
     // Handle the home button
     return false;
   }
   updateOptionsMenu();
   return true;
 }
 public void updateView() {
   updateOptionsMenu();
   final Activity host = getActivity();
   if (host != null) {
     host.invalidateOptionsMenu();
   }
 }
 @Override
 public void onResume() {
   super.onResume();
   mActivityResumed = true;
   showCurrentTab();
   updateOptionsMenu();
   mTabHost.getTabWidget().setEnabled(true);
 }
 @Override
 public void onResume() {
   super.onResume();
   updateView();
   updateOptionsMenu();
   if (mApplications != null) {
     mApplications.resume(mSortOrder);
     mApplications.updateLoading();
   }
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   if (mListType == LIST_TYPE_DOMAINS_URLS) {
     return;
   }
   HelpUtils.prepareHelpMenuItem(
       getActivity(),
       menu,
       mListType == LIST_TYPE_MAIN ? R.string.help_uri_apps : R.string.help_uri_notifications,
       getClass().getName());
   mOptionsMenu = menu;
   inflater.inflate(R.menu.manage_apps, menu);
   updateOptionsMenu();
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int menuId = item.getItemId();
   if ((menuId == SORT_ORDER_ALPHA) || (menuId == SORT_ORDER_SIZE)) {
     mSortOrder = menuId;
     if (mCurView != VIEW_RUNNING) {
       mApplicationsAdapter.rebuild(mFilterApps, mSortOrder);
     }
   } else if (menuId == SHOW_RUNNING_SERVICES) {
     mShowBackground = false;
     mRunningProcessesView.mAdapter.setShowBackground(false);
   } else if (menuId == SHOW_BACKGROUND_PROCESSES) {
     mShowBackground = true;
     mRunningProcessesView.mAdapter.setShowBackground(true);
   }
   updateOptionsMenu();
   return true;
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   mOptionsMenu = menu;
   // note: icons removed for now because the cause the new action
   // bar UI to be very confusing.
   menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha)
       // .setIcon(android.R.drawable.ic_menu_sort_alphabetically)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
   menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
       // .setIcon(android.R.drawable.ic_menu_sort_by_size)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
   menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
   menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
   menu.add(0, RESET_APP_PREFERENCES, 4, R.string.reset_app_preferences)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
   updateOptionsMenu();
 }
示例#11
0
  public void showCurrentTab() {
    String tabId = mDefaultTab = mTabHost.getCurrentTabTag();
    int newOption;
    if (TAB_DOWNLOADED.equalsIgnoreCase(tabId)) {
      newOption = FILTER_APPS_THIRD_PARTY;
    } else if (TAB_ALL.equalsIgnoreCase(tabId)) {
      newOption = FILTER_APPS_ALL;
    } else if (TAB_SDCARD.equalsIgnoreCase(tabId)) {
      newOption = FILTER_APPS_SDCARD;
    } else if (TAB_RUNNING.equalsIgnoreCase(tabId)) {
      ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
          .hideSoftInputFromWindow(getActivity().getWindow().getDecorView().getWindowToken(), 0);
      selectView(VIEW_RUNNING);
      return;
    } else {
      // Invalid option. Do nothing
      return;
    }

    mFilterApps = newOption;
    selectView(VIEW_LIST);
    updateStorageUsage();
    updateOptionsMenu();
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int menuId = item.getItemId();
   switch (item.getItemId()) {
     case R.id.sort_order_alpha:
     case R.id.sort_order_size:
       mSortOrder = menuId;
       if (mApplications != null) {
         mApplications.rebuild(mSortOrder);
       }
       break;
     case R.id.show_system:
     case R.id.hide_system:
       mShowSystem = !mShowSystem;
       mApplications.rebuild(false);
       break;
     case R.id.reset_app_preferences:
       mResetAppsHelper.buildResetDialog();
       return true;
     case R.id.advanced:
       ((SettingsActivity) getActivity())
           .startPreferencePanel(
               AdvancedAppSettings.class.getName(),
               null,
               R.string.configure_apps,
               null,
               this,
               ADVANCED_SETTINGS);
       return true;
     default:
       // Handle the home button
       return false;
   }
   updateOptionsMenu();
   return true;
 }
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   updateOptionsMenu();
 }