Commit 6a9d8b41 authored by Lijin Shen's avatar Lijin Shen Committed by Commit Bot

Fix crash on tablet when reordering bookmark page is closed by notification

If reordering bookmark page is closed by clicking 'Close Incognito Tabs' on
notifications, then the runnable posted by recyclerView will be run. But at
that moment, bookmark model has been assigned to null. This CL makes it
only run when view is being attached to window.

Bug: 1017073
Change-Id: I328550a11432a7288b9508227f9634e9719ae357
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884350Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Lijin Shen <lazzzis@google.com>
Cr-Commit-Position: refs/heads/master@{#710016}
parent f1af4b3d
......@@ -92,7 +92,9 @@ public abstract class DragReorderableListAdapter<T> extends RecyclerView.Adapter
@Override
public void clearView(RecyclerView recyclerView, ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
if (viewHolder.getAdapterPosition() != mStart) {
// no need to commit change if recycler view is not attached to window, e.g.:
// dragging is terminated by destroying activity
if (viewHolder.getAdapterPosition() != mStart && recyclerView.isAttachedToWindow()) {
// Commit the position change for the dragged item when it's dropped and
// recyclerView has finished layout computing
recyclerView.post(() -> setOrder(mElements));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment