Clear all button should not be swipable
Unlike other task items in the recycler view, the clear all button
should not be swipable as you obviously can't remove the button.
Bug: 114136250
Test: Go to recents, attempt to swipe clear all, does not work
Change-Id: I0ab00c03b697f2174431b69bbf758c3ff104db97
(cherry picked from commit cd88cf8d1c
)
This commit is contained in:
parent
072dcc3aeb
commit
0eefc8530e
|
@ -43,9 +43,10 @@ public final class TaskAdapter extends Adapter<ViewHolder> {
|
||||||
public static final int MAX_TASKS_TO_DISPLAY = 6;
|
public static final int MAX_TASKS_TO_DISPLAY = 6;
|
||||||
public static final int TASKS_START_POSITION = 1;
|
public static final int TASKS_START_POSITION = 1;
|
||||||
|
|
||||||
|
public static final int ITEM_TYPE_TASK = 0;
|
||||||
|
public static final int ITEM_TYPE_CLEAR_ALL = 1;
|
||||||
|
|
||||||
private static final String TAG = "TaskAdapter";
|
private static final String TAG = "TaskAdapter";
|
||||||
private static final int ITEM_TYPE_TASK = 0;
|
|
||||||
private static final int ITEM_TYPE_CLEAR_ALL = 1;
|
|
||||||
private final TaskListLoader mLoader;
|
private final TaskListLoader mLoader;
|
||||||
private TaskActionController mTaskActionController;
|
private TaskActionController mTaskActionController;
|
||||||
private OnClickListener mClearAllListener;
|
private OnClickListener mClearAllListener;
|
||||||
|
|
|
@ -17,6 +17,9 @@ package com.android.quickstep;
|
||||||
|
|
||||||
import static androidx.recyclerview.widget.ItemTouchHelper.RIGHT;
|
import static androidx.recyclerview.widget.ItemTouchHelper.RIGHT;
|
||||||
|
|
||||||
|
import static com.android.quickstep.TaskAdapter.ITEM_TYPE_CLEAR_ALL;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||||
|
@ -45,4 +48,14 @@ public final class TaskSwipeCallback extends ItemTouchHelper.SimpleCallback {
|
||||||
mTaskActionController.removeTask((TaskHolder) viewHolder);
|
mTaskActionController.removeTask((TaskHolder) viewHolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSwipeDirs(@NonNull RecyclerView recyclerView,
|
||||||
|
@NonNull ViewHolder viewHolder) {
|
||||||
|
if (viewHolder.getItemViewType() == ITEM_TYPE_CLEAR_ALL) {
|
||||||
|
// Clear all button should not be swipable.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return super.getSwipeDirs(recyclerView, viewHolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue