Loading core/java/android/widget/AbsListView.java +143 −131 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import android.view.inspector.InspectableProperty.EnumEntry; import android.widget.RemoteViews.InteractionHandler; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.List; Loading Loading @@ -712,20 +713,24 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * * Even though this field is practically final, we cannot make it final because there are apps * setting it via reflection and they need to keep working until they target Q. * @hide */ @NonNull @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769408) private EdgeEffect mEdgeGlowTop; @VisibleForTesting public EdgeEffect mEdgeGlowTop; /** * Tracks the state of the bottom edge glow. * * Even though this field is practically final, we cannot make it final because there are apps * setting it via reflection and they need to keep working until they target Q. * @hide */ @NonNull @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768444) private EdgeEffect mEdgeGlowBottom; @VisibleForTesting public EdgeEffect mEdgeGlowBottom; /** * An estimate of how many pixels are between the top of the list and Loading Loading @@ -4116,7 +4121,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } final float x = ev.getX(); final boolean inList = x > mListPadding.left && x < getWidth() - mListPadding.right; final boolean inList = x > mListPadding.left && x < getWidth() - mListPadding.right; if (inList && !child.hasExplicitFocusable()) { if (mPerformClick == null) { mPerformClick = new PerformClick(); Loading @@ -4129,8 +4135,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mResurrectToPosition = motionPosition; if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP) { removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress); removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress); mLayoutMode = LAYOUT_NORMAL; if (!mDataChanged && mAdapter.isEnabled(motionPosition)) { mTouchMode = TOUCH_MODE_TAP; Loading @@ -4156,7 +4162,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mTouchMode = TOUCH_MODE_REST; child.setPressed(false); setPressed(false); if (!mDataChanged && !mIsDetaching && isAttachedToWindow()) { if (!mDataChanged && !mIsDetaching && isAttachedToWindow()) { performClick.run(); } } Loading @@ -4183,9 +4190,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te final int lastChildBottom = getChildAt(childCount - 1).getBottom(); final int contentTop = mListPadding.top; final int contentBottom = getHeight() - mListPadding.bottom; if (mFirstPosition == 0 && firstChildTop >= contentTop && mFirstPosition + childCount < mItemCount && lastChildBottom <= getHeight() - contentBottom) { if (mFirstPosition == 0 && firstChildTop >= contentTop && mFirstPosition + childCount < mItemCount && lastChildBottom <= getHeight() - contentBottom) { mTouchMode = TOUCH_MODE_REST; reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE); } else { Loading @@ -4199,11 +4206,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te // allow the weird behavior where you can scroll to a boundary then // fling further. boolean flingVelocity = Math.abs(initialVelocity) > mMinimumVelocity; if (flingVelocity && !((mFirstPosition == 0 && firstChildTop == contentTop - mOverscrollDistance) || (mFirstPosition + childCount == mItemCount && lastChildBottom == contentBottom + mOverscrollDistance))) { if (flingVelocity && !mEdgeGlowTop.isFinished()) { mEdgeGlowTop.onAbsorb(initialVelocity); } else if (flingVelocity && !mEdgeGlowBottom.isFinished()) { mEdgeGlowBottom.onAbsorb(-initialVelocity); } else if (flingVelocity && !((mFirstPosition == 0 && firstChildTop == contentTop - mOverscrollDistance) || (mFirstPosition + childCount == mItemCount && lastChildBottom == contentBottom + mOverscrollDistance)) ) { if (!dispatchNestedPreFling(0, -initialVelocity)) { if (mFlingRunnable == null) { mFlingRunnable = new FlingRunnable(); Loading Loading
core/java/android/widget/AbsListView.java +143 −131 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import android.view.inspector.InspectableProperty.EnumEntry; import android.widget.RemoteViews.InteractionHandler; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.List; Loading Loading @@ -712,20 +713,24 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * * Even though this field is practically final, we cannot make it final because there are apps * setting it via reflection and they need to keep working until they target Q. * @hide */ @NonNull @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769408) private EdgeEffect mEdgeGlowTop; @VisibleForTesting public EdgeEffect mEdgeGlowTop; /** * Tracks the state of the bottom edge glow. * * Even though this field is practically final, we cannot make it final because there are apps * setting it via reflection and they need to keep working until they target Q. * @hide */ @NonNull @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768444) private EdgeEffect mEdgeGlowBottom; @VisibleForTesting public EdgeEffect mEdgeGlowBottom; /** * An estimate of how many pixels are between the top of the list and Loading Loading @@ -4116,7 +4121,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } final float x = ev.getX(); final boolean inList = x > mListPadding.left && x < getWidth() - mListPadding.right; final boolean inList = x > mListPadding.left && x < getWidth() - mListPadding.right; if (inList && !child.hasExplicitFocusable()) { if (mPerformClick == null) { mPerformClick = new PerformClick(); Loading @@ -4129,8 +4135,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mResurrectToPosition = motionPosition; if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP) { removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress); removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress); mLayoutMode = LAYOUT_NORMAL; if (!mDataChanged && mAdapter.isEnabled(motionPosition)) { mTouchMode = TOUCH_MODE_TAP; Loading @@ -4156,7 +4162,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mTouchMode = TOUCH_MODE_REST; child.setPressed(false); setPressed(false); if (!mDataChanged && !mIsDetaching && isAttachedToWindow()) { if (!mDataChanged && !mIsDetaching && isAttachedToWindow()) { performClick.run(); } } Loading @@ -4183,9 +4190,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te final int lastChildBottom = getChildAt(childCount - 1).getBottom(); final int contentTop = mListPadding.top; final int contentBottom = getHeight() - mListPadding.bottom; if (mFirstPosition == 0 && firstChildTop >= contentTop && mFirstPosition + childCount < mItemCount && lastChildBottom <= getHeight() - contentBottom) { if (mFirstPosition == 0 && firstChildTop >= contentTop && mFirstPosition + childCount < mItemCount && lastChildBottom <= getHeight() - contentBottom) { mTouchMode = TOUCH_MODE_REST; reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE); } else { Loading @@ -4199,11 +4206,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te // allow the weird behavior where you can scroll to a boundary then // fling further. boolean flingVelocity = Math.abs(initialVelocity) > mMinimumVelocity; if (flingVelocity && !((mFirstPosition == 0 && firstChildTop == contentTop - mOverscrollDistance) || (mFirstPosition + childCount == mItemCount && lastChildBottom == contentBottom + mOverscrollDistance))) { if (flingVelocity && !mEdgeGlowTop.isFinished()) { mEdgeGlowTop.onAbsorb(initialVelocity); } else if (flingVelocity && !mEdgeGlowBottom.isFinished()) { mEdgeGlowBottom.onAbsorb(-initialVelocity); } else if (flingVelocity && !((mFirstPosition == 0 && firstChildTop == contentTop - mOverscrollDistance) || (mFirstPosition + childCount == mItemCount && lastChildBottom == contentBottom + mOverscrollDistance)) ) { if (!dispatchNestedPreFling(0, -initialVelocity)) { if (mFlingRunnable == null) { mFlingRunnable = new FlingRunnable(); Loading