1474 lines
60 KiB
Java
1474 lines
60 KiB
Java
package androidx.core.widget;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
import android.os.Bundle;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.util.TypedValue;
|
|
import android.view.FocusFinder;
|
|
import android.view.KeyEvent;
|
|
import android.view.MotionEvent;
|
|
import android.view.VelocityTracker;
|
|
import android.view.View;
|
|
import android.view.ViewConfiguration;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewParent;
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
import android.view.animation.AnimationUtils;
|
|
import android.widget.EdgeEffect;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.OverScroller;
|
|
import android.widget.ScrollView;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.view.AccessibilityDelegateCompat;
|
|
import androidx.core.view.NestedScrollingChild3;
|
|
import androidx.core.view.NestedScrollingChildHelper;
|
|
import androidx.core.view.NestedScrollingParent3;
|
|
import androidx.core.view.NestedScrollingParentHelper;
|
|
import androidx.core.view.ScrollingView;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
|
import androidx.core.view.accessibility.AccessibilityRecordCompat;
|
|
import c.d.b.a.a;
|
|
import java.util.ArrayList;
|
|
public class NestedScrollView extends FrameLayout implements NestedScrollingParent3, NestedScrollingChild3, ScrollingView {
|
|
private static final AccessibilityDelegate ACCESSIBILITY_DELEGATE = new AccessibilityDelegate();
|
|
public static final int ANIMATED_SCROLL_GAP = 250;
|
|
private static final int DEFAULT_SMOOTH_SCROLL_DURATION = 250;
|
|
private static final int INVALID_POINTER = -1;
|
|
public static final float MAX_SCROLL_FACTOR = 0.5f;
|
|
private static final int[] SCROLLVIEW_STYLEABLE = {16843130};
|
|
private static final String TAG = "NestedScrollView";
|
|
private int mActivePointerId;
|
|
private final NestedScrollingChildHelper mChildHelper;
|
|
private View mChildToScrollTo;
|
|
private EdgeEffect mEdgeGlowBottom;
|
|
private EdgeEffect mEdgeGlowTop;
|
|
private boolean mFillViewport;
|
|
private boolean mIsBeingDragged;
|
|
private boolean mIsLaidOut;
|
|
private boolean mIsLayoutDirty;
|
|
private int mLastMotionY;
|
|
private long mLastScroll;
|
|
private int mLastScrollerY;
|
|
private int mMaximumVelocity;
|
|
private int mMinimumVelocity;
|
|
private int mNestedYOffset;
|
|
private OnScrollChangeListener mOnScrollChangeListener;
|
|
private final NestedScrollingParentHelper mParentHelper;
|
|
private SavedState mSavedState;
|
|
private final int[] mScrollConsumed;
|
|
private final int[] mScrollOffset;
|
|
private OverScroller mScroller;
|
|
private boolean mSmoothScrollingEnabled;
|
|
private final Rect mTempRect;
|
|
private int mTouchSlop;
|
|
private VelocityTracker mVelocityTracker;
|
|
private float mVerticalScrollFactor;
|
|
|
|
public static class AccessibilityDelegate extends AccessibilityDelegateCompat {
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
|
|
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
|
|
NestedScrollView nestedScrollView = (NestedScrollView) view;
|
|
accessibilityEvent.setClassName(ScrollView.class.getName());
|
|
accessibilityEvent.setScrollable(nestedScrollView.getScrollRange() > 0);
|
|
accessibilityEvent.setScrollX(nestedScrollView.getScrollX());
|
|
accessibilityEvent.setScrollY(nestedScrollView.getScrollY());
|
|
AccessibilityRecordCompat.setMaxScrollX(accessibilityEvent, nestedScrollView.getScrollX());
|
|
AccessibilityRecordCompat.setMaxScrollY(accessibilityEvent, nestedScrollView.getScrollRange());
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
|
int scrollRange;
|
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
|
NestedScrollView nestedScrollView = (NestedScrollView) view;
|
|
accessibilityNodeInfoCompat.setClassName(ScrollView.class.getName());
|
|
if (nestedScrollView.isEnabled() && (scrollRange = nestedScrollView.getScrollRange()) > 0) {
|
|
accessibilityNodeInfoCompat.setScrollable(true);
|
|
if (nestedScrollView.getScrollY() > 0) {
|
|
accessibilityNodeInfoCompat.addAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_BACKWARD);
|
|
accessibilityNodeInfoCompat.addAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_UP);
|
|
}
|
|
if (nestedScrollView.getScrollY() < scrollRange) {
|
|
accessibilityNodeInfoCompat.addAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_FORWARD);
|
|
accessibilityNodeInfoCompat.addAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_DOWN);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
|
|
if (super.performAccessibilityAction(view, i, bundle)) {
|
|
return true;
|
|
}
|
|
NestedScrollView nestedScrollView = (NestedScrollView) view;
|
|
if (!nestedScrollView.isEnabled()) {
|
|
return false;
|
|
}
|
|
if (i != 4096) {
|
|
if (i == 8192 || i == 16908344) {
|
|
int max = Math.max(nestedScrollView.getScrollY() - ((nestedScrollView.getHeight() - nestedScrollView.getPaddingBottom()) - nestedScrollView.getPaddingTop()), 0);
|
|
if (max == nestedScrollView.getScrollY()) {
|
|
return false;
|
|
}
|
|
nestedScrollView.smoothScrollTo(0, max, true);
|
|
return true;
|
|
} else if (i != 16908346) {
|
|
return false;
|
|
}
|
|
}
|
|
int min = Math.min(nestedScrollView.getScrollY() + ((nestedScrollView.getHeight() - nestedScrollView.getPaddingBottom()) - nestedScrollView.getPaddingTop()), nestedScrollView.getScrollRange());
|
|
if (min == nestedScrollView.getScrollY()) {
|
|
return false;
|
|
}
|
|
nestedScrollView.smoothScrollTo(0, min, true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public interface OnScrollChangeListener {
|
|
void onScrollChange(NestedScrollView nestedScrollView, int i, int i2, int i3, int i4);
|
|
}
|
|
|
|
public static class SavedState extends View.BaseSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new AnonymousClass1();
|
|
public int scrollPosition;
|
|
|
|
/* renamed from: androidx.core.widget.NestedScrollView$SavedState$1 reason: invalid class name */
|
|
public class AnonymousClass1 implements Parcelable.Creator<SavedState> {
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
}
|
|
|
|
public SavedState(Parcel parcel) {
|
|
super(parcel);
|
|
this.scrollPosition = parcel.readInt();
|
|
}
|
|
|
|
public SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
@NonNull
|
|
public String toString() {
|
|
StringBuilder L = a.L("HorizontalScrollView.SavedState{");
|
|
L.append(Integer.toHexString(System.identityHashCode(this)));
|
|
L.append(" scrollPosition=");
|
|
return a.z(L, this.scrollPosition, "}");
|
|
}
|
|
|
|
@Override // android.view.View.BaseSavedState, android.os.Parcelable, android.view.AbsSavedState
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
super.writeToParcel(parcel, i);
|
|
parcel.writeInt(this.scrollPosition);
|
|
}
|
|
}
|
|
|
|
public NestedScrollView(@NonNull Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.mTempRect = new Rect();
|
|
this.mIsLayoutDirty = true;
|
|
this.mIsLaidOut = false;
|
|
this.mChildToScrollTo = null;
|
|
this.mIsBeingDragged = false;
|
|
this.mSmoothScrollingEnabled = true;
|
|
this.mActivePointerId = -1;
|
|
this.mScrollOffset = new int[2];
|
|
this.mScrollConsumed = new int[2];
|
|
initScrollView();
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, SCROLLVIEW_STYLEABLE, i, 0);
|
|
setFillViewport(obtainStyledAttributes.getBoolean(0, false));
|
|
obtainStyledAttributes.recycle();
|
|
this.mParentHelper = new NestedScrollingParentHelper(this);
|
|
this.mChildHelper = new NestedScrollingChildHelper(this);
|
|
setNestedScrollingEnabled(true);
|
|
ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE);
|
|
}
|
|
|
|
private void abortAnimatedScroll() {
|
|
this.mScroller.abortAnimation();
|
|
stopNestedScroll(1);
|
|
}
|
|
|
|
private boolean canScroll() {
|
|
if (getChildCount() <= 0) {
|
|
return false;
|
|
}
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
return (childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin > (getHeight() - getPaddingTop()) - getPaddingBottom();
|
|
}
|
|
|
|
private static int clamp(int i, int i2, int i3) {
|
|
if (i2 >= i3 || i < 0) {
|
|
return 0;
|
|
}
|
|
return i2 + i > i3 ? i3 - i2 : i;
|
|
}
|
|
|
|
private void doScrollY(int i) {
|
|
if (i == 0) {
|
|
return;
|
|
}
|
|
if (this.mSmoothScrollingEnabled) {
|
|
smoothScrollBy(0, i);
|
|
} else {
|
|
scrollBy(0, i);
|
|
}
|
|
}
|
|
|
|
private void endDrag() {
|
|
this.mIsBeingDragged = false;
|
|
recycleVelocityTracker();
|
|
stopNestedScroll(0);
|
|
EdgeEffect edgeEffect = this.mEdgeGlowTop;
|
|
if (edgeEffect != null) {
|
|
edgeEffect.onRelease();
|
|
this.mEdgeGlowBottom.onRelease();
|
|
}
|
|
}
|
|
|
|
private void ensureGlows() {
|
|
if (getOverScrollMode() == 2) {
|
|
this.mEdgeGlowTop = null;
|
|
this.mEdgeGlowBottom = null;
|
|
} else if (this.mEdgeGlowTop == null) {
|
|
Context context = getContext();
|
|
this.mEdgeGlowTop = new EdgeEffect(context);
|
|
this.mEdgeGlowBottom = new EdgeEffect(context);
|
|
}
|
|
}
|
|
|
|
private View findFocusableViewInBounds(boolean z2, int i, int i2) {
|
|
ArrayList focusables = getFocusables(2);
|
|
int size = focusables.size();
|
|
View view = null;
|
|
boolean z3 = false;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
View view2 = (View) focusables.get(i3);
|
|
int top = view2.getTop();
|
|
int bottom = view2.getBottom();
|
|
if (i < bottom && top < i2) {
|
|
boolean z4 = i < top && bottom < i2;
|
|
if (view == null) {
|
|
view = view2;
|
|
z3 = z4;
|
|
} else {
|
|
boolean z5 = (z2 && top < view.getTop()) || (!z2 && bottom > view.getBottom());
|
|
if (z3) {
|
|
if (z4) {
|
|
if (!z5) {
|
|
}
|
|
}
|
|
} else if (z4) {
|
|
view = view2;
|
|
z3 = true;
|
|
} else if (!z5) {
|
|
}
|
|
view = view2;
|
|
}
|
|
}
|
|
}
|
|
return view;
|
|
}
|
|
|
|
private float getVerticalScrollFactorCompat() {
|
|
if (this.mVerticalScrollFactor == 0.0f) {
|
|
TypedValue typedValue = new TypedValue();
|
|
Context context = getContext();
|
|
if (context.getTheme().resolveAttribute(16842829, typedValue, true)) {
|
|
this.mVerticalScrollFactor = typedValue.getDimension(context.getResources().getDisplayMetrics());
|
|
} else {
|
|
throw new IllegalStateException("Expected theme to define listPreferredItemHeight.");
|
|
}
|
|
}
|
|
return this.mVerticalScrollFactor;
|
|
}
|
|
|
|
private boolean inChild(int i, int i2) {
|
|
if (getChildCount() <= 0) {
|
|
return false;
|
|
}
|
|
int scrollY = getScrollY();
|
|
View childAt = getChildAt(0);
|
|
return i2 >= childAt.getTop() - scrollY && i2 < childAt.getBottom() - scrollY && i >= childAt.getLeft() && i < childAt.getRight();
|
|
}
|
|
|
|
private void initOrResetVelocityTracker() {
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker == null) {
|
|
this.mVelocityTracker = VelocityTracker.obtain();
|
|
} else {
|
|
velocityTracker.clear();
|
|
}
|
|
}
|
|
|
|
private void initScrollView() {
|
|
this.mScroller = new OverScroller(getContext());
|
|
setFocusable(true);
|
|
setDescendantFocusability(262144);
|
|
setWillNotDraw(false);
|
|
ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
|
|
this.mTouchSlop = viewConfiguration.getScaledTouchSlop();
|
|
this.mMinimumVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
|
|
this.mMaximumVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
|
|
}
|
|
|
|
private void initVelocityTrackerIfNotExists() {
|
|
if (this.mVelocityTracker == null) {
|
|
this.mVelocityTracker = VelocityTracker.obtain();
|
|
}
|
|
}
|
|
|
|
private boolean isOffScreen(View view) {
|
|
return !isWithinDeltaOfScreen(view, 0, getHeight());
|
|
}
|
|
|
|
private static boolean isViewDescendantOf(View view, View view2) {
|
|
if (view == view2) {
|
|
return true;
|
|
}
|
|
ViewParent parent = view.getParent();
|
|
return (parent instanceof ViewGroup) && isViewDescendantOf((View) parent, view2);
|
|
}
|
|
|
|
private boolean isWithinDeltaOfScreen(View view, int i, int i2) {
|
|
view.getDrawingRect(this.mTempRect);
|
|
offsetDescendantRectToMyCoords(view, this.mTempRect);
|
|
return this.mTempRect.bottom + i >= getScrollY() && this.mTempRect.top - i <= getScrollY() + i2;
|
|
}
|
|
|
|
private void onNestedScrollInternal(int i, int i2, @Nullable int[] iArr) {
|
|
int scrollY = getScrollY();
|
|
scrollBy(0, i);
|
|
int scrollY2 = getScrollY() - scrollY;
|
|
if (iArr != null) {
|
|
iArr[1] = iArr[1] + scrollY2;
|
|
}
|
|
this.mChildHelper.dispatchNestedScroll(0, scrollY2, 0, i - scrollY2, null, i2, iArr);
|
|
}
|
|
|
|
private void onSecondaryPointerUp(MotionEvent motionEvent) {
|
|
int actionIndex = motionEvent.getActionIndex();
|
|
if (motionEvent.getPointerId(actionIndex) == this.mActivePointerId) {
|
|
int i = actionIndex == 0 ? 1 : 0;
|
|
this.mLastMotionY = (int) motionEvent.getY(i);
|
|
this.mActivePointerId = motionEvent.getPointerId(i);
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void recycleVelocityTracker() {
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.recycle();
|
|
this.mVelocityTracker = null;
|
|
}
|
|
}
|
|
|
|
private void runAnimatedScroll(boolean z2) {
|
|
if (z2) {
|
|
startNestedScroll(2, 1);
|
|
} else {
|
|
stopNestedScroll(1);
|
|
}
|
|
this.mLastScrollerY = getScrollY();
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
|
|
private boolean scrollAndFocus(int i, int i2, int i3) {
|
|
int height = getHeight();
|
|
int scrollY = getScrollY();
|
|
int i4 = height + scrollY;
|
|
boolean z2 = false;
|
|
boolean z3 = i == 33;
|
|
View findFocusableViewInBounds = findFocusableViewInBounds(z3, i2, i3);
|
|
if (findFocusableViewInBounds == null) {
|
|
findFocusableViewInBounds = this;
|
|
}
|
|
if (i2 < scrollY || i3 > i4) {
|
|
doScrollY(z3 ? i2 - scrollY : i3 - i4);
|
|
z2 = true;
|
|
}
|
|
if (findFocusableViewInBounds != findFocus()) {
|
|
findFocusableViewInBounds.requestFocus(i);
|
|
}
|
|
return z2;
|
|
}
|
|
|
|
private void scrollToChild(View view) {
|
|
view.getDrawingRect(this.mTempRect);
|
|
offsetDescendantRectToMyCoords(view, this.mTempRect);
|
|
int computeScrollDeltaToGetChildRectOnScreen = computeScrollDeltaToGetChildRectOnScreen(this.mTempRect);
|
|
if (computeScrollDeltaToGetChildRectOnScreen != 0) {
|
|
scrollBy(0, computeScrollDeltaToGetChildRectOnScreen);
|
|
}
|
|
}
|
|
|
|
private boolean scrollToChildRect(Rect rect, boolean z2) {
|
|
int computeScrollDeltaToGetChildRectOnScreen = computeScrollDeltaToGetChildRectOnScreen(rect);
|
|
boolean z3 = computeScrollDeltaToGetChildRectOnScreen != 0;
|
|
if (z3) {
|
|
if (z2) {
|
|
scrollBy(0, computeScrollDeltaToGetChildRectOnScreen);
|
|
} else {
|
|
smoothScrollBy(0, computeScrollDeltaToGetChildRectOnScreen);
|
|
}
|
|
}
|
|
return z3;
|
|
}
|
|
|
|
private void smoothScrollBy(int i, int i2, int i3, boolean z2) {
|
|
if (getChildCount() != 0) {
|
|
if (AnimationUtils.currentAnimationTimeMillis() - this.mLastScroll > 250) {
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
int scrollY = getScrollY();
|
|
OverScroller overScroller = this.mScroller;
|
|
int scrollX = getScrollX();
|
|
overScroller.startScroll(scrollX, scrollY, 0, Math.max(0, Math.min(i2 + scrollY, Math.max(0, ((childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin) - ((getHeight() - getPaddingTop()) - getPaddingBottom())))) - scrollY, i3);
|
|
runAnimatedScroll(z2);
|
|
} else {
|
|
if (!this.mScroller.isFinished()) {
|
|
abortAnimatedScroll();
|
|
}
|
|
scrollBy(i, i2);
|
|
}
|
|
this.mLastScroll = AnimationUtils.currentAnimationTimeMillis();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void addView(View view) {
|
|
if (getChildCount() <= 0) {
|
|
super.addView(view);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("ScrollView can host only one direct child");
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void addView(View view, int i) {
|
|
if (getChildCount() <= 0) {
|
|
super.addView(view, i);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("ScrollView can host only one direct child");
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
|
if (getChildCount() <= 0) {
|
|
super.addView(view, i, layoutParams);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("ScrollView can host only one direct child");
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewManager
|
|
public void addView(View view, ViewGroup.LayoutParams layoutParams) {
|
|
if (getChildCount() <= 0) {
|
|
super.addView(view, layoutParams);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("ScrollView can host only one direct child");
|
|
}
|
|
|
|
public boolean arrowScroll(int i) {
|
|
View findFocus = findFocus();
|
|
if (findFocus == this) {
|
|
findFocus = null;
|
|
}
|
|
View findNextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, i);
|
|
int maxScrollAmount = getMaxScrollAmount();
|
|
if (findNextFocus == null || !isWithinDeltaOfScreen(findNextFocus, maxScrollAmount, getHeight())) {
|
|
if (i == 33 && getScrollY() < maxScrollAmount) {
|
|
maxScrollAmount = getScrollY();
|
|
} else if (i == 130 && getChildCount() > 0) {
|
|
View childAt = getChildAt(0);
|
|
maxScrollAmount = Math.min((childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin) - ((getHeight() + getScrollY()) - getPaddingBottom()), maxScrollAmount);
|
|
}
|
|
if (maxScrollAmount == 0) {
|
|
return false;
|
|
}
|
|
if (i != 130) {
|
|
maxScrollAmount = -maxScrollAmount;
|
|
}
|
|
doScrollY(maxScrollAmount);
|
|
} else {
|
|
findNextFocus.getDrawingRect(this.mTempRect);
|
|
offsetDescendantRectToMyCoords(findNextFocus, this.mTempRect);
|
|
doScrollY(computeScrollDeltaToGetChildRectOnScreen(this.mTempRect));
|
|
findNextFocus.requestFocus(i);
|
|
}
|
|
if (findFocus == null || !findFocus.isFocused() || !isOffScreen(findFocus)) {
|
|
return true;
|
|
}
|
|
int descendantFocusability = getDescendantFocusability();
|
|
setDescendantFocusability(131072);
|
|
requestFocus();
|
|
setDescendantFocusability(descendantFocusability);
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.ScrollingView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public int computeHorizontalScrollExtent() {
|
|
return super.computeHorizontalScrollExtent();
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.ScrollingView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public int computeHorizontalScrollOffset() {
|
|
return super.computeHorizontalScrollOffset();
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.ScrollingView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public int computeHorizontalScrollRange() {
|
|
return super.computeHorizontalScrollRange();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void computeScroll() {
|
|
if (!this.mScroller.isFinished()) {
|
|
this.mScroller.computeScrollOffset();
|
|
int currY = this.mScroller.getCurrY();
|
|
int i = currY - this.mLastScrollerY;
|
|
this.mLastScrollerY = currY;
|
|
int[] iArr = this.mScrollConsumed;
|
|
boolean z2 = false;
|
|
iArr[1] = 0;
|
|
dispatchNestedPreScroll(0, i, iArr, null, 1);
|
|
int i2 = i - this.mScrollConsumed[1];
|
|
int scrollRange = getScrollRange();
|
|
if (i2 != 0) {
|
|
int scrollY = getScrollY();
|
|
overScrollByCompat(0, i2, getScrollX(), scrollY, 0, scrollRange, 0, 0, false);
|
|
int scrollY2 = getScrollY() - scrollY;
|
|
int i3 = i2 - scrollY2;
|
|
int[] iArr2 = this.mScrollConsumed;
|
|
iArr2[1] = 0;
|
|
dispatchNestedScroll(0, scrollY2, 0, i3, this.mScrollOffset, 1, iArr2);
|
|
i2 = i3 - this.mScrollConsumed[1];
|
|
}
|
|
if (i2 != 0) {
|
|
int overScrollMode = getOverScrollMode();
|
|
if (overScrollMode == 0 || (overScrollMode == 1 && scrollRange > 0)) {
|
|
z2 = true;
|
|
}
|
|
if (z2) {
|
|
ensureGlows();
|
|
if (i2 < 0) {
|
|
if (this.mEdgeGlowTop.isFinished()) {
|
|
this.mEdgeGlowTop.onAbsorb((int) this.mScroller.getCurrVelocity());
|
|
}
|
|
} else if (this.mEdgeGlowBottom.isFinished()) {
|
|
this.mEdgeGlowBottom.onAbsorb((int) this.mScroller.getCurrVelocity());
|
|
}
|
|
}
|
|
abortAnimatedScroll();
|
|
}
|
|
if (!this.mScroller.isFinished()) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
} else {
|
|
stopNestedScroll(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
|
|
if (getChildCount() == 0) {
|
|
return 0;
|
|
}
|
|
int height = getHeight();
|
|
int scrollY = getScrollY();
|
|
int i = scrollY + height;
|
|
int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
|
|
if (rect.top > 0) {
|
|
scrollY += verticalFadingEdgeLength;
|
|
}
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
int i2 = rect.bottom < (childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin ? i - verticalFadingEdgeLength : i;
|
|
int i3 = rect.bottom;
|
|
if (i3 > i2 && rect.top > scrollY) {
|
|
return Math.min((rect.height() > height ? rect.top - scrollY : rect.bottom - i2) + 0, (childAt.getBottom() + layoutParams.bottomMargin) - i);
|
|
} else if (rect.top >= scrollY || i3 >= i2) {
|
|
return 0;
|
|
} else {
|
|
return Math.max(rect.height() > height ? 0 - (i2 - rect.bottom) : 0 - (scrollY - rect.top), -getScrollY());
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.ScrollingView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public int computeVerticalScrollExtent() {
|
|
return super.computeVerticalScrollExtent();
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.ScrollingView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public int computeVerticalScrollOffset() {
|
|
return Math.max(0, super.computeVerticalScrollOffset());
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.ScrollingView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public int computeVerticalScrollRange() {
|
|
int childCount = getChildCount();
|
|
int height = (getHeight() - getPaddingBottom()) - getPaddingTop();
|
|
if (childCount == 0) {
|
|
return height;
|
|
}
|
|
View childAt = getChildAt(0);
|
|
int bottom = childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
|
|
int scrollY = getScrollY();
|
|
int max = Math.max(0, bottom - height);
|
|
return scrollY < 0 ? bottom - scrollY : scrollY > max ? bottom + (scrollY - max) : bottom;
|
|
}
|
|
|
|
@Override // android.view.View, android.view.ViewGroup
|
|
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
|
|
return super.dispatchKeyEvent(keyEvent) || executeKeyEvent(keyEvent);
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean dispatchNestedFling(float f, float f2, boolean z2) {
|
|
return this.mChildHelper.dispatchNestedFling(f, f2, z2);
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean dispatchNestedPreFling(float f, float f2) {
|
|
return this.mChildHelper.dispatchNestedPreFling(f, f2);
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean dispatchNestedPreScroll(int i, int i2, int[] iArr, int[] iArr2) {
|
|
return dispatchNestedPreScroll(i, i2, iArr, iArr2, 0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingChild2
|
|
public boolean dispatchNestedPreScroll(int i, int i2, int[] iArr, int[] iArr2, int i3) {
|
|
return this.mChildHelper.dispatchNestedPreScroll(i, i2, iArr, iArr2, i3);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingChild3
|
|
public void dispatchNestedScroll(int i, int i2, int i3, int i4, @Nullable int[] iArr, int i5, @NonNull int[] iArr2) {
|
|
this.mChildHelper.dispatchNestedScroll(i, i2, i3, i4, iArr, i5, iArr2);
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean dispatchNestedScroll(int i, int i2, int i3, int i4, int[] iArr) {
|
|
return this.mChildHelper.dispatchNestedScroll(i, i2, i3, i4, iArr);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingChild2
|
|
public boolean dispatchNestedScroll(int i, int i2, int i3, int i4, int[] iArr, int i5) {
|
|
return this.mChildHelper.dispatchNestedScroll(i, i2, i3, i4, iArr, i5);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void draw(Canvas canvas) {
|
|
int i;
|
|
super.draw(canvas);
|
|
if (this.mEdgeGlowTop != null) {
|
|
int scrollY = getScrollY();
|
|
int i2 = 0;
|
|
if (!this.mEdgeGlowTop.isFinished()) {
|
|
int save = canvas.save();
|
|
int width = getWidth();
|
|
int height = getHeight();
|
|
int min = Math.min(0, scrollY);
|
|
if (getClipToPadding()) {
|
|
width -= getPaddingRight() + getPaddingLeft();
|
|
i = getPaddingLeft() + 0;
|
|
} else {
|
|
i = 0;
|
|
}
|
|
if (getClipToPadding()) {
|
|
height -= getPaddingBottom() + getPaddingTop();
|
|
min += getPaddingTop();
|
|
}
|
|
canvas.translate((float) i, (float) min);
|
|
this.mEdgeGlowTop.setSize(width, height);
|
|
if (this.mEdgeGlowTop.draw(canvas)) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
canvas.restoreToCount(save);
|
|
}
|
|
if (!this.mEdgeGlowBottom.isFinished()) {
|
|
int save2 = canvas.save();
|
|
int width2 = getWidth();
|
|
int height2 = getHeight();
|
|
int max = Math.max(getScrollRange(), scrollY) + height2;
|
|
if (getClipToPadding()) {
|
|
width2 -= getPaddingRight() + getPaddingLeft();
|
|
i2 = 0 + getPaddingLeft();
|
|
}
|
|
if (getClipToPadding()) {
|
|
height2 -= getPaddingBottom() + getPaddingTop();
|
|
max -= getPaddingBottom();
|
|
}
|
|
canvas.translate((float) (i2 - width2), (float) max);
|
|
canvas.rotate(180.0f, (float) width2, 0.0f);
|
|
this.mEdgeGlowBottom.setSize(width2, height2);
|
|
if (this.mEdgeGlowBottom.draw(canvas)) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
canvas.restoreToCount(save2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public boolean executeKeyEvent(@NonNull KeyEvent keyEvent) {
|
|
this.mTempRect.setEmpty();
|
|
int i = 130;
|
|
if (!canScroll()) {
|
|
if (!isFocused() || keyEvent.getKeyCode() == 4) {
|
|
return false;
|
|
}
|
|
View findFocus = findFocus();
|
|
if (findFocus == this) {
|
|
findFocus = null;
|
|
}
|
|
View findNextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, 130);
|
|
return (findNextFocus == null || findNextFocus == this || !findNextFocus.requestFocus(130)) ? false : true;
|
|
} else if (keyEvent.getAction() != 0) {
|
|
return false;
|
|
} else {
|
|
int keyCode = keyEvent.getKeyCode();
|
|
if (keyCode == 19) {
|
|
return !keyEvent.isAltPressed() ? arrowScroll(33) : fullScroll(33);
|
|
}
|
|
if (keyCode == 20) {
|
|
return !keyEvent.isAltPressed() ? arrowScroll(130) : fullScroll(130);
|
|
}
|
|
if (keyCode != 62) {
|
|
return false;
|
|
}
|
|
if (keyEvent.isShiftPressed()) {
|
|
i = 33;
|
|
}
|
|
pageScroll(i);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void fling(int i) {
|
|
if (getChildCount() > 0) {
|
|
this.mScroller.fling(getScrollX(), getScrollY(), 0, i, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
|
|
runAnimatedScroll(true);
|
|
}
|
|
}
|
|
|
|
public boolean fullScroll(int i) {
|
|
int childCount;
|
|
boolean z2 = i == 130;
|
|
int height = getHeight();
|
|
Rect rect = this.mTempRect;
|
|
rect.top = 0;
|
|
rect.bottom = height;
|
|
if (z2 && (childCount = getChildCount()) > 0) {
|
|
View childAt = getChildAt(childCount - 1);
|
|
this.mTempRect.bottom = getPaddingBottom() + childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
|
|
Rect rect2 = this.mTempRect;
|
|
rect2.top = rect2.bottom - height;
|
|
}
|
|
Rect rect3 = this.mTempRect;
|
|
return scrollAndFocus(i, rect3.top, rect3.bottom);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public float getBottomFadingEdgeStrength() {
|
|
if (getChildCount() == 0) {
|
|
return 0.0f;
|
|
}
|
|
View childAt = getChildAt(0);
|
|
int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
|
|
int bottom = ((childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin) - getScrollY()) - (getHeight() - getPaddingBottom());
|
|
if (bottom < verticalFadingEdgeLength) {
|
|
return ((float) bottom) / ((float) verticalFadingEdgeLength);
|
|
}
|
|
return 1.0f;
|
|
}
|
|
|
|
public int getMaxScrollAmount() {
|
|
return (int) (((float) getHeight()) * 0.5f);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public int getNestedScrollAxes() {
|
|
return this.mParentHelper.getNestedScrollAxes();
|
|
}
|
|
|
|
public int getScrollRange() {
|
|
if (getChildCount() <= 0) {
|
|
return 0;
|
|
}
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
return Math.max(0, ((childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin) - ((getHeight() - getPaddingTop()) - getPaddingBottom()));
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public float getTopFadingEdgeStrength() {
|
|
if (getChildCount() == 0) {
|
|
return 0.0f;
|
|
}
|
|
int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
|
|
int scrollY = getScrollY();
|
|
if (scrollY < verticalFadingEdgeLength) {
|
|
return ((float) scrollY) / ((float) verticalFadingEdgeLength);
|
|
}
|
|
return 1.0f;
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean hasNestedScrollingParent() {
|
|
return hasNestedScrollingParent(0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingChild2
|
|
public boolean hasNestedScrollingParent(int i) {
|
|
return this.mChildHelper.hasNestedScrollingParent(i);
|
|
}
|
|
|
|
public boolean isFillViewport() {
|
|
return this.mFillViewport;
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean isNestedScrollingEnabled() {
|
|
return this.mChildHelper.isNestedScrollingEnabled();
|
|
}
|
|
|
|
public boolean isSmoothScrollingEnabled() {
|
|
return this.mSmoothScrollingEnabled;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void measureChild(View view, int i, int i2) {
|
|
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
|
view.measure(FrameLayout.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft(), layoutParams.width), View.MeasureSpec.makeMeasureSpec(0, 0));
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void measureChildWithMargins(View view, int i, int i2, int i3, int i4) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
|
view.measure(FrameLayout.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i2, marginLayoutParams.width), View.MeasureSpec.makeMeasureSpec(marginLayoutParams.topMargin + marginLayoutParams.bottomMargin, 0));
|
|
}
|
|
|
|
@Override // android.view.View, android.view.ViewGroup
|
|
public void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
this.mIsLaidOut = false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onGenericMotionEvent(MotionEvent motionEvent) {
|
|
if ((motionEvent.getSource() & 2) != 0 && motionEvent.getAction() == 8 && !this.mIsBeingDragged) {
|
|
float axisValue = motionEvent.getAxisValue(9);
|
|
if (axisValue != 0.0f) {
|
|
int scrollRange = getScrollRange();
|
|
int scrollY = getScrollY();
|
|
int verticalScrollFactorCompat = scrollY - ((int) (axisValue * getVerticalScrollFactorCompat()));
|
|
if (verticalScrollFactorCompat < 0) {
|
|
scrollRange = 0;
|
|
} else if (verticalScrollFactorCompat <= scrollRange) {
|
|
scrollRange = verticalScrollFactorCompat;
|
|
}
|
|
if (scrollRange != scrollY) {
|
|
super.scrollTo(getScrollX(), scrollRange);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
|
int action = motionEvent.getAction();
|
|
if (action == 2 && this.mIsBeingDragged) {
|
|
return true;
|
|
}
|
|
int i = action & 255;
|
|
if (i != 0) {
|
|
if (i != 1) {
|
|
if (i == 2) {
|
|
int i2 = this.mActivePointerId;
|
|
if (i2 != -1) {
|
|
int findPointerIndex = motionEvent.findPointerIndex(i2);
|
|
if (findPointerIndex == -1) {
|
|
Log.e("NestedScrollView", "Invalid pointerId=" + i2 + " in onInterceptTouchEvent");
|
|
} else {
|
|
int y2 = (int) motionEvent.getY(findPointerIndex);
|
|
if (Math.abs(y2 - this.mLastMotionY) > this.mTouchSlop && (2 & getNestedScrollAxes()) == 0) {
|
|
this.mIsBeingDragged = true;
|
|
this.mLastMotionY = y2;
|
|
initVelocityTrackerIfNotExists();
|
|
this.mVelocityTracker.addMovement(motionEvent);
|
|
this.mNestedYOffset = 0;
|
|
ViewParent parent = getParent();
|
|
if (parent != null) {
|
|
parent.requestDisallowInterceptTouchEvent(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (i != 3) {
|
|
if (i == 6) {
|
|
onSecondaryPointerUp(motionEvent);
|
|
}
|
|
}
|
|
}
|
|
this.mIsBeingDragged = false;
|
|
this.mActivePointerId = -1;
|
|
recycleVelocityTracker();
|
|
if (this.mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
stopNestedScroll(0);
|
|
} else {
|
|
int y3 = (int) motionEvent.getY();
|
|
if (!inChild((int) motionEvent.getX(), y3)) {
|
|
this.mIsBeingDragged = false;
|
|
recycleVelocityTracker();
|
|
} else {
|
|
this.mLastMotionY = y3;
|
|
this.mActivePointerId = motionEvent.getPointerId(0);
|
|
initOrResetVelocityTracker();
|
|
this.mVelocityTracker.addMovement(motionEvent);
|
|
this.mScroller.computeScrollOffset();
|
|
this.mIsBeingDragged = !this.mScroller.isFinished();
|
|
startNestedScroll(2, 0);
|
|
}
|
|
}
|
|
return this.mIsBeingDragged;
|
|
}
|
|
|
|
@Override // android.widget.FrameLayout, android.view.View, android.view.ViewGroup
|
|
public void onLayout(boolean z2, int i, int i2, int i3, int i4) {
|
|
super.onLayout(z2, i, i2, i3, i4);
|
|
int i5 = 0;
|
|
this.mIsLayoutDirty = false;
|
|
View view = this.mChildToScrollTo;
|
|
if (view != null && isViewDescendantOf(view, this)) {
|
|
scrollToChild(this.mChildToScrollTo);
|
|
}
|
|
this.mChildToScrollTo = null;
|
|
if (!this.mIsLaidOut) {
|
|
if (this.mSavedState != null) {
|
|
scrollTo(getScrollX(), this.mSavedState.scrollPosition);
|
|
this.mSavedState = null;
|
|
}
|
|
if (getChildCount() > 0) {
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
i5 = childAt.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
|
|
}
|
|
int paddingTop = ((i4 - i2) - getPaddingTop()) - getPaddingBottom();
|
|
int scrollY = getScrollY();
|
|
int clamp = clamp(scrollY, paddingTop, i5);
|
|
if (clamp != scrollY) {
|
|
scrollTo(getScrollX(), clamp);
|
|
}
|
|
}
|
|
scrollTo(getScrollX(), getScrollY());
|
|
this.mIsLaidOut = true;
|
|
}
|
|
|
|
@Override // android.widget.FrameLayout, android.view.View
|
|
public void onMeasure(int i, int i2) {
|
|
super.onMeasure(i, i2);
|
|
if (this.mFillViewport && View.MeasureSpec.getMode(i2) != 0 && getChildCount() > 0) {
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
int measuredHeight = childAt.getMeasuredHeight();
|
|
int measuredHeight2 = (((getMeasuredHeight() - getPaddingTop()) - getPaddingBottom()) - layoutParams.topMargin) - layoutParams.bottomMargin;
|
|
if (measuredHeight < measuredHeight2) {
|
|
childAt.measure(FrameLayout.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft() + layoutParams.leftMargin + layoutParams.rightMargin, layoutParams.width), View.MeasureSpec.makeMeasureSpec(measuredHeight2, 1073741824));
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public boolean onNestedFling(@NonNull View view, float f, float f2, boolean z2) {
|
|
if (z2) {
|
|
return false;
|
|
}
|
|
dispatchNestedFling(0.0f, f2, true);
|
|
fling((int) f2);
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public boolean onNestedPreFling(@NonNull View view, float f, float f2) {
|
|
return dispatchNestedPreFling(f, f2);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public void onNestedPreScroll(@NonNull View view, int i, int i2, @NonNull int[] iArr) {
|
|
onNestedPreScroll(view, i, i2, iArr, 0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedPreScroll(@NonNull View view, int i, int i2, @NonNull int[] iArr, int i3) {
|
|
dispatchNestedPreScroll(i, i2, iArr, null, i3);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public void onNestedScroll(@NonNull View view, int i, int i2, int i3, int i4) {
|
|
onNestedScrollInternal(i4, 0, null);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScroll(@NonNull View view, int i, int i2, int i3, int i4, int i5) {
|
|
onNestedScrollInternal(i4, i5, null);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent3
|
|
public void onNestedScroll(@NonNull View view, int i, int i2, int i3, int i4, int i5, @NonNull int[] iArr) {
|
|
onNestedScrollInternal(i4, i5, iArr);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public void onNestedScrollAccepted(@NonNull View view, @NonNull View view2, int i) {
|
|
onNestedScrollAccepted(view, view2, i, 0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScrollAccepted(@NonNull View view, @NonNull View view2, int i, int i2) {
|
|
this.mParentHelper.onNestedScrollAccepted(view, view2, i, i2);
|
|
startNestedScroll(2, i2);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onOverScrolled(int i, int i2, boolean z2, boolean z3) {
|
|
super.scrollTo(i, i2);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean onRequestFocusInDescendants(int i, Rect rect) {
|
|
if (i == 2) {
|
|
i = 130;
|
|
} else if (i == 1) {
|
|
i = 33;
|
|
}
|
|
View findNextFocus = rect == null ? FocusFinder.getInstance().findNextFocus(this, null, i) : FocusFinder.getInstance().findNextFocusFromRect(this, rect, i);
|
|
if (findNextFocus != null && !isOffScreen(findNextFocus)) {
|
|
return findNextFocus.requestFocus(i, rect);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onRestoreInstanceState(Parcelable parcelable) {
|
|
if (!(parcelable instanceof SavedState)) {
|
|
super.onRestoreInstanceState(parcelable);
|
|
return;
|
|
}
|
|
SavedState savedState = (SavedState) parcelable;
|
|
super.onRestoreInstanceState(savedState.getSuperState());
|
|
this.mSavedState = savedState;
|
|
requestLayout();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public Parcelable onSaveInstanceState() {
|
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
|
savedState.scrollPosition = getScrollY();
|
|
return savedState;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onScrollChanged(int i, int i2, int i3, int i4) {
|
|
super.onScrollChanged(i, i2, i3, i4);
|
|
OnScrollChangeListener onScrollChangeListener = this.mOnScrollChangeListener;
|
|
if (onScrollChangeListener != null) {
|
|
onScrollChangeListener.onScrollChange(this, i, i2, i3, i4);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
View findFocus = findFocus();
|
|
if (findFocus != null && this != findFocus && isWithinDeltaOfScreen(findFocus, 0, i4)) {
|
|
findFocus.getDrawingRect(this.mTempRect);
|
|
offsetDescendantRectToMyCoords(findFocus, this.mTempRect);
|
|
doScrollY(computeScrollDeltaToGetChildRectOnScreen(this.mTempRect));
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public boolean onStartNestedScroll(@NonNull View view, @NonNull View view2, int i) {
|
|
return onStartNestedScroll(view, view2, i, 0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public boolean onStartNestedScroll(@NonNull View view, @NonNull View view2, int i, int i2) {
|
|
return (i & 2) != 0;
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public void onStopNestedScroll(@NonNull View view) {
|
|
onStopNestedScroll(view, 0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onStopNestedScroll(@NonNull View view, int i) {
|
|
this.mParentHelper.onStopNestedScroll(view, i);
|
|
stopNestedScroll(i);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
ViewParent parent;
|
|
initVelocityTrackerIfNotExists();
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 0) {
|
|
this.mNestedYOffset = 0;
|
|
}
|
|
MotionEvent obtain = MotionEvent.obtain(motionEvent);
|
|
obtain.offsetLocation(0.0f, (float) this.mNestedYOffset);
|
|
if (actionMasked != 0) {
|
|
if (actionMasked == 1) {
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
velocityTracker.computeCurrentVelocity(1000, (float) this.mMaximumVelocity);
|
|
int yVelocity = (int) velocityTracker.getYVelocity(this.mActivePointerId);
|
|
if (Math.abs(yVelocity) >= this.mMinimumVelocity) {
|
|
int i = -yVelocity;
|
|
float f = (float) i;
|
|
if (!dispatchNestedPreFling(0.0f, f)) {
|
|
dispatchNestedFling(0.0f, f, true);
|
|
fling(i);
|
|
}
|
|
} else if (this.mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
this.mActivePointerId = -1;
|
|
endDrag();
|
|
} else if (actionMasked == 2) {
|
|
int findPointerIndex = motionEvent.findPointerIndex(this.mActivePointerId);
|
|
if (findPointerIndex == -1) {
|
|
StringBuilder L = a.L("Invalid pointerId=");
|
|
L.append(this.mActivePointerId);
|
|
L.append(" in onTouchEvent");
|
|
Log.e("NestedScrollView", L.toString());
|
|
} else {
|
|
int y2 = (int) motionEvent.getY(findPointerIndex);
|
|
int i2 = this.mLastMotionY - y2;
|
|
if (!this.mIsBeingDragged && Math.abs(i2) > this.mTouchSlop) {
|
|
ViewParent parent2 = getParent();
|
|
if (parent2 != null) {
|
|
parent2.requestDisallowInterceptTouchEvent(true);
|
|
}
|
|
this.mIsBeingDragged = true;
|
|
i2 = i2 > 0 ? i2 - this.mTouchSlop : i2 + this.mTouchSlop;
|
|
}
|
|
int i3 = i2;
|
|
if (this.mIsBeingDragged) {
|
|
if (dispatchNestedPreScroll(0, i3, this.mScrollConsumed, this.mScrollOffset, 0)) {
|
|
i3 -= this.mScrollConsumed[1];
|
|
this.mNestedYOffset += this.mScrollOffset[1];
|
|
}
|
|
this.mLastMotionY = y2 - this.mScrollOffset[1];
|
|
int scrollY = getScrollY();
|
|
int scrollRange = getScrollRange();
|
|
int overScrollMode = getOverScrollMode();
|
|
boolean z2 = overScrollMode == 0 || (overScrollMode == 1 && scrollRange > 0);
|
|
if (overScrollByCompat(0, i3, 0, getScrollY(), 0, scrollRange, 0, 0, true) && !hasNestedScrollingParent(0)) {
|
|
this.mVelocityTracker.clear();
|
|
}
|
|
int scrollY2 = getScrollY() - scrollY;
|
|
int i4 = i3 - scrollY2;
|
|
int[] iArr = this.mScrollConsumed;
|
|
iArr[1] = 0;
|
|
dispatchNestedScroll(0, scrollY2, 0, i4, this.mScrollOffset, 0, iArr);
|
|
int i5 = this.mLastMotionY;
|
|
int[] iArr2 = this.mScrollOffset;
|
|
this.mLastMotionY = i5 - iArr2[1];
|
|
this.mNestedYOffset += iArr2[1];
|
|
if (z2) {
|
|
int i6 = i3 - this.mScrollConsumed[1];
|
|
ensureGlows();
|
|
int i7 = scrollY + i6;
|
|
if (i7 < 0) {
|
|
EdgeEffectCompat.onPull(this.mEdgeGlowTop, ((float) i6) / ((float) getHeight()), motionEvent.getX(findPointerIndex) / ((float) getWidth()));
|
|
if (!this.mEdgeGlowBottom.isFinished()) {
|
|
this.mEdgeGlowBottom.onRelease();
|
|
}
|
|
} else if (i7 > scrollRange) {
|
|
EdgeEffectCompat.onPull(this.mEdgeGlowBottom, ((float) i6) / ((float) getHeight()), 1.0f - (motionEvent.getX(findPointerIndex) / ((float) getWidth())));
|
|
if (!this.mEdgeGlowTop.isFinished()) {
|
|
this.mEdgeGlowTop.onRelease();
|
|
}
|
|
}
|
|
EdgeEffect edgeEffect = this.mEdgeGlowTop;
|
|
if (edgeEffect != null && (!edgeEffect.isFinished() || !this.mEdgeGlowBottom.isFinished())) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (actionMasked == 3) {
|
|
if (this.mIsBeingDragged && getChildCount() > 0 && this.mScroller.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
this.mActivePointerId = -1;
|
|
endDrag();
|
|
} else if (actionMasked == 5) {
|
|
int actionIndex = motionEvent.getActionIndex();
|
|
this.mLastMotionY = (int) motionEvent.getY(actionIndex);
|
|
this.mActivePointerId = motionEvent.getPointerId(actionIndex);
|
|
} else if (actionMasked == 6) {
|
|
onSecondaryPointerUp(motionEvent);
|
|
this.mLastMotionY = (int) motionEvent.getY(motionEvent.findPointerIndex(this.mActivePointerId));
|
|
}
|
|
} else if (getChildCount() == 0) {
|
|
return false;
|
|
} else {
|
|
boolean z3 = !this.mScroller.isFinished();
|
|
this.mIsBeingDragged = z3;
|
|
if (z3 && (parent = getParent()) != null) {
|
|
parent.requestDisallowInterceptTouchEvent(true);
|
|
}
|
|
if (!this.mScroller.isFinished()) {
|
|
abortAnimatedScroll();
|
|
}
|
|
this.mLastMotionY = (int) motionEvent.getY();
|
|
this.mActivePointerId = motionEvent.getPointerId(0);
|
|
startNestedScroll(2, 0);
|
|
}
|
|
VelocityTracker velocityTracker2 = this.mVelocityTracker;
|
|
if (velocityTracker2 != null) {
|
|
velocityTracker2.addMovement(obtain);
|
|
}
|
|
obtain.recycle();
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:34:0x0057 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:36:0x005a */
|
|
/* JADX WARNING: Removed duplicated region for block: B:45:0x0083 A[ADDED_TO_REGION] */
|
|
public boolean overScrollByCompat(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, boolean z2) {
|
|
boolean z3;
|
|
boolean z4;
|
|
int overScrollMode = getOverScrollMode();
|
|
boolean z5 = computeHorizontalScrollRange() > computeHorizontalScrollExtent();
|
|
boolean z6 = computeVerticalScrollRange() > computeVerticalScrollExtent();
|
|
boolean z7 = overScrollMode == 0 || (overScrollMode == 1 && z5);
|
|
boolean z8 = overScrollMode == 0 || (overScrollMode == 1 && z6);
|
|
int i9 = i3 + i;
|
|
int i10 = !z7 ? 0 : i7;
|
|
int i11 = i4 + i2;
|
|
int i12 = !z8 ? 0 : i8;
|
|
int i13 = -i10;
|
|
int i14 = i10 + i5;
|
|
int i15 = -i12;
|
|
int i16 = i12 + i6;
|
|
if (i9 > i14) {
|
|
i9 = i14;
|
|
} else if (i9 < i13) {
|
|
i9 = i13;
|
|
} else {
|
|
z3 = false;
|
|
if (i11 <= i16) {
|
|
i11 = i16;
|
|
} else if (i11 < i15) {
|
|
i11 = i15;
|
|
} else {
|
|
z4 = false;
|
|
if (z4 && !hasNestedScrollingParent(1)) {
|
|
this.mScroller.springBack(i9, i11, 0, 0, 0, getScrollRange());
|
|
}
|
|
onOverScrolled(i9, i11, z3, z4);
|
|
return !z3 || z4;
|
|
}
|
|
z4 = true;
|
|
this.mScroller.springBack(i9, i11, 0, 0, 0, getScrollRange());
|
|
onOverScrolled(i9, i11, z3, z4);
|
|
if (!z3) {
|
|
}
|
|
}
|
|
z3 = true;
|
|
if (i11 <= i16) {
|
|
}
|
|
z4 = true;
|
|
this.mScroller.springBack(i9, i11, 0, 0, 0, getScrollRange());
|
|
onOverScrolled(i9, i11, z3, z4);
|
|
if (!z3) {
|
|
}
|
|
}
|
|
|
|
public boolean pageScroll(int i) {
|
|
boolean z2 = i == 130;
|
|
int height = getHeight();
|
|
if (z2) {
|
|
this.mTempRect.top = getScrollY() + height;
|
|
int childCount = getChildCount();
|
|
if (childCount > 0) {
|
|
View childAt = getChildAt(childCount - 1);
|
|
int paddingBottom = getPaddingBottom() + childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
|
|
Rect rect = this.mTempRect;
|
|
if (rect.top + height > paddingBottom) {
|
|
rect.top = paddingBottom - height;
|
|
}
|
|
}
|
|
} else {
|
|
this.mTempRect.top = getScrollY() - height;
|
|
Rect rect2 = this.mTempRect;
|
|
if (rect2.top < 0) {
|
|
rect2.top = 0;
|
|
}
|
|
}
|
|
Rect rect3 = this.mTempRect;
|
|
int i2 = rect3.top;
|
|
int i3 = height + i2;
|
|
rect3.bottom = i3;
|
|
return scrollAndFocus(i, i2, i3);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup
|
|
public void requestChildFocus(View view, View view2) {
|
|
if (!this.mIsLayoutDirty) {
|
|
scrollToChild(view2);
|
|
} else {
|
|
this.mChildToScrollTo = view2;
|
|
}
|
|
super.requestChildFocus(view, view2);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup
|
|
public boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z2) {
|
|
rect.offset(view.getLeft() - view.getScrollX(), view.getTop() - view.getScrollY());
|
|
return scrollToChildRect(rect, z2);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.ViewGroup
|
|
public void requestDisallowInterceptTouchEvent(boolean z2) {
|
|
if (z2) {
|
|
recycleVelocityTracker();
|
|
}
|
|
super.requestDisallowInterceptTouchEvent(z2);
|
|
}
|
|
|
|
@Override // android.view.ViewParent, android.view.View
|
|
public void requestLayout() {
|
|
this.mIsLayoutDirty = true;
|
|
super.requestLayout();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void scrollTo(int i, int i2) {
|
|
if (getChildCount() > 0) {
|
|
View childAt = getChildAt(0);
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
|
|
int clamp = clamp(i, (getWidth() - getPaddingLeft()) - getPaddingRight(), childAt.getWidth() + layoutParams.leftMargin + layoutParams.rightMargin);
|
|
int clamp2 = clamp(i2, (getHeight() - getPaddingTop()) - getPaddingBottom(), childAt.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin);
|
|
if (clamp != getScrollX() || clamp2 != getScrollY()) {
|
|
super.scrollTo(clamp, clamp2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setFillViewport(boolean z2) {
|
|
if (z2 != this.mFillViewport) {
|
|
this.mFillViewport = z2;
|
|
requestLayout();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public void setNestedScrollingEnabled(boolean z2) {
|
|
this.mChildHelper.setNestedScrollingEnabled(z2);
|
|
}
|
|
|
|
public void setOnScrollChangeListener(@Nullable OnScrollChangeListener onScrollChangeListener) {
|
|
this.mOnScrollChangeListener = onScrollChangeListener;
|
|
}
|
|
|
|
public void setSmoothScrollingEnabled(boolean z2) {
|
|
this.mSmoothScrollingEnabled = z2;
|
|
}
|
|
|
|
@Override // android.widget.FrameLayout, android.view.ViewGroup
|
|
public boolean shouldDelayChildPressedState() {
|
|
return true;
|
|
}
|
|
|
|
public final void smoothScrollBy(int i, int i2) {
|
|
smoothScrollBy(i, i2, 250, false);
|
|
}
|
|
|
|
public final void smoothScrollBy(int i, int i2, int i3) {
|
|
smoothScrollBy(i, i2, i3, false);
|
|
}
|
|
|
|
public final void smoothScrollTo(int i, int i2) {
|
|
smoothScrollTo(i, i2, 250, false);
|
|
}
|
|
|
|
public final void smoothScrollTo(int i, int i2, int i3) {
|
|
smoothScrollTo(i, i2, i3, false);
|
|
}
|
|
|
|
public void smoothScrollTo(int i, int i2, int i3, boolean z2) {
|
|
smoothScrollBy(i - getScrollX(), i2 - getScrollY(), i3, z2);
|
|
}
|
|
|
|
public void smoothScrollTo(int i, int i2, boolean z2) {
|
|
smoothScrollTo(i, i2, 250, z2);
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public boolean startNestedScroll(int i) {
|
|
return startNestedScroll(i, 0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingChild2
|
|
public boolean startNestedScroll(int i, int i2) {
|
|
return this.mChildHelper.startNestedScroll(i, i2);
|
|
}
|
|
|
|
@Override // android.view.View, androidx.core.view.NestedScrollingChild
|
|
public void stopNestedScroll() {
|
|
stopNestedScroll(0);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingChild2
|
|
public void stopNestedScroll(int i) {
|
|
this.mChildHelper.stopNestedScroll(i);
|
|
}
|
|
}
|