diff options
| author | 2018-08-02 13:15:59 +0000 | |
|---|---|---|
| committer | 2018-08-02 13:15:59 +0000 | |
| commit | e20cd739c8da023f3e472ee7b6084665c668b523 (patch) | |
| tree | d4ca4876fb437f32c78d5a9a46969c3244f05d42 | |
| parent | 13cb8b8dd0e83e9c8aae541b25ca74edb7e726fb (diff) | |
| parent | 46a48cf0b0d815cf20e4ccf2e6846c20855ac637 (diff) | |
Merge "Revert "Fix PagedTileLayout reveal animation crash.""
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index 91f1d3dcab4a..f13f4899baed 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -55,6 +55,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { private Scroller mScroller; private AnimatorSet mBounceAnimatorSet; + private int mAnimatingToPage = -1; private float mLastExpansion; public PagedTileLayout(Context context, AttributeSet attrs) { @@ -94,16 +95,40 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { } @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + // Suppress all touch event during reveal animation. + if (mAnimatingToPage != -1) { + return true; + } + return super.onInterceptTouchEvent(ev); + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + // Suppress all touch event during reveal animation. + if (mAnimatingToPage != -1) { + return true; + } + return super.onTouchEvent(ev); + } + + @Override public void computeScroll() { if (!mScroller.isFinished() && mScroller.computeScrollOffset()) { - fakeDragBy(getScrollX() - mScroller.getCurrX()); + scrollTo(mScroller.getCurrX(), mScroller.getCurrY()); + float pageFraction = (float) getScrollX() / getWidth(); + int position = (int) pageFraction; + float positionOffset = pageFraction - position; + mOnPageChangeListener.onPageScrolled(position, positionOffset, getScrollX()); // Keep on drawing until the animation has finished. postInvalidateOnAnimation(); return; - } else if (isFakeDragging()) { - endFakeDrag(); + } + if (mAnimatingToPage != -1) { + setCurrentItem(mAnimatingToPage, true); mBounceAnimatorSet.start(); setOffscreenPageLimit(1); + mAnimatingToPage = -1; } super.computeScroll(); } @@ -262,7 +287,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { } public void startTileReveal(Set<String> tileSpecs, final Runnable postAnimation) { - if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) { + if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0) { // Do not start the reveal animation unless there are tiles to animate, multiple // TilePages available and the user has not already started dragging. return; @@ -292,8 +317,9 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { postAnimation.run(); } }); - setOffscreenPageLimit(lastPageNumber); // Ensure the page to reveal has been inflated. - mScroller.startScroll(getScrollX(), getScrollY(), getWidth() * lastPageNumber, 0, + mAnimatingToPage = lastPageNumber; + setOffscreenPageLimit(mAnimatingToPage); // Ensure the page to reveal has been inflated. + mScroller.startScroll(getScrollX(), getScrollY(), getWidth() * mAnimatingToPage, 0, REVEAL_SCROLL_DURATION_MILLIS); postInvalidateOnAnimation(); } |