From b169ebd4c40b78d8a4c79e416c288af2ab5b5046 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 14 Dec 2015 13:57:36 -0500 Subject: [PATCH] Loading activity icons in History view. Change-Id: I68bbef59d380ce7abe251fca75135775528429d5 --- .../res/layout/recents_history_task.xml | 31 ++++++--- .../history/RecentsHistoryAdapter.java | 68 +++++++++++++++---- .../android/systemui/recents/model/Task.java | 37 +++++++--- .../systemui/recents/views/TaskView.java | 6 +- 4 files changed, 106 insertions(+), 36 deletions(-) diff --git a/packages/SystemUI/res/layout/recents_history_task.xml b/packages/SystemUI/res/layout/recents_history_task.xml index b9de15606bfb4..ae1100604840d 100644 --- a/packages/SystemUI/res/layout/recents_history_task.xml +++ b/packages/SystemUI/res/layout/recents_history_task.xml @@ -13,15 +13,30 @@ See the License for the specific language governing permissions and limitations under the License. --> - \ No newline at end of file + android:orientation="horizontal" + android:clickable="true" + android:focusable="true" + android:background="?android:selectableItemBackground"> + + + \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java index 06265bd8c12b3..abe3c01f836f0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java @@ -23,10 +23,12 @@ import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.android.systemui.R; import com.android.systemui.recents.Recents; import com.android.systemui.recents.misc.SystemServicesProxy; +import com.android.systemui.recents.model.RecentsTaskLoader; import com.android.systemui.recents.model.Task; import java.util.ArrayList; @@ -49,14 +51,34 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter mCallbacks = new ArrayList<>(); public Task() { // Do nothing @@ -157,9 +158,20 @@ public class Task { this.bounds = o.bounds; } - /** Set the callbacks */ - public void setCallbacks(TaskCallbacks cb) { - mCb = cb; + /** + * Add a callback. + */ + public void addCallback(TaskCallbacks cb) { + if (!mCallbacks.contains(cb)) { + mCallbacks.add(cb); + } + } + + /** + * Remove a callback. + */ + public void removeCallback(TaskCallbacks cb) { + mCallbacks.remove(cb); } /** Set the grouping */ @@ -175,8 +187,9 @@ public class Task { */ public void setStackId(int stackId) { key.stackId = stackId; - if (mCb != null) { - mCb.onTaskStackIdChanged(); + int callbackCount = mCallbacks.size(); + for (int i = 0; i < callbackCount; i++) { + mCallbacks.get(i).onTaskStackIdChanged(); } } @@ -192,8 +205,9 @@ public class Task { public void notifyTaskDataLoaded(Bitmap thumbnail, Drawable applicationIcon) { this.applicationIcon = applicationIcon; this.thumbnail = thumbnail; - if (mCb != null) { - mCb.onTaskDataLoaded(); + int callbackCount = mCallbacks.size(); + for (int i = 0; i < callbackCount; i++) { + mCallbacks.get(i).onTaskDataLoaded(this); } } @@ -201,8 +215,9 @@ public class Task { public void notifyTaskDataUnloaded(Bitmap defaultThumbnail, Drawable defaultApplicationIcon) { applicationIcon = defaultApplicationIcon; thumbnail = defaultThumbnail; - if (mCb != null) { - mCb.onTaskDataUnloaded(); + int callbackCount = mCallbacks.size(); + for (int i = 0; i < callbackCount; i++) { + mCallbacks.get(i).onTaskDataUnloaded(); } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index ab51d5f268586..3b6130c76bf40 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -678,7 +678,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, /** Binds this task view to the task */ public void onTaskBound(Task t) { mTask = t; - mTask.setCallbacks(this); + mTask.addCallback(this); // Hide the action button if lock to app is disabled for this view int lockButtonVisibility = (!t.lockToTaskEnabled || !t.lockToThisTask) ? GONE : VISIBLE; @@ -689,7 +689,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, } @Override - public void onTaskDataLoaded() { + public void onTaskDataLoaded(Task task) { if (mThumbnailView != null && mHeaderView != null) { // Bind each of the views to the new task data mThumbnailView.rebindToTask(mTask); @@ -706,7 +706,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, public void onTaskDataUnloaded() { if (mThumbnailView != null && mHeaderView != null) { // Unbind each of the views from the task data and remove the task callback - mTask.setCallbacks(null); + mTask.removeCallback(this); mThumbnailView.unbindFromTask(); mHeaderView.unbindFromTask(); // Unbind any listeners