public void resume(int sort) {
   if (DEBUG) Log.i(TAG, "Resume!  mResumed=" + mResumed);
   if (!mResumed) {
     mResumed = true;
     mSession.resume();
     mLastSortMode = sort;
     rebuild(true);
   } else {
     rebuild(sort);
   }
 }
    public void rebuild(boolean eraseold) {
      if (DEBUG) Log.i(TAG, "Rebuilding app list...");
      ApplicationsState.AppFilter filterObj;
      Comparator<AppEntry> comparatorObj;
      boolean emulated = Environment.isExternalStorageEmulated();
      if (emulated) {
        mWhichSize = SIZE_TOTAL;
      } else {
        mWhichSize = SIZE_INTERNAL;
      }
      switch (mFilterMode) {
        case FILTER_APPS_THIRD_PARTY:
          filterObj = ApplicationsState.THIRD_PARTY_FILTER;
          break;
        case FILTER_APPS_SDCARD:
          filterObj = ApplicationsState.ON_SD_CARD_FILTER;
          if (!emulated) {
            mWhichSize = SIZE_EXTERNAL;
          }
          break;
        default:
          filterObj = null;
          break;
      }
      switch (mLastSortMode) {
        case SORT_ORDER_SIZE:
          switch (mWhichSize) {
            case SIZE_INTERNAL:
              comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR;
              break;
            case SIZE_EXTERNAL:
              comparatorObj = ApplicationsState.EXTERNAL_SIZE_COMPARATOR;
              break;
            default:
              comparatorObj = ApplicationsState.SIZE_COMPARATOR;
              break;
          }
          break;
        default:
          comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
          break;
      }
      ArrayList<ApplicationsState.AppEntry> entries = mSession.rebuild(filterObj, comparatorObj);
      if (entries == null && !eraseold) {
        // Don't have new list yet, but can continue using the old one.
        return;
      }
      mBaseEntries = entries;
      if (mBaseEntries != null) {
        mEntries = applyPrefixFilter(mCurFilterPrefix, mBaseEntries);
      } else {
        mEntries = null;
      }
      notifyDataSetChanged();
      mTab.updateStorageUsage();

      if (entries == null) {
        mWaitingForData = true;
        mTab.mListContainer.setVisibility(View.INVISIBLE);
        mTab.mLoadingContainer.setVisibility(View.VISIBLE);
      } else {
        mTab.mListContainer.setVisibility(View.VISIBLE);
        mTab.mLoadingContainer.setVisibility(View.GONE);
      }
    }
 public void pause() {
   if (mResumed) {
     mResumed = false;
     mSession.pause();
   }
 }