From c7873d1dc2a5fd39ed68dd1f827f0c047d8bc210 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Fri, 11 Dec 2020 09:42:07 -0600 Subject: [PATCH] Remove anchor scrolling Fixes: 175336550 Test: manual, no regressions Change-Id: Ie262e9023cb1a51d449ea3a74867dbd4798d1a41 --- .../notification/stack/AmbientState.java | 23 - .../stack/NotificationStackScrollLayout.java | 798 ++++-------------- .../stack/StackScrollAlgorithm.java | 57 +- 3 files changed, 175 insertions(+), 703 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java index 885048df13f18..c5dd3c771da13 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java @@ -42,8 +42,6 @@ public class AmbientState { private final SectionProvider mSectionProvider; private int mScrollY; - private int mAnchorViewIndex; - private int mAnchorViewY; private boolean mDimmed; private ActivatableNotificationView mActivatedChild; private float mOverScrollTopAmount; @@ -139,27 +137,6 @@ public class AmbientState { this.mScrollY = scrollY; } - /** - * Index of the child view whose Y position on screen is returned by {@link #getAnchorViewY()}. - * Other views are laid out outwards from this view in both directions. - */ - public int getAnchorViewIndex() { - return mAnchorViewIndex; - } - - public void setAnchorViewIndex(int anchorViewIndex) { - mAnchorViewIndex = anchorViewIndex; - } - - /** Current Y position of the view at {@link #getAnchorViewIndex()}. */ - public int getAnchorViewY() { - return mAnchorViewY; - } - - public void setAnchorViewY(int anchorViewY) { - mAnchorViewY = anchorViewY; - } - /** * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are * translucent and everything is scaled back a bit. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 4487142e89070..bbfae7c17ea53 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.notification.stack; import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_SCROLL_FLING; import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters; import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_SILENT; -import static com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.ANCHOR_SCROLLING; import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_SWIPE; import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; @@ -164,9 +163,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private float mExpandedHeight; private int mOwnScrollY; - - private View mScrollAnchorView; - private int mScrollAnchorViewY; private int mMaxLayoutHeight; private VelocityTracker mVelocityTracker; @@ -423,9 +419,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private int mCachedBackgroundColor; private boolean mHeadsUpGoingAwayAnimationsAllowed = true; private Runnable mReflingAndAnimateScroll = () -> { - if (ANCHOR_SCROLLING) { - maybeReflingScroller(); - } animateScroll(); }; private int mCornerRadius; @@ -480,23 +473,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private final ScrollAdapter mScrollAdapter = new ScrollAdapter() { @Override public boolean isScrolledToTop() { - if (ANCHOR_SCROLLING) { - updateScrollAnchor(); - // TODO: once we're recycling this will need to check the adapter position of the - // child - return mScrollAnchorView == getFirstChildNotGone() && mScrollAnchorViewY >= 0; - } else { - return mOwnScrollY == 0; - } + return mOwnScrollY == 0; } @Override public boolean isScrolledToBottom() { - if (ANCHOR_SCROLLING) { - return getMaxPositiveScrollAmount() <= 0; - } else { - return mOwnScrollY >= getScrollRange(); - } + return mOwnScrollY >= getScrollRange(); } @Override @@ -665,30 +647,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } } - @Override - public void draw(Canvas canvas) { - super.draw(canvas); - - if (DEBUG && ANCHOR_SCROLLING) { - if (mScrollAnchorView instanceof ExpandableNotificationRow) { - canvas.drawRect(0, - mScrollAnchorView.getTranslationY(), - getWidth(), - mScrollAnchorView.getTranslationY() - + ((ExpandableNotificationRow) mScrollAnchorView).getActualHeight(), - mDebugPaint); - canvas.drawText(Integer.toString(mScrollAnchorViewY), getWidth() - 200, - mScrollAnchorView.getTranslationY() + 30, mDebugPaint); - int y = (int) mShelf.getTranslationY(); - canvas.drawLine(0, y, getWidth(), y, mDebugPaint); - } - canvas.drawText(Integer.toString(getMaxNegativeScrollAmount()), getWidth() - 100, - getTopPadding() + 30, mDebugPaint); - canvas.drawText(Integer.toString(getMaxPositiveScrollAmount()), getWidth() - 100, - getHeight() - 30, mDebugPaint); - } - } - @ShadeViewRefactor(RefactorComponent.DECORATOR) private void drawBackground(Canvas canvas) { int lockScreenLeft = mSidePaddings; @@ -996,10 +954,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mListener = listener; } - public void setScrollAnchorView(View scrollAnchorView) { - mScrollAnchorView = scrollAnchorView; - } - @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) private void setMaxLayoutHeight(int maxLayoutHeight) { mMaxLayoutHeight = maxLayoutHeight; @@ -1030,12 +984,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mAmbientState.setCurrentScrollVelocity(mScroller.isFinished() ? 0 : mScroller.getCurrVelocity()); - if (ANCHOR_SCROLLING) { - mAmbientState.setAnchorViewIndex(indexOfChild(mScrollAnchorView)); - mAmbientState.setAnchorViewY(mScrollAnchorViewY); - } else { - mAmbientState.setScrollY(mOwnScrollY); - } + mAmbientState.setScrollY(mOwnScrollY); mStackScrollAlgorithm.resetViewStates(mAmbientState, getSpeedBumpIndex()); if (!isCurrentlyAnimating() && !mNeedsAnimation) { applyCurrentState(); @@ -1081,18 +1030,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable if (mChildrenToAddAnimated.isEmpty()) { return; } - if (!ANCHOR_SCROLLING) { - for (int i = 0; i < getChildCount(); i++) { - ExpandableView child = (ExpandableView) getChildAt(i); - if (mChildrenToAddAnimated.contains(child)) { - final int startingPosition = getPositionInLinearLayout(child); - final int childHeight = getIntrinsicHeight(child) + mPaddingBetweenElements; - if (startingPosition < mOwnScrollY) { - // This child starts off screen, so let's keep it offscreen to keep the - // others visible + for (int i = 0; i < getChildCount(); i++) { + ExpandableView child = (ExpandableView) getChildAt(i); + if (mChildrenToAddAnimated.contains(child)) { + final int startingPosition = getPositionInLinearLayout(child); + final int childHeight = getIntrinsicHeight(child) + mPaddingBetweenElements; + if (startingPosition < mOwnScrollY) { + // This child starts off screen, so let's keep it offscreen to keep the + // others visible - setOwnScrollY(mOwnScrollY + childHeight); - } + setOwnScrollY(mOwnScrollY + childHeight); } } } @@ -1110,17 +1057,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable int positionInLinearLayout = getPositionInLinearLayout(expandableView); int targetScroll = targetScrollForView(expandableView, positionInLinearLayout); int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight(); - - if (ANCHOR_SCROLLING) { - // TODO - } else { - targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange())); - - // Only apply the scroll if we're scrolling the view upwards, or the view is so - // far up that it is not visible anymore. - if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { - setOwnScrollY(targetScroll); - } + targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange())); + // Only apply the scroll if we're scrolling the view upwards, or the view is so + // far up that it is not visible anymore. + if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { + setOwnScrollY(targetScroll); } } } @@ -1155,13 +1096,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.COORDINATOR) private void clampScrollPosition() { - if (ANCHOR_SCROLLING) { - // TODO - } else { - int scrollRange = getScrollRange(); - if (scrollRange < mOwnScrollY) { - setOwnScrollY(scrollRange); - } + int scrollRange = getScrollRange(); + if (scrollRange < mOwnScrollY) { + setOwnScrollY(scrollRange); } } @@ -1559,21 +1496,17 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public boolean scrollTo(View v) { ExpandableView expandableView = (ExpandableView) v; - if (ANCHOR_SCROLLING) { - // TODO - } else { - int positionInLinearLayout = getPositionInLinearLayout(v); - int targetScroll = targetScrollForView(expandableView, positionInLinearLayout); - int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight(); + int positionInLinearLayout = getPositionInLinearLayout(v); + int targetScroll = targetScrollForView(expandableView, positionInLinearLayout); + int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight(); - // Only apply the scroll if we're scrolling the view upwards, or the view is so far up - // that it is not visible anymore. - if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { - mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY); - mDontReportNextOverScroll = true; - animateScroll(); - return true; - } + // Only apply the scroll if we're scrolling the view upwards, or the view is so far up + // that it is not visible anymore. + if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { + mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY); + mDontReportNextOverScroll = true; + animateScroll(); + return true; } return false; } @@ -1600,20 +1533,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mWaterfallTopInset = cutout.getWaterfallInsets().top; } - if (ANCHOR_SCROLLING) { - // TODO - } else { - int range = getScrollRange(); - if (mOwnScrollY > range) { - // HACK: We're repeatedly getting staggered insets here while the IME is - // animating away. To work around that we'll wait until things have settled. - removeCallbacks(mReclamp); - postDelayed(mReclamp, 50); - } else if (mForcedScroll != null) { - // The scroll was requested before we got the actual inset - in case we need - // to scroll up some more do so now. - scrollTo(mForcedScroll); - } + int range = getScrollRange(); + if (mOwnScrollY > range) { + // HACK: We're repeatedly getting staggered insets here while the IME is + // animating away. To work around that we'll wait until things have settled. + removeCallbacks(mReclamp); + postDelayed(mReclamp, 50); + } else if (mForcedScroll != null) { + // The scroll was requested before we got the actual inset - in case we need + // to scroll up some more do so now. + scrollTo(mForcedScroll); } return insets; } @@ -1622,12 +1551,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private Runnable mReclamp = new Runnable() { @Override public void run() { - if (ANCHOR_SCROLLING) { - // TODO - } else { - int range = getScrollRange(); - mScroller.startScroll(mScrollX, mOwnScrollY, 0, range - mOwnScrollY); - } + int range = getScrollRange(); + mScroller.startScroll(mScrollX, mOwnScrollY, 0, range - mOwnScrollY); mDontReportNextOverScroll = true; mDontClampNextScroll = true; animateScroll(); @@ -1701,39 +1626,20 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } // Top overScroll might not grab all scrolling motion, // we have to scroll as well. - if (ANCHOR_SCROLLING) { - float scrollAmount = newTopAmount < 0 ? -newTopAmount : 0.0f; - // TODO: once we're recycling this will need to check the adapter position of the child - ExpandableView lastRow = getLastRowNotGone(); - if (lastRow != null && !lastRow.isInShelf()) { - float distanceToMax = Math.max(0, getMaxPositiveScrollAmount()); - if (scrollAmount > distanceToMax) { - float currentBottomPixels = getCurrentOverScrolledPixels(false); - // We overScroll on the bottom - setOverScrolledPixels(currentBottomPixels + (scrollAmount - distanceToMax), - false /* onTop */, - false /* animate */); - mScrollAnchorViewY -= distanceToMax; - scrollAmount = 0f; - } + float scrollAmount = newTopAmount < 0 ? -newTopAmount : 0.0f; + float newScrollY = mOwnScrollY + scrollAmount; + if (newScrollY > range) { + if (!mExpandedInThisMotion) { + float currentBottomPixels = getCurrentOverScrolledPixels(false); + // We overScroll on the bottom + setOverScrolledPixels(currentBottomPixels + newScrollY - range, + false /* onTop */, + false /* animate */); } - return scrollAmount; - } else { - float scrollAmount = newTopAmount < 0 ? -newTopAmount : 0.0f; - float newScrollY = mOwnScrollY + scrollAmount; - if (newScrollY > range) { - if (!mExpandedInThisMotion) { - float currentBottomPixels = getCurrentOverScrolledPixels(false); - // We overScroll on the bottom - setOverScrolledPixels(currentBottomPixels + newScrollY - range, - false /* onTop */, - false /* animate */); - } - setOwnScrollY(range); - scrollAmount = 0.0f; - } - return scrollAmount; + setOwnScrollY(range); + scrollAmount = 0.0f; } + return scrollAmount; } /** @@ -1754,37 +1660,18 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } // Bottom overScroll might not grab all scrolling motion, // we have to scroll as well. - if (ANCHOR_SCROLLING) { - float scrollAmount = newBottomAmount < 0 ? newBottomAmount : 0.0f; - // TODO: once we're recycling this will need to check the adapter position of the child - ExpandableView firstChild = getFirstChildNotGone(); - float top = firstChild.getTranslationY(); - float distanceToTop = mScrollAnchorView.getTranslationY() - top - mScrollAnchorViewY; - if (distanceToTop < -scrollAmount) { - float currentTopPixels = getCurrentOverScrolledPixels(true); - // We overScroll on the top - setOverScrolledPixels(currentTopPixels + (-scrollAmount - distanceToTop), - true /* onTop */, - false /* animate */); - mScrollAnchorView = firstChild; - mScrollAnchorViewY = 0; - scrollAmount = 0f; - } - return scrollAmount; - } else { - float scrollAmount = newBottomAmount < 0 ? newBottomAmount : 0.0f; - float newScrollY = mOwnScrollY + scrollAmount; - if (newScrollY < 0) { - float currentTopPixels = getCurrentOverScrolledPixels(true); - // We overScroll on the top - setOverScrolledPixels(currentTopPixels - newScrollY, - true /* onTop */, - false /* animate */); - setOwnScrollY(0); - scrollAmount = 0.0f; - } - return scrollAmount; + float scrollAmount = newBottomAmount < 0 ? newBottomAmount : 0.0f; + float newScrollY = mOwnScrollY + scrollAmount; + if (newScrollY < 0) { + float currentTopPixels = getCurrentOverScrolledPixels(true); + // We overScroll on the top + setOverScrolledPixels(currentTopPixels - newScrollY, + true /* onTop */, + false /* animate */); + setOwnScrollY(0); + scrollAmount = 0.0f; } + return scrollAmount; } @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) @@ -1819,42 +1706,23 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) private void animateScroll() { if (mScroller.computeScrollOffset()) { - if (ANCHOR_SCROLLING) { - int oldY = mLastScrollerY; - int y = mScroller.getCurrY(); - int deltaY = y - oldY; - if (deltaY != 0) { - int maxNegativeScrollAmount = getMaxNegativeScrollAmount(); - int maxPositiveScrollAmount = getMaxPositiveScrollAmount(); - if ((maxNegativeScrollAmount < 0 && deltaY < maxNegativeScrollAmount) - || (maxPositiveScrollAmount > 0 && deltaY > maxPositiveScrollAmount)) { - // This frame takes us into overscroll, so set the max overscroll based on - // the current velocity - setMaxOverScrollFromCurrentVelocity(); - } - customOverScrollBy(deltaY, oldY, 0, (int) mMaxOverScroll); - mLastScrollerY = y; - } - } else { - int oldY = mOwnScrollY; - int y = mScroller.getCurrY(); + int oldY = mOwnScrollY; + int y = mScroller.getCurrY(); - if (oldY != y) { - int range = getScrollRange(); - if (y < 0 && oldY >= 0 || y > range && oldY <= range) { - // This frame takes us into overscroll, so set the max overscroll based on - // the current velocity - setMaxOverScrollFromCurrentVelocity(); - } - - if (mDontClampNextScroll) { - range = Math.max(range, oldY); - } - customOverScrollBy(y - oldY, oldY, range, - (int) (mMaxOverScroll)); + if (oldY != y) { + int range = getScrollRange(); + if (y < 0 && oldY >= 0 || y > range && oldY <= range) { + // This frame takes us into overscroll, so set the max overscroll based on + // the current velocity + setMaxOverScrollFromCurrentVelocity(); } + + if (mDontClampNextScroll) { + range = Math.max(range, oldY); + } + customOverScrollBy(y - oldY, oldY, range, + (int) (mMaxOverScroll)); } - postOnAnimation(mReflingAndAnimateScroll); } else { mDontClampNextScroll = false; @@ -1877,9 +1745,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable * * This method performs the determination of whether we're exceeding the overscroll and clamps * the scroll amount if so. The actual scrolling/overscrolling happens in - * {@link #onCustomOverScrolled(int, boolean)} (absolute scrolling) or - * {@link #onCustomOverScrolledBy(int, boolean)} (anchor scrolling). - * + * {@link #onCustomOverScrolled(int, boolean)} * @param deltaY The (signed) number of pixels to scroll. * @param scrollY The current scroll position (absolute scrolling only). * @param scrollRangeY The maximum allowable scroll position (absolute scrolling only). @@ -1887,44 +1753,20 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable */ @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) private void customOverScrollBy(int deltaY, int scrollY, int scrollRangeY, int maxOverScrollY) { - if (ANCHOR_SCROLLING) { - boolean clampedY = false; - if (deltaY < 0) { - int maxScrollAmount = getMaxNegativeScrollAmount(); - if (maxScrollAmount > Integer.MIN_VALUE) { - maxScrollAmount -= maxOverScrollY; - if (deltaY < maxScrollAmount) { - deltaY = maxScrollAmount; - clampedY = true; - } - } - } else { - int maxScrollAmount = getMaxPositiveScrollAmount(); - if (maxScrollAmount < Integer.MAX_VALUE) { - maxScrollAmount += maxOverScrollY; - if (deltaY > maxScrollAmount) { - deltaY = maxScrollAmount; - clampedY = true; - } - } - } - onCustomOverScrolledBy(deltaY, clampedY); - } else { - int newScrollY = scrollY + deltaY; - final int top = -maxOverScrollY; - final int bottom = maxOverScrollY + scrollRangeY; + int newScrollY = scrollY + deltaY; + final int top = -maxOverScrollY; + final int bottom = maxOverScrollY + scrollRangeY; - boolean clampedY = false; - if (newScrollY > bottom) { - newScrollY = bottom; - clampedY = true; - } else if (newScrollY < top) { - newScrollY = top; - clampedY = true; - } - - onCustomOverScrolled(newScrollY, clampedY); + boolean clampedY = false; + if (newScrollY > bottom) { + newScrollY = bottom; + clampedY = true; + } else if (newScrollY < top) { + newScrollY = top; + clampedY = true; } + + onCustomOverScrolled(newScrollY, clampedY); } /** @@ -2042,35 +1884,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } } - /** - * Scrolls by the given delta, overscrolling if needed. If called during a fling and the delta - * would cause us to exceed the provided maximum overscroll, springs back instead. - * - * @param deltaY The (signed) number of pixels to scroll. - * @param clampedY Whether this value was clamped by the calling method, meaning we've reached - * the overscroll limit. - */ - private void onCustomOverScrolledBy(int deltaY, boolean clampedY) { - assert ANCHOR_SCROLLING; - mScrollAnchorViewY -= deltaY; - // Treat animating scrolls differently; see #computeScroll() for why. - if (!mScroller.isFinished()) { - if (clampedY) { - springBack(); - } else { - float overScrollTop = getCurrentOverScrollAmount(true /* top */); - if (mScrollAdapter.isScrolledToTop() && mScrollAnchorViewY > 0) { - notifyOverscrollTopListener(mScrollAnchorViewY, - isRubberbanded(true /* onTop */)); - } else { - notifyOverscrollTopListener(overScrollTop, isRubberbanded(true /* onTop */)); - } - } - } - updateScrollAnchor(); - updateOnScrollChange(); - } - /** * Scrolls to the given position, overscrolling if needed. If called during a fling and the * position exceeds the provided maximum overscroll, springs back instead. @@ -2081,7 +1894,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable */ @ShadeViewRefactor(RefactorComponent.COORDINATOR) private void onCustomOverScrolled(int scrollY, boolean clampedY) { - assert !ANCHOR_SCROLLING; // Treat animating scrolls differently; see #computeScroll() for why. if (!mScroller.isFinished()) { setOwnScrollY(scrollY); @@ -2106,45 +1918,25 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable */ @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) private void springBack() { - if (ANCHOR_SCROLLING) { - boolean overScrolledTop = mScrollAdapter.isScrolledToTop() && mScrollAnchorViewY > 0; - int maxPositiveScrollAmount = getMaxPositiveScrollAmount(); - boolean overscrolledBottom = maxPositiveScrollAmount < 0; - if (overScrolledTop || overscrolledBottom) { - float newAmount; - if (overScrolledTop) { - newAmount = mScrollAnchorViewY; - mScrollAnchorViewY = 0; - mDontReportNextOverScroll = true; - } else { - newAmount = -maxPositiveScrollAmount; - mScrollAnchorViewY -= maxPositiveScrollAmount; - } - setOverScrollAmount(newAmount, overScrolledTop, false); - setOverScrollAmount(0.0f, overScrolledTop, true); - mScroller.forceFinished(true); - } - } else { - int scrollRange = getScrollRange(); - boolean overScrolledTop = mOwnScrollY <= 0; - boolean overScrolledBottom = mOwnScrollY >= scrollRange; - if (overScrolledTop || overScrolledBottom) { - boolean onTop; - float newAmount; - if (overScrolledTop) { - onTop = true; - newAmount = -mOwnScrollY; - setOwnScrollY(0); - mDontReportNextOverScroll = true; - } else { - onTop = false; - newAmount = mOwnScrollY - scrollRange; - setOwnScrollY(scrollRange); - } - setOverScrollAmount(newAmount, onTop, false); - setOverScrollAmount(0.0f, onTop, true); - mScroller.forceFinished(true); + int scrollRange = getScrollRange(); + boolean overScrolledTop = mOwnScrollY <= 0; + boolean overScrolledBottom = mOwnScrollY >= scrollRange; + if (overScrolledTop || overScrolledBottom) { + boolean onTop; + float newAmount; + if (overScrolledTop) { + onTop = true; + newAmount = -mOwnScrollY; + setOwnScrollY(0); + mDontReportNextOverScroll = true; + } else { + onTop = false; + newAmount = mOwnScrollY - scrollRange; + setOwnScrollY(scrollRange); } + setOverScrollAmount(newAmount, onTop, false); + setOverScrollAmount(0.0f, onTop, true); + mScroller.forceFinished(true); } } @@ -2334,8 +2126,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable ExpandableView current, int visibleIndex ) { - return mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager, - mAmbientState.getAnchorViewIndex(), visibleIndex, current, + return mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager, visibleIndex, current, previous); } @@ -2566,21 +2357,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable float topAmount = getCurrentOverScrollAmount(true); float bottomAmount = getCurrentOverScrollAmount(false); if (velocityY < 0 && topAmount > 0) { - if (ANCHOR_SCROLLING) { - mScrollAnchorViewY += topAmount; - } else { - setOwnScrollY(mOwnScrollY - (int) topAmount); - } + setOwnScrollY(mOwnScrollY - (int) topAmount); mDontReportNextOverScroll = true; setOverScrollAmount(0, true, false); mMaxOverScroll = Math.abs(velocityY) / 1000f * getRubberBandFactor(true /* onTop */) * mOverflingDistance + topAmount; } else if (velocityY > 0 && bottomAmount > 0) { - if (ANCHOR_SCROLLING) { - mScrollAnchorViewY -= bottomAmount; - } else { - setOwnScrollY((int) (mOwnScrollY + bottomAmount)); - } + setOwnScrollY((int) (mOwnScrollY + bottomAmount)); setOverScrollAmount(0, false, false); mMaxOverScroll = Math.abs(velocityY) / 1000f * getRubberBandFactor(false /* onTop */) * mOverflingDistance @@ -2589,138 +2372,18 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable // it will be set once we reach the boundary mMaxOverScroll = 0.0f; } - if (ANCHOR_SCROLLING) { - flingScroller(velocityY); - } else { - int scrollRange = getScrollRange(); - int minScrollY = Math.max(0, scrollRange); - if (mExpandedInThisMotion) { - minScrollY = Math.min(minScrollY, mMaxScrollAfterExpand); - } - mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, - mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); + int scrollRange = getScrollRange(); + int minScrollY = Math.max(0, scrollRange); + if (mExpandedInThisMotion) { + minScrollY = Math.min(minScrollY, mMaxScrollAfterExpand); } + mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, + mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); animateScroll(); } } - /** - * Flings the overscroller with the given velocity (anchor-based scrolling). - * - * Because anchor-based scrolling can't track the current scroll position, the overscroller is - * always started at startY = 0, and we interpret the positions it computes as relative to the - * start of the scroll. - */ - private void flingScroller(int velocityY) { - assert ANCHOR_SCROLLING; - mIsScrollerBoundSet = false; - maybeFlingScroller(velocityY, true /* always fling */); - } - - private void maybeFlingScroller(int velocityY, boolean alwaysFling) { - assert ANCHOR_SCROLLING; - // Attempt to determine the maximum amount to scroll before we reach the end. - // If the first view is not materialized (for an upwards scroll) or the last view is either - // not materialized or is pinned to the shade (for a downwards scroll), we don't know this - // amount, so we do an unbounded fling and rely on {@link #maybeReflingScroller()} to update - // the scroller once we approach the start/end of the list. - int minY = Integer.MIN_VALUE; - int maxY = Integer.MAX_VALUE; - if (velocityY < 0) { - minY = getMaxNegativeScrollAmount(); - if (minY > Integer.MIN_VALUE) { - mIsScrollerBoundSet = true; - } - } else { - maxY = getMaxPositiveScrollAmount(); - if (maxY < Integer.MAX_VALUE) { - mIsScrollerBoundSet = true; - } - } - if (mIsScrollerBoundSet || alwaysFling) { - mLastScrollerY = 0; - // x velocity is set to 1 to avoid overscroller bug - mScroller.fling(0, 0, 1, velocityY, 0, 0, minY, maxY, 0, - mExpandedInThisMotion - && !mScrollAdapter.isScrolledToTop() ? 0 : Integer.MAX_VALUE / 2); - } - } - - /** - * Returns the maximum number of pixels we can scroll in the positive direction (downwards) - * before reaching the bottom of the list (discounting overscroll). - * - * If the return value is negative then we have overscrolled; this is a transient state which - * should immediately be handled by adjusting the anchor position and adding the extra space to - * the bottom overscroll amount. - * - * If we don't know how many pixels we have left to scroll (because the last row has not been - * materialized, or it's in the shelf so it doesn't have its "natural" position), we return - * {@link Integer#MAX_VALUE}. - */ - private int getMaxPositiveScrollAmount() { - assert ANCHOR_SCROLLING; - // TODO: once we're recycling we need to check the adapter position of the last child. - ExpandableNotificationRow lastRow = getLastRowNotGone(); - if (mScrollAnchorView != null && lastRow != null && !lastRow.isInShelf()) { - // distance from bottom of last child to bottom of notifications area is: - // distance from bottom of last child - return (int) (lastRow.getTranslationY() + lastRow.getActualHeight() - // to top of anchor view - - mScrollAnchorView.getTranslationY() - // plus distance from anchor view to top of notifications area - + mScrollAnchorViewY - // minus height of notifications area. - - (mMaxLayoutHeight - getIntrinsicPadding() - mFooterView.getActualHeight())); - } else { - return Integer.MAX_VALUE; - } - } - - /** - * Returns the maximum number of pixels (as a negative number) we can scroll in the negative - * direction (upwards) before reaching the top of the list (discounting overscroll). - * - * If the return value is positive then we have overscrolled; this is a transient state which - * should immediately be handled by adjusting the anchor position and adding the extra space to - * the top overscroll amount. - * - * If we don't know how many pixels we have left to scroll (because the first row has not been - * materialized), we return {@link Integer#MIN_VALUE}. - */ - private int getMaxNegativeScrollAmount() { - assert ANCHOR_SCROLLING; - // TODO: once we're recycling we need to check the adapter position of the first child. - ExpandableView firstChild = getFirstChildNotGone(); - if (mScrollAnchorView != null && firstChild != null) { - // distance from top of first child to top of notifications area is: - // distance from top of anchor view - return (int) -(mScrollAnchorView.getTranslationY() - // to top of first child - - firstChild.getTranslationY() - // minus distance from top of anchor view to top of notifications area. - - mScrollAnchorViewY); - } else { - return Integer.MIN_VALUE; - } - } - - /** - * During a fling, if we were unable to set the bounds of the fling due to the top/bottom view - * not being materialized or being pinned to the shelf, we need to check on every frame if we're - * able to set the bounds. If we are, we fling the scroller again with the newly computed - * bounds. - */ - private void maybeReflingScroller() { - if (!mIsScrollerBoundSet) { - // Because mScroller is a flywheel scroller, we fling with the minimum possible - // velocity to establish direction, so as not to perceptibly affect the velocity. - maybeFlingScroller((int) Math.signum(mScroller.getCurrVelocity()), - false /* alwaysFling */); - } - } - /** * @return Whether a fling performed on the top overscroll edge lead to the expanded * overScroll view (i.e QS). @@ -2990,38 +2653,17 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable */ @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) private void updateScrollStateForRemovedChild(ExpandableView removedChild) { - if (ANCHOR_SCROLLING) { - if (removedChild == mScrollAnchorView) { - ExpandableView firstChild = getFirstChildNotGone(); - if (firstChild != null) { - mScrollAnchorView = firstChild; - } else { - mScrollAnchorView = mShelf; - } - // Adjust anchor view Y by the distance between the old and new anchors - // so that there's no visible change. - mScrollAnchorViewY += - mScrollAnchorView.getTranslationY() - removedChild.getTranslationY(); - } - updateScrollAnchor(); - // TODO: once we're recycling this will need to check the adapter position of the child - if (mScrollAnchorView == getFirstChildNotGone() && mScrollAnchorViewY > 0) { - mScrollAnchorViewY = 0; - } - updateOnScrollChange(); - } else { - final int startingPosition = getPositionInLinearLayout(removedChild); - final int childHeight = getIntrinsicHeight(removedChild) + mPaddingBetweenElements; - final int endPosition = startingPosition + childHeight; - if (endPosition <= mOwnScrollY) { - // This child is fully scrolled of the top, so we have to deduct its height from the - // scrollPosition - setOwnScrollY(mOwnScrollY - childHeight); - } else if (startingPosition < mOwnScrollY) { - // This child is currently being scrolled into, set the scroll position to the - // start of this child - setOwnScrollY(startingPosition); - } + final int startingPosition = getPositionInLinearLayout(removedChild); + final int childHeight = getIntrinsicHeight(removedChild) + mPaddingBetweenElements; + final int endPosition = startingPosition + childHeight; + if (endPosition <= mOwnScrollY) { + // This child is fully scrolled of the top, so we have to deduct its height from the + // scrollPosition + setOwnScrollY(mOwnScrollY - childHeight); + } else if (startingPosition < mOwnScrollY) { + // This child is currently being scrolled into, set the scroll position to the + // start of this child + setOwnScrollY(startingPosition); } } @@ -3115,15 +2757,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable if (child instanceof ExpandableNotificationRow) { ((ExpandableNotificationRow) child).setDismissRtl(mDismissRtl); } - if (ANCHOR_SCROLLING) { - // TODO: once we're recycling this will need to check the adapter position of the child - if (child == getFirstChildNotGone() - && (mScrollAdapter.isScrolledToTop() || !mIsExpanded)) { - // New child was added at the top while we're scrolled to the top; - // make it the new anchor view so that we stay at the top. - mScrollAnchorView = child; - } - } } @ShadeViewRefactor(RefactorComponent.COORDINATOR) @@ -3581,24 +3214,17 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll != 0) { final int delta = (int) (vscroll * getVerticalScrollFactor()); - if (ANCHOR_SCROLLING) { - mScrollAnchorViewY -= delta; - updateScrollAnchor(); - clampScrollPosition(); - updateOnScrollChange(); - } else { - final int range = getScrollRange(); - int oldScrollY = mOwnScrollY; - int newScrollY = oldScrollY - delta; - if (newScrollY < 0) { - newScrollY = 0; - } else if (newScrollY > range) { - newScrollY = range; - } - if (newScrollY != oldScrollY) { - setOwnScrollY(newScrollY); - return true; - } + final int range = getScrollRange(); + int oldScrollY = mOwnScrollY; + int newScrollY = oldScrollY - delta; + if (newScrollY < 0) { + newScrollY = 0; + } else if (newScrollY > range) { + newScrollY = range; + } + if (newScrollY != oldScrollY) { + setOwnScrollY(newScrollY); + return true; } } } @@ -3676,13 +3302,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mLastMotionY = y; float scrollAmount; int range; - if (ANCHOR_SCROLLING) { - range = 0; // unused in the methods it's being passed to - } else { - range = getScrollRange(); - if (mExpandedInThisMotion) { - range = Math.min(range, mMaxScrollAfterExpand); - } + range = getScrollRange(); + if (mExpandedInThisMotion) { + range = Math.min(range, mMaxScrollAfterExpand); } if (deltaY < 0) { scrollAmount = overScrollDown(deltaY); @@ -3727,13 +3349,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable onOverScrollFling(false, initialVelocity); } } else { - if (ANCHOR_SCROLLING) { - // TODO - } else { - if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, - getScrollRange())) { - animateScroll(); - } + if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, + getScrollRange())) { + animateScroll(); } } } @@ -3745,13 +3363,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable break; case MotionEvent.ACTION_CANCEL: if (mIsBeingDragged && getChildCount() > 0) { - if (ANCHOR_SCROLLING) { - // TODO - } else { - if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, - getScrollRange())) { - animateScroll(); - } + if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, + getScrollRange())) { + animateScroll(); } mActivePointerId = INVALID_POINTER; endDrag(); @@ -3970,12 +3584,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable setIsBeingDragged(false); mActivePointerId = INVALID_POINTER; recycleVelocityTracker(); - if (ANCHOR_SCROLLING) { - // TODO - } else { - if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { - animateScroll(); - } + if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { + animateScroll(); } break; case MotionEvent.ACTION_POINTER_UP: @@ -4050,20 +3660,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: // fall through case android.R.id.accessibilityActionScrollUp: - if (ANCHOR_SCROLLING) { - // TODO - } else { - final int viewportHeight = - getHeight() - mPaddingBottom - mTopPadding - mPaddingTop - - mShelf.getIntrinsicHeight(); - final int targetScrollY = Math.max(0, - Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange())); - if (targetScrollY != mOwnScrollY) { - mScroller.startScroll(mScrollX, mOwnScrollY, 0, - targetScrollY - mOwnScrollY); - animateScroll(); - return true; - } + final int viewportHeight = + getHeight() - mPaddingBottom - mTopPadding - mPaddingTop + - mShelf.getIntrinsicHeight(); + final int targetScrollY = Math.max(0, + Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange())); + if (targetScrollY != mOwnScrollY) { + mScroller.startScroll(mScrollX, mOwnScrollY, 0, + targetScrollY - mOwnScrollY); + animateScroll(); + return true; } break; } @@ -4166,14 +3772,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) void resetScrollPosition() { mScroller.abortAnimation(); - if (ANCHOR_SCROLLING) { - // TODO: once we're recycling this will need to modify the adapter position instead - mScrollAnchorView = getFirstChildNotGone(); - mScrollAnchorViewY = 0; - updateOnScrollChange(); - } else { - setOwnScrollY(0); - } + setOwnScrollY(0); } @ShadeViewRefactor(RefactorComponent.COORDINATOR) @@ -4262,13 +3861,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable layoutEnd -= mShelf.getIntrinsicHeight() + mPaddingBetweenElements; } if (endPosition > layoutEnd) { - if (ANCHOR_SCROLLING) { - mScrollAnchorViewY -= (endPosition - layoutEnd); - updateScrollAnchor(); - updateOnScrollChange(); - } else { - setOwnScrollY((int) (mOwnScrollY + endPosition - layoutEnd)); - } + setOwnScrollY((int) (mOwnScrollY + endPosition - layoutEnd)); mDisallowScrollingInThisMotion = true; } } @@ -4765,12 +4358,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable super.onInitializeAccessibilityEventInternal(event); event.setScrollable(mScrollable); event.setMaxScrollX(mScrollX); - if (ANCHOR_SCROLLING) { - // TODO - } else { - event.setScrollY(mOwnScrollY); - event.setMaxScrollY(getScrollRange()); - } + event.setScrollY(mOwnScrollY); + event.setMaxScrollY(getScrollRange()); } @Override @@ -4955,7 +4544,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.COORDINATOR) private void setOwnScrollY(int ownScrollY) { - assert !ANCHOR_SCROLLING; if (ownScrollY != mOwnScrollY) { // We still want to call the normal scrolled changed for accessibility reasons onScrollChanged(mScrollX, ownScrollY, mScrollX, mOwnScrollY); @@ -4969,51 +4557,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable requestChildrenUpdate(); } - private void updateScrollAnchor() { - int anchorIndex = indexOfChild(mScrollAnchorView); - // If the anchor view has been scrolled off the top, move to the next view. - while (mScrollAnchorViewY < 0) { - View nextAnchor = null; - for (int i = anchorIndex + 1; i < getChildCount(); i++) { - View child = getChildAt(i); - if (child.getVisibility() != View.GONE - && child instanceof ExpandableNotificationRow) { - anchorIndex = i; - nextAnchor = child; - break; - } - } - if (nextAnchor == null) { - break; - } - mScrollAnchorViewY += - (int) (nextAnchor.getTranslationY() - mScrollAnchorView.getTranslationY()); - mScrollAnchorView = nextAnchor; - } - // If the view above the anchor view is fully visible, make it the anchor view. - while (anchorIndex > 0 && mScrollAnchorViewY > 0) { - View prevAnchor = null; - for (int i = anchorIndex - 1; i >= 0; i--) { - View child = getChildAt(i); - if (child.getVisibility() != View.GONE - && child instanceof ExpandableNotificationRow) { - anchorIndex = i; - prevAnchor = child; - break; - } - } - if (prevAnchor == null) { - break; - } - float distanceToPreviousAnchor = - mScrollAnchorView.getTranslationY() - prevAnchor.getTranslationY(); - if (distanceToPreviousAnchor < mScrollAnchorViewY) { - mScrollAnchorViewY -= (int) distanceToPreviousAnchor; - mScrollAnchorView = prevAnchor; - } - } - } - @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void setShelfController(NotificationShelfController notificationShelfController) { int index = -1; @@ -5026,9 +4569,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mAmbientState.setShelf(mShelf); mStateAnimator.setShelf(mShelf); notificationShelfController.bind(mAmbientState, mController); - if (ANCHOR_SCROLLING) { - mScrollAnchorView = mShelf; - } } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) @@ -6166,11 +5706,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable public void expansionStateChanged(boolean isExpanding) { mExpandingNotification = isExpanding; if (!mExpandedInThisMotion) { - if (ANCHOR_SCROLLING) { - // TODO - } else { - mMaxScrollAfterExpand = mOwnScrollY; - } + mMaxScrollAfterExpand = mOwnScrollY; mExpandedInThisMotion = true; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index d85baa9f1b93f..2c206b1c3f453 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -45,8 +45,6 @@ import java.util.List; */ public class StackScrollAlgorithm { - static final boolean ANCHOR_SCROLLING = false; - private static final String LOG_TAG = "StackScrollAlgorithm"; private final ViewGroup mHostView; @@ -229,10 +227,6 @@ public class StackScrollAlgorithm { scrollY = Math.max(0, scrollY); state.scrollY = (int) (scrollY + bottomOverScroll); - if (ANCHOR_SCROLLING) { - state.anchorViewY = (int) (ambientState.getAnchorViewY() - bottomOverScroll); - } - //now init the visible children and update paddings int childCount = hostView.getChildCount(); state.visibleChildren.clear(); @@ -240,11 +234,6 @@ public class StackScrollAlgorithm { int notGoneIndex = 0; ExpandableView lastView = null; for (int i = 0; i < childCount; i++) { - if (ANCHOR_SCROLLING) { - if (i == ambientState.getAnchorViewIndex()) { - state.anchorViewIndex = state.visibleChildren.size(); - } - } ExpandableView v = (ExpandableView) hostView.getChildAt(i); if (v.getVisibility() != View.GONE) { if (v == ambientState.getShelf()) { @@ -293,26 +282,12 @@ public class StackScrollAlgorithm { */ private void updatePositionsForState(StackScrollAlgorithmState algorithmState, AmbientState ambientState) { - if (ANCHOR_SCROLLING) { - float currentYPosition = algorithmState.anchorViewY; - int childCount = algorithmState.visibleChildren.size(); - for (int i = algorithmState.anchorViewIndex; i < childCount; i++) { - currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition, - false /* reverse */); - } - currentYPosition = algorithmState.anchorViewY; - for (int i = algorithmState.anchorViewIndex - 1; i >= 0; i--) { - currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition, - true /* reverse */); - } - } else { - // The y coordinate of the current child. - float currentYPosition = -algorithmState.scrollY; - int childCount = algorithmState.visibleChildren.size(); - for (int i = 0; i < childCount; i++) { - currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition, - false /* reverse */); - } + // The y coordinate of the current child. + float currentYPosition = -algorithmState.scrollY; + int childCount = algorithmState.visibleChildren.size(); + for (int i = 0; i < childCount; i++) { + currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition, + false /* reverse */); } } @@ -343,7 +318,7 @@ public class StackScrollAlgorithm { ExpandableView previousChild = i > 0 ? algorithmState.visibleChildren.get(i - 1) : null; final boolean applyGapHeight = childNeedsGapHeight( - ambientState.getSectionProvider(), algorithmState.anchorViewIndex, i, + ambientState.getSectionProvider(), i, child, previousChild); ExpandableViewState childViewState = child.getViewState(); childViewState.location = ExpandableViewState.LOCATION_UNKNOWN; @@ -409,7 +384,6 @@ public class StackScrollAlgorithm { * Get the gap height needed for before a view * * @param sectionProvider the sectionProvider used to understand the sections - * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not * @param visibleIndex the visible index of this view in the list * @param child the child asked about * @param previousChild the child right before it or null if none @@ -417,12 +391,11 @@ public class StackScrollAlgorithm { */ public float getGapHeightForChild( SectionProvider sectionProvider, - int anchorViewIndex, int visibleIndex, View child, View previousChild) { - if (childNeedsGapHeight(sectionProvider, anchorViewIndex, visibleIndex, child, + if (childNeedsGapHeight(sectionProvider, visibleIndex, child, previousChild)) { return mGapHeight; } else { @@ -434,7 +407,6 @@ public class StackScrollAlgorithm { * Does a given child need a gap, i.e spacing before a view? * * @param sectionProvider the sectionProvider used to understand the sections - * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not * @param visibleIndex the visible index of this view in the list * @param child the child asked about * @param previousChild the child right before it or null if none @@ -442,16 +414,12 @@ public class StackScrollAlgorithm { */ private boolean childNeedsGapHeight( SectionProvider sectionProvider, - int anchorViewIndex, int visibleIndex, View child, View previousChild) { boolean needsGapHeight = sectionProvider.beginsSection(child, previousChild) && visibleIndex > 0; - if (ANCHOR_SCROLLING) { - needsGapHeight &= visibleIndex != anchorViewIndex; - } return needsGapHeight; } @@ -537,7 +505,6 @@ public class StackScrollAlgorithm { // To check if the row need to do translation according to scroll Y // heads up show full of row's content and any scroll y indicate that the // translationY need to move up the HUN. - // TODO: fix this check for anchor scrolling. if (!mIsExpanded && isTopEntry && ambientState.getScrollY() > 0) { childState.yTranslation -= ambientState.getScrollY(); } @@ -701,14 +668,6 @@ public class StackScrollAlgorithm { */ public int scrollY; - /** The index of the anchor view (anchor scrolling). */ - public int anchorViewIndex; - - /** - * The Y position, relative to the top of the screen, of the anchor view (anchor scrolling). - */ - public int anchorViewY; - /** * The children from the host view which are not gone. */