From 060fcd3f86e87e5829c673686e8e32f3b947b071 Mon Sep 17 00:00:00 2001 From: Sid Soundararajan Date: Wed, 11 May 2016 11:37:53 -0700 Subject: [PATCH] Remove task based on object rather than position Is some cases, the adapter is changed before the AnimationListener is fired. Thus we need to remove the task without relying on position. BUG: 28703989 Change-Id: If5cfe8589bbf6938c6e57e8e4c7bd54de6e3bd68 --- .../tv/views/TaskStackHorizontalViewAdapter.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java index ed28ef173f0f6..0a6d1ed1a2947 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java @@ -16,7 +16,6 @@ package com.android.systemui.recents.tv.views; import android.animation.Animator; -import android.app.Activity; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; @@ -87,7 +86,7 @@ public class TaskStackHorizontalViewAdapter extends @Override public void onAnimationEnd(Animator animation) { - removeAt(position); + removeTask(task); EventBus.getDefault().send(new DeleteTaskDataEvent(task)); mShouldReset = true; } @@ -148,20 +147,15 @@ public class TaskStackHorizontalViewAdapter extends return mTaskList.size(); } - private void removeAt(int position) { - Task removedTask = mTaskList.remove(position); - if (mGridView != null) { - mGridView.getStack().removeTask(removedTask, AnimationProps.IMMEDIATE, - false); - } - notifyItemRemoved(position); - } - public void removeTask(Task task) { int position = mTaskList.indexOf(task); if (position >= 0) { mTaskList.remove(position); notifyItemRemoved(position); + if (mGridView != null) { + mGridView.getStack().removeTask(task, AnimationProps.IMMEDIATE, + false); + } } }