Commit 9ba68b4c authored by Matt Simmons's avatar Matt Simmons Committed by Commit Bot

Fix crash due to scroll listener being set to null during animation.

Address TODO and remove state from TabListOnScrollListener.

R=yusufo@chromium.org

Bug: 977955
Change-Id: I45b6020ce855fd0b4cd81c25c5af1b3ca491fd93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1673538Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Matt Simmons <mattsimmons@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671730}
parent 59cd3cc1
...@@ -89,27 +89,16 @@ class TabListRecyclerView extends RecyclerView { ...@@ -89,27 +89,16 @@ class TabListRecyclerView extends RecyclerView {
} }
private class TabListOnScrollListener extends RecyclerView.OnScrollListener { private class TabListOnScrollListener extends RecyclerView.OnScrollListener {
// TODO(mattsimmons): Remove state from this class. This is here to prevent scroll signals
// from showing the toolbar shadow after the show/hide of the GTS has already triggered the
// shadow being hidden. Due to this view's visibility being updated asynchronously after
// animating off-screen, checking View.getVisibility() can't be used as the guard condition
// here. Removing/Adding the listener from the view also happens asynchronously and has
// similar undesirable effects.
private boolean mIsActive;
public void pause() {
mIsActive = false;
}
public void resume() {
mIsActive = true;
}
@Override @Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (!mIsActive) return;
final int yOffset = recyclerView.computeVerticalScrollOffset(); final int yOffset = recyclerView.computeVerticalScrollOffset();
if (yOffset == 0) {
setShadowVisibility(false);
return;
}
if (dy == 0 || recyclerView.getScrollState() == SCROLL_STATE_SETTLING) return;
setShadowVisibility(yOffset > 0); setShadowVisibility(yOffset > 0);
} }
} }
...@@ -176,7 +165,6 @@ class TabListRecyclerView extends RecyclerView { ...@@ -176,7 +165,6 @@ class TabListRecyclerView extends RecyclerView {
mListener.finishedShowing(); mListener.finishedShowing();
// Restore the original value. // Restore the original value.
setItemAnimator(mOriginalAnimator); setItemAnimator(mOriginalAnimator);
mScrollListener.resume();
setShadowVisibility(computeVerticalScrollOffset() > 0); setShadowVisibility(computeVerticalScrollOffset() > 0);
if (mDynamicView != null) { if (mDynamicView != null) {
mDynamicView.dropCachedBitmap(); mDynamicView.dropCachedBitmap();
...@@ -335,7 +323,6 @@ class TabListRecyclerView extends RecyclerView { ...@@ -335,7 +323,6 @@ class TabListRecyclerView extends RecyclerView {
mListener.finishedHiding(); mListener.finishedHiding();
} }
}); });
mScrollListener.pause();
setShadowVisibility(false); setShadowVisibility(false);
mFadeOutAnimator.start(); mFadeOutAnimator.start();
if (!animate) mFadeOutAnimator.end(); if (!animate) mFadeOutAnimator.end();
......
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