public void refreshViews() {
   if (DEBUG) Log.d(TAG, "refreshViews count =" + mListAdapter.getCount());
   mListAdapter.notifyDataSetInvalidated();
   updateUiElements();
   /* YUNOS BEGIN */
   // ##modules(systemui recents)
   // ##date:2013-11-19 ##author:[email protected]
   updateRecentTaskCount();
   // updateMemInfo();
   /* YUNOS END */
   showIfReady();
 }
 public void onTaskLoadingCancelled(boolean refreshView) {
   // Gets called by RecentTasksLoader when it's cancelled
   if (mRecentTaskDescriptions != null) {
     mRecentTaskDescriptions = null;
     if (refreshView) mListAdapter.notifyDataSetInvalidated();
   }
 }
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    mRecentsContainer = (ViewGroup) findViewById(R.id.recents_container);

    mListAdapter = new TaskDescriptionAdapter(mContext);
    if (mRecentsContainer instanceof RecentsScrollView) {
      RecentsScrollView scrollView = (RecentsScrollView) mRecentsContainer;
      mListAdapter.setItemWidth(scrollView.getItemWidth());
      scrollView.setAdapter(mListAdapter);
      scrollView.setCallback(this);
    } else {
      throw new IllegalArgumentException("missing Recents[Horizontal]ScrollView");
    }

    mRecentsScrim = findViewById(R.id.recents_bg_protect);
    mRecentsNoApps = findViewById(R.id.recents_no_apps);
    mClearRecents = (ImageView) findViewById(R.id.recents_rock);
    mProgress = (AliProgress) findViewById(R.id.progress);
    if (mClearRecents != null) {
      mClearRecents.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              long avilableSize = MemoryUtil.getSystemAvaialbeMemorySize(mContext);
              Intent intent = new Intent();
              TaskDescription firstTaskDescription =
                  RecentTasksLoader.getInstance(mContext).getFirstTaskDescription();

              int numRecentApps =
                  mRecentTaskDescriptions != null ? mRecentTaskDescriptions.size() : 0;
              long memRelease = 0;
              if (firstTaskDescription != null) {
                String pkgName = firstTaskDescription.getPackageName();
                boolean isTaskLocked =
                    !mContext.getPackageName().equals(pkgName)
                        && !RecentTasksLoader.HOME_PACKAGE_NAME.equals(pkgName);
                if (isTaskLocked) {
                  intent.putExtra("package", pkgName);
                }
              }
              // mContext.sendBroadcast(intent);
              ComponentName serviceComponent =
                  new ComponentName(
                      "com.aliyun.SecurityCenter",
                      "com.aliyun.SecurityCenter.applications.ManageApplicationsService");
              intent.setComponent(serviceComponent);
              // getContext().startService(intent);

              for (int i = 0; i < numRecentApps; i++) {
                String packageName =
                    mRecentTaskDescriptions.get(i).packageName
                        + mRecentTaskDescriptions.get(i).resolveInfo.activityInfo.name;
                if (!MemoryUtil.isTaskLocked(mContext, mRecentTaskDescriptions.get(i).packageName))
                  memRelease +=
                      MemoryUtil.getPackageAvailabelMemory(
                          mContext, mRecentTaskDescriptions.get(i).packageName);
              }
              long total = MemoryUtil.getTotalMemory(mContext);
              long willAvailable =
                  MemoryUtil.getSystemAvaialbeMemorySize(mContext) + memRelease * 1024;
              long percent = 100 - (willAvailable * 100) / total;
              mClearAppType = CLEARALLAPPS;
              mProgress.setMemorySizeBeforeClear(avilableSize);
              mProgress.setIsClickAccerlateButton(true);
              mRecentsContainer.removeAllViewsInLayout();
              mProgress.startClearAnimation((int) percent);
              setCurrentColor((int) percent);
              updateRecentTaskCurrentMemPercent((int) percent);
            }
          });
    }
    /* YUNOS_END */
    if (mRecentsScrim != null) {
      mHighEndGfx = true; /* ActivityManager.isHighEndGfx() */
      ;
      if (!mHighEndGfx) {
        mRecentsScrim.setBackground(null);
      } else if (mRecentsScrim.getBackground() instanceof BitmapDrawable) {
        // In order to save space, we make the background texture repeat
        // in the Y direction
        ((BitmapDrawable) mRecentsScrim.getBackground()).setTileModeY(TileMode.REPEAT);
      }
    }
  }
 public void updateRecentTaskCount() {
   TextView view = (TextView) findViewById(R.id.recent_task_num);
   if (view != null) {
     view.setText(String.valueOf(mListAdapter.getCount()));
   }
 }