diff options
Diffstat (limited to 'go')
-rw-r--r-- | go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java | 10 | ||||
-rw-r--r-- | go/quickstep/src/com/android/quickstep/views/IconRecentsView.java | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java b/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java index 76865435a..57f49d653 100644 --- a/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java +++ b/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java @@ -26,16 +26,18 @@ import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.ViewHolder; +import java.util.function.Consumer; + /** * Callback for swipe input on {@link TaskHolder} views in the recents view. */ public final class TaskSwipeCallback extends ItemTouchHelper.SimpleCallback { - private final TaskActionController mTaskActionController; + private final Consumer<TaskHolder> mOnTaskSwipeCallback; - public TaskSwipeCallback(TaskActionController taskActionController) { + public TaskSwipeCallback(Consumer<TaskHolder> onTaskSwipeCallback) { super(0 /* dragDirs */, RIGHT); - mTaskActionController = taskActionController; + mOnTaskSwipeCallback = onTaskSwipeCallback; } @Override @@ -47,7 +49,7 @@ public final class TaskSwipeCallback extends ItemTouchHelper.SimpleCallback { @Override public void onSwiped(ViewHolder viewHolder, int direction) { if (direction == RIGHT) { - mTaskActionController.removeTask((TaskHolder) viewHolder); + mOnTaskSwipeCallback.accept((TaskHolder) viewHolder); } } diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index c52a94f81..7225e572b 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -168,7 +168,12 @@ public final class IconRecentsView extends FrameLayout implements Insettable { mTaskRecyclerView.setAdapter(mTaskAdapter); mTaskRecyclerView.setLayoutManager(mTaskLayoutManager); ItemTouchHelper helper = new ItemTouchHelper( - new TaskSwipeCallback(mTaskActionController)); + new TaskSwipeCallback(holder -> { + mTaskActionController.removeTask(holder); + if (mTaskLoader.getCurrentTaskList().isEmpty()) { + mActivityHelper.leaveRecents(); + } + })); helper.attachToRecyclerView(mTaskRecyclerView); mTaskRecyclerView.addOnChildAttachStateChangeListener( new OnChildAttachStateChangeListener() { @@ -459,7 +464,6 @@ public final class IconRecentsView extends FrameLayout implements Insettable { if (mShowingContentView != mEmptyView && taskListSize == 0) { mShowingContentView = mEmptyView; crossfadeViews(mEmptyView, mContentView); - mActivityHelper.leaveRecents(); } if (mShowingContentView != mContentView && taskListSize > 0) { mShowingContentView = mContentView; |