Commit 0242f1bd authored by Matt Simmons's avatar Matt Simmons Committed by Commit Bot

Pause scroll listener when GTS hides, resume when shown.

R=yusufo@chromium.org

Bug: 976213
Change-Id: Ia31e1a8c93c77e657bc7f0ca1b22d5bebe364e5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663383
Commit-Queue: Matt Simmons <mattsimmons@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670259}
parent 619b0737
...@@ -76,8 +76,26 @@ class TabListRecyclerView extends RecyclerView { ...@@ -76,8 +76,26 @@ 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();
setShadowVisibility(yOffset > 0); setShadowVisibility(yOffset > 0);
} }
...@@ -145,6 +163,7 @@ class TabListRecyclerView extends RecyclerView { ...@@ -145,6 +163,7 @@ 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();
...@@ -302,6 +321,7 @@ class TabListRecyclerView extends RecyclerView { ...@@ -302,6 +321,7 @@ 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