public boolean doResume(Fragment owner, Runnable dataAvail) {
   mOwner = owner;
   mState.resume(this);
   if (mState.hasData()) {
     // If the state already has its data, then let's populate our
     // list right now to avoid flicker.
     refreshUi(true);
     return true;
   }
   mDataAvail = dataAvail;
   return false;
 }
 void refreshItems() {
   ArrayList<RunningState.MergedItem> newItems =
       mShowBackground ? mState.getCurrentBackgroundItems() : mState.getCurrentMergedItems();
   if (mOrigItems != newItems) {
     mOrigItems = newItems;
     if (newItems == null) {
       mItems.clear();
     } else {
       mItems.clear();
       mItems.addAll(newItems);
       if (mShowBackground) {
         Collections.sort(mItems, mState.mBackgroundComparator);
       }
     }
   }
 }
 void setShowBackground(boolean showBackground) {
   if (mShowBackground != showBackground) {
     mShowBackground = showBackground;
     mState.setWatchingBackgroundItems(showBackground);
     refreshItems();
     notifyDataSetChanged();
     mColorBar.setShowingGreen(mShowBackground);
   }
 }
  public void doCreate(Bundle savedInstanceState) {
    mAm = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    mState = RunningState.getInstance(getContext());
    LayoutInflater inflater =
        (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.running_processes_view, this);
    mListView = (ListView) findViewById(android.R.id.list);
    View emptyView = findViewById(com.android.internal.R.id.empty);
    if (emptyView != null) {
      mListView.setEmptyView(emptyView);
    }
    mListView.setOnItemClickListener(this);
    mListView.setRecyclerListener(this);
    mAdapter = new ServiceListAdapter(mState);
    mListView.setAdapter(mAdapter);
    mColorBar = (LinearColorBar) findViewById(R.id.color_bar);
    mBackgroundProcessText = (TextView) findViewById(R.id.backgroundText);
    mBackgroundProcessText.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mAdapter.setShowBackground(true);
          }
        });
    mForegroundProcessText = (TextView) findViewById(R.id.foregroundText);
    mForegroundProcessText.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mAdapter.setShowBackground(false);
          }
        });

    ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
    mAm.getMemoryInfo(memInfo);
    SECONDARY_SERVER_MEM = memInfo.secondaryServerThreshold;
  }
 public void doPause() {
   mState.pause();
   mDataAvail = null;
   mOwner = null;
 }
 @Override
 public boolean isEmpty() {
   return mState.hasData() && mItems.size() == 0;
 }