mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-25 16:42:30 -06:00
2172 lines
80 KiB
Java
2172 lines
80 KiB
Java
package androidx.viewpager.widget;
|
|
|
|
import android.R;
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.database.DataSetObserver;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Bundle;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.os.SystemClock;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
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.Interpolator;
|
|
import android.widget.EdgeEffect;
|
|
import android.widget.Scroller;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.core.view.AccessibilityDelegateCompat;
|
|
import androidx.core.view.OnApplyWindowInsetsListener;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.WindowInsetsCompat;
|
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
|
import androidx.customview.view.AbsSavedState;
|
|
import java.lang.annotation.ElementType;
|
|
import java.lang.annotation.Inherited;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
import java.lang.annotation.Target;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class ViewPager extends ViewGroup {
|
|
private static final int CLOSE_ENOUGH = 2;
|
|
private static final boolean DEBUG = false;
|
|
private static final int DEFAULT_GUTTER_SIZE = 16;
|
|
private static final int DEFAULT_OFFSCREEN_PAGES = 1;
|
|
private static final int DRAW_ORDER_DEFAULT = 0;
|
|
private static final int DRAW_ORDER_FORWARD = 1;
|
|
private static final int DRAW_ORDER_REVERSE = 2;
|
|
private static final int INVALID_POINTER = -1;
|
|
private static final int MAX_SETTLE_DURATION = 600;
|
|
private static final int MIN_DISTANCE_FOR_FLING = 25;
|
|
private static final int MIN_FLING_VELOCITY = 400;
|
|
public static final int SCROLL_STATE_DRAGGING = 1;
|
|
public static final int SCROLL_STATE_IDLE = 0;
|
|
public static final int SCROLL_STATE_SETTLING = 2;
|
|
private static final String TAG = "ViewPager";
|
|
private static final boolean USE_CACHE = false;
|
|
private int mActivePointerId;
|
|
PagerAdapter mAdapter;
|
|
private List<OnAdapterChangeListener> mAdapterChangeListeners;
|
|
private int mBottomPageBounds;
|
|
private boolean mCalledSuper;
|
|
private int mChildHeightMeasureSpec;
|
|
private int mChildWidthMeasureSpec;
|
|
private int mCloseEnough;
|
|
int mCurItem;
|
|
private int mDecorChildCount;
|
|
private int mDefaultGutterSize;
|
|
private int mDrawingOrder;
|
|
private ArrayList<View> mDrawingOrderedChildren;
|
|
private final Runnable mEndScrollRunnable;
|
|
private int mExpectedAdapterCount;
|
|
private long mFakeDragBeginTime;
|
|
private boolean mFakeDragging;
|
|
private boolean mFirstLayout;
|
|
private float mFirstOffset;
|
|
private int mFlingDistance;
|
|
private int mGutterSize;
|
|
private boolean mInLayout;
|
|
private float mInitialMotionX;
|
|
private float mInitialMotionY;
|
|
private OnPageChangeListener mInternalPageChangeListener;
|
|
private boolean mIsBeingDragged;
|
|
private boolean mIsScrollStarted;
|
|
private boolean mIsUnableToDrag;
|
|
private final ArrayList<ItemInfo> mItems;
|
|
private float mLastMotionX;
|
|
private float mLastMotionY;
|
|
private float mLastOffset;
|
|
private EdgeEffect mLeftEdge;
|
|
private Drawable mMarginDrawable;
|
|
private int mMaximumVelocity;
|
|
private int mMinimumVelocity;
|
|
private boolean mNeedCalculatePageOffsets;
|
|
private PagerObserver mObserver;
|
|
private int mOffscreenPageLimit;
|
|
private OnPageChangeListener mOnPageChangeListener;
|
|
private List<OnPageChangeListener> mOnPageChangeListeners;
|
|
private int mPageMargin;
|
|
private PageTransformer mPageTransformer;
|
|
private int mPageTransformerLayerType;
|
|
private boolean mPopulatePending;
|
|
private Parcelable mRestoredAdapterState;
|
|
private ClassLoader mRestoredClassLoader;
|
|
private int mRestoredCurItem;
|
|
private EdgeEffect mRightEdge;
|
|
private int mScrollState;
|
|
private Scroller mScroller;
|
|
private boolean mScrollingCacheEnabled;
|
|
private final ItemInfo mTempItem;
|
|
private final Rect mTempRect;
|
|
private int mTopPageBounds;
|
|
private int mTouchSlop;
|
|
private VelocityTracker mVelocityTracker;
|
|
static final int[] LAYOUT_ATTRS = {R.attr.layout_gravity};
|
|
private static final Comparator<ItemInfo> COMPARATOR = new Comparator<ItemInfo>() { // from class: androidx.viewpager.widget.ViewPager.1
|
|
@Override // java.util.Comparator
|
|
public int compare(ItemInfo itemInfo, ItemInfo itemInfo2) {
|
|
return itemInfo.position - itemInfo2.position;
|
|
}
|
|
};
|
|
private static final Interpolator sInterpolator = new Interpolator() { // from class: androidx.viewpager.widget.ViewPager.2
|
|
@Override // android.animation.TimeInterpolator
|
|
public float getInterpolation(float f) {
|
|
float f2 = f - 1.0f;
|
|
return (f2 * f2 * f2 * f2 * f2) + 1.0f;
|
|
}
|
|
};
|
|
private static final ViewPositionComparator sPositionComparator = new ViewPositionComparator();
|
|
|
|
@Target({ElementType.TYPE})
|
|
@Inherited
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
/* loaded from: classes2.dex */
|
|
public @interface DecorView {
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface OnAdapterChangeListener {
|
|
void onAdapterChanged(ViewPager viewPager, PagerAdapter pagerAdapter, PagerAdapter pagerAdapter2);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface OnPageChangeListener {
|
|
void onPageScrollStateChanged(int i);
|
|
|
|
void onPageScrolled(int i, float f, int i2);
|
|
|
|
void onPageSelected(int i);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface PageTransformer {
|
|
void transformPage(View view, float f);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class SimpleOnPageChangeListener implements OnPageChangeListener {
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageScrollStateChanged(int i) {
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageScrolled(int i, float f, int i2) {
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageSelected(int i) {
|
|
}
|
|
}
|
|
|
|
private void setScrollingCacheEnabled(boolean z) {
|
|
if (this.mScrollingCacheEnabled != z) {
|
|
this.mScrollingCacheEnabled = z;
|
|
}
|
|
}
|
|
|
|
public PagerAdapter getAdapter() {
|
|
return this.mAdapter;
|
|
}
|
|
|
|
public int getCurrentItem() {
|
|
return this.mCurItem;
|
|
}
|
|
|
|
public int getOffscreenPageLimit() {
|
|
return this.mOffscreenPageLimit;
|
|
}
|
|
|
|
public int getPageMargin() {
|
|
return this.mPageMargin;
|
|
}
|
|
|
|
public boolean isFakeDragging() {
|
|
return this.mFakeDragging;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public OnPageChangeListener setInternalPageChangeListener(OnPageChangeListener onPageChangeListener) {
|
|
OnPageChangeListener onPageChangeListener2 = this.mInternalPageChangeListener;
|
|
this.mInternalPageChangeListener = onPageChangeListener;
|
|
return onPageChangeListener2;
|
|
}
|
|
|
|
@Deprecated
|
|
public void setOnPageChangeListener(OnPageChangeListener onPageChangeListener) {
|
|
this.mOnPageChangeListener = onPageChangeListener;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class ItemInfo {
|
|
Object object;
|
|
float offset;
|
|
int position;
|
|
boolean scrolling;
|
|
float widthFactor;
|
|
|
|
ItemInfo() {
|
|
}
|
|
}
|
|
|
|
public ViewPager(Context context) {
|
|
super(context);
|
|
this.mItems = new ArrayList<>();
|
|
this.mTempItem = new ItemInfo();
|
|
this.mTempRect = new Rect();
|
|
this.mRestoredCurItem = -1;
|
|
this.mRestoredAdapterState = null;
|
|
this.mRestoredClassLoader = null;
|
|
this.mFirstOffset = -3.4028235E38f;
|
|
this.mLastOffset = Float.MAX_VALUE;
|
|
this.mOffscreenPageLimit = 1;
|
|
this.mActivePointerId = -1;
|
|
this.mFirstLayout = true;
|
|
this.mNeedCalculatePageOffsets = false;
|
|
this.mEndScrollRunnable = new Runnable() { // from class: androidx.viewpager.widget.ViewPager.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ViewPager.this.setScrollState(0);
|
|
ViewPager.this.populate();
|
|
}
|
|
};
|
|
this.mScrollState = 0;
|
|
initViewPager();
|
|
}
|
|
|
|
public ViewPager(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.mItems = new ArrayList<>();
|
|
this.mTempItem = new ItemInfo();
|
|
this.mTempRect = new Rect();
|
|
this.mRestoredCurItem = -1;
|
|
this.mRestoredAdapterState = null;
|
|
this.mRestoredClassLoader = null;
|
|
this.mFirstOffset = -3.4028235E38f;
|
|
this.mLastOffset = Float.MAX_VALUE;
|
|
this.mOffscreenPageLimit = 1;
|
|
this.mActivePointerId = -1;
|
|
this.mFirstLayout = true;
|
|
this.mNeedCalculatePageOffsets = false;
|
|
this.mEndScrollRunnable = new Runnable() { // from class: androidx.viewpager.widget.ViewPager.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ViewPager.this.setScrollState(0);
|
|
ViewPager.this.populate();
|
|
}
|
|
};
|
|
this.mScrollState = 0;
|
|
initViewPager();
|
|
}
|
|
|
|
void initViewPager() {
|
|
setWillNotDraw(false);
|
|
setDescendantFocusability(262144);
|
|
setFocusable(true);
|
|
Context context = getContext();
|
|
this.mScroller = new Scroller(context, sInterpolator);
|
|
ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
|
|
float f = context.getResources().getDisplayMetrics().density;
|
|
this.mTouchSlop = viewConfiguration.getScaledPagingTouchSlop();
|
|
this.mMinimumVelocity = (int) (400.0f * f);
|
|
this.mMaximumVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
|
|
this.mLeftEdge = new EdgeEffect(context);
|
|
this.mRightEdge = new EdgeEffect(context);
|
|
this.mFlingDistance = (int) (25.0f * f);
|
|
this.mCloseEnough = (int) (2.0f * f);
|
|
this.mDefaultGutterSize = (int) (f * 16.0f);
|
|
ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
|
|
if (ViewCompat.getImportantForAccessibility(this) == 0) {
|
|
ViewCompat.setImportantForAccessibility(this, 1);
|
|
}
|
|
ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() { // from class: androidx.viewpager.widget.ViewPager.4
|
|
private final Rect mTempRect = new Rect();
|
|
|
|
@Override // androidx.core.view.OnApplyWindowInsetsListener
|
|
public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) {
|
|
WindowInsetsCompat onApplyWindowInsets = ViewCompat.onApplyWindowInsets(view, windowInsetsCompat);
|
|
if (onApplyWindowInsets.isConsumed()) {
|
|
return onApplyWindowInsets;
|
|
}
|
|
Rect rect = this.mTempRect;
|
|
rect.left = onApplyWindowInsets.getSystemWindowInsetLeft();
|
|
rect.top = onApplyWindowInsets.getSystemWindowInsetTop();
|
|
rect.right = onApplyWindowInsets.getSystemWindowInsetRight();
|
|
rect.bottom = onApplyWindowInsets.getSystemWindowInsetBottom();
|
|
int childCount = ViewPager.this.getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
WindowInsetsCompat dispatchApplyWindowInsets = ViewCompat.dispatchApplyWindowInsets(ViewPager.this.getChildAt(i), onApplyWindowInsets);
|
|
rect.left = Math.min(dispatchApplyWindowInsets.getSystemWindowInsetLeft(), rect.left);
|
|
rect.top = Math.min(dispatchApplyWindowInsets.getSystemWindowInsetTop(), rect.top);
|
|
rect.right = Math.min(dispatchApplyWindowInsets.getSystemWindowInsetRight(), rect.right);
|
|
rect.bottom = Math.min(dispatchApplyWindowInsets.getSystemWindowInsetBottom(), rect.bottom);
|
|
}
|
|
return onApplyWindowInsets.replaceSystemWindowInsets(rect.left, rect.top, rect.right, rect.bottom);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onDetachedFromWindow() {
|
|
removeCallbacks(this.mEndScrollRunnable);
|
|
Scroller scroller = this.mScroller;
|
|
if (scroller != null && !scroller.isFinished()) {
|
|
this.mScroller.abortAnimation();
|
|
}
|
|
super.onDetachedFromWindow();
|
|
}
|
|
|
|
void setScrollState(int i) {
|
|
if (this.mScrollState == i) {
|
|
return;
|
|
}
|
|
this.mScrollState = i;
|
|
if (this.mPageTransformer != null) {
|
|
enableLayers(i != 0);
|
|
}
|
|
dispatchOnScrollStateChanged(i);
|
|
}
|
|
|
|
public void setAdapter(PagerAdapter pagerAdapter) {
|
|
PagerAdapter pagerAdapter2 = this.mAdapter;
|
|
if (pagerAdapter2 != null) {
|
|
pagerAdapter2.setViewPagerObserver(null);
|
|
this.mAdapter.startUpdate((ViewGroup) this);
|
|
for (int i = 0; i < this.mItems.size(); i++) {
|
|
ItemInfo itemInfo = this.mItems.get(i);
|
|
this.mAdapter.destroyItem((ViewGroup) this, itemInfo.position, itemInfo.object);
|
|
}
|
|
this.mAdapter.finishUpdate((ViewGroup) this);
|
|
this.mItems.clear();
|
|
removeNonDecorViews();
|
|
this.mCurItem = 0;
|
|
scrollTo(0, 0);
|
|
}
|
|
PagerAdapter pagerAdapter3 = this.mAdapter;
|
|
this.mAdapter = pagerAdapter;
|
|
this.mExpectedAdapterCount = 0;
|
|
if (pagerAdapter != null) {
|
|
if (this.mObserver == null) {
|
|
this.mObserver = new PagerObserver();
|
|
}
|
|
this.mAdapter.setViewPagerObserver(this.mObserver);
|
|
this.mPopulatePending = false;
|
|
boolean z = this.mFirstLayout;
|
|
this.mFirstLayout = true;
|
|
this.mExpectedAdapterCount = this.mAdapter.getCount();
|
|
if (this.mRestoredCurItem >= 0) {
|
|
this.mAdapter.restoreState(this.mRestoredAdapterState, this.mRestoredClassLoader);
|
|
setCurrentItemInternal(this.mRestoredCurItem, false, true);
|
|
this.mRestoredCurItem = -1;
|
|
this.mRestoredAdapterState = null;
|
|
this.mRestoredClassLoader = null;
|
|
} else if (!z) {
|
|
populate();
|
|
} else {
|
|
requestLayout();
|
|
}
|
|
}
|
|
List<OnAdapterChangeListener> list = this.mAdapterChangeListeners;
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
int size = this.mAdapterChangeListeners.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
this.mAdapterChangeListeners.get(i2).onAdapterChanged(this, pagerAdapter3, pagerAdapter);
|
|
}
|
|
}
|
|
|
|
private void removeNonDecorViews() {
|
|
int i = 0;
|
|
while (i < getChildCount()) {
|
|
if (!((LayoutParams) getChildAt(i).getLayoutParams()).isDecor) {
|
|
removeViewAt(i);
|
|
i--;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
public void addOnAdapterChangeListener(OnAdapterChangeListener onAdapterChangeListener) {
|
|
if (this.mAdapterChangeListeners == null) {
|
|
this.mAdapterChangeListeners = new ArrayList();
|
|
}
|
|
this.mAdapterChangeListeners.add(onAdapterChangeListener);
|
|
}
|
|
|
|
public void removeOnAdapterChangeListener(OnAdapterChangeListener onAdapterChangeListener) {
|
|
List<OnAdapterChangeListener> list = this.mAdapterChangeListeners;
|
|
if (list != null) {
|
|
list.remove(onAdapterChangeListener);
|
|
}
|
|
}
|
|
|
|
private int getClientWidth() {
|
|
return (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
|
|
}
|
|
|
|
public void setCurrentItem(int i) {
|
|
this.mPopulatePending = false;
|
|
setCurrentItemInternal(i, !this.mFirstLayout, false);
|
|
}
|
|
|
|
public void setCurrentItem(int i, boolean z) {
|
|
this.mPopulatePending = false;
|
|
setCurrentItemInternal(i, z, false);
|
|
}
|
|
|
|
void setCurrentItemInternal(int i, boolean z, boolean z2) {
|
|
setCurrentItemInternal(i, z, z2, 0);
|
|
}
|
|
|
|
void setCurrentItemInternal(int i, boolean z, boolean z2, int i2) {
|
|
PagerAdapter pagerAdapter = this.mAdapter;
|
|
if (pagerAdapter == null || pagerAdapter.getCount() <= 0) {
|
|
setScrollingCacheEnabled(false);
|
|
return;
|
|
}
|
|
if (!z2 && this.mCurItem == i && this.mItems.size() != 0) {
|
|
setScrollingCacheEnabled(false);
|
|
return;
|
|
}
|
|
if (i < 0) {
|
|
i = 0;
|
|
} else if (i >= this.mAdapter.getCount()) {
|
|
i = this.mAdapter.getCount() - 1;
|
|
}
|
|
int i3 = this.mOffscreenPageLimit;
|
|
int i4 = this.mCurItem;
|
|
if (i > i4 + i3 || i < i4 - i3) {
|
|
for (int i5 = 0; i5 < this.mItems.size(); i5++) {
|
|
this.mItems.get(i5).scrolling = true;
|
|
}
|
|
}
|
|
boolean z3 = this.mCurItem != i;
|
|
if (this.mFirstLayout) {
|
|
this.mCurItem = i;
|
|
if (z3) {
|
|
dispatchOnPageSelected(i);
|
|
}
|
|
requestLayout();
|
|
return;
|
|
}
|
|
populate(i);
|
|
scrollToItem(i, z, i2, z3);
|
|
}
|
|
|
|
private void scrollToItem(int i, boolean z, int i2, boolean z2) {
|
|
ItemInfo infoForPosition = infoForPosition(i);
|
|
int clientWidth = infoForPosition != null ? (int) (getClientWidth() * Math.max(this.mFirstOffset, Math.min(infoForPosition.offset, this.mLastOffset))) : 0;
|
|
if (z) {
|
|
smoothScrollTo(clientWidth, 0, i2);
|
|
if (z2) {
|
|
dispatchOnPageSelected(i);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (z2) {
|
|
dispatchOnPageSelected(i);
|
|
}
|
|
completeScroll(false);
|
|
scrollTo(clientWidth, 0);
|
|
pageScrolled(clientWidth);
|
|
}
|
|
|
|
public void addOnPageChangeListener(OnPageChangeListener onPageChangeListener) {
|
|
if (this.mOnPageChangeListeners == null) {
|
|
this.mOnPageChangeListeners = new ArrayList();
|
|
}
|
|
this.mOnPageChangeListeners.add(onPageChangeListener);
|
|
}
|
|
|
|
public void removeOnPageChangeListener(OnPageChangeListener onPageChangeListener) {
|
|
List<OnPageChangeListener> list = this.mOnPageChangeListeners;
|
|
if (list != null) {
|
|
list.remove(onPageChangeListener);
|
|
}
|
|
}
|
|
|
|
public void clearOnPageChangeListeners() {
|
|
List<OnPageChangeListener> list = this.mOnPageChangeListeners;
|
|
if (list != null) {
|
|
list.clear();
|
|
}
|
|
}
|
|
|
|
public void setPageTransformer(boolean z, PageTransformer pageTransformer) {
|
|
setPageTransformer(z, pageTransformer, 2);
|
|
}
|
|
|
|
public void setPageTransformer(boolean z, PageTransformer pageTransformer, int i) {
|
|
boolean z2 = pageTransformer != null;
|
|
boolean z3 = z2 != (this.mPageTransformer != null);
|
|
this.mPageTransformer = pageTransformer;
|
|
setChildrenDrawingOrderEnabled(z2);
|
|
if (z2) {
|
|
this.mDrawingOrder = z ? 2 : 1;
|
|
this.mPageTransformerLayerType = i;
|
|
} else {
|
|
this.mDrawingOrder = 0;
|
|
}
|
|
if (z3) {
|
|
populate();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected int getChildDrawingOrder(int i, int i2) {
|
|
if (this.mDrawingOrder == 2) {
|
|
i2 = (i - 1) - i2;
|
|
}
|
|
return ((LayoutParams) this.mDrawingOrderedChildren.get(i2).getLayoutParams()).childIndex;
|
|
}
|
|
|
|
public void setOffscreenPageLimit(int i) {
|
|
if (i < 1) {
|
|
Log.w(TAG, "Requested offscreen page limit " + i + " too small; defaulting to 1");
|
|
i = 1;
|
|
}
|
|
if (i != this.mOffscreenPageLimit) {
|
|
this.mOffscreenPageLimit = i;
|
|
populate();
|
|
}
|
|
}
|
|
|
|
public void setPageMargin(int i) {
|
|
int i2 = this.mPageMargin;
|
|
this.mPageMargin = i;
|
|
int width = getWidth();
|
|
recomputeScrollPosition(width, width, i, i2);
|
|
requestLayout();
|
|
}
|
|
|
|
public void setPageMarginDrawable(Drawable drawable) {
|
|
this.mMarginDrawable = drawable;
|
|
if (drawable != null) {
|
|
refreshDrawableState();
|
|
}
|
|
setWillNotDraw(drawable == null);
|
|
invalidate();
|
|
}
|
|
|
|
public void setPageMarginDrawable(int i) {
|
|
setPageMarginDrawable(ContextCompat.getDrawable(getContext(), i));
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected boolean verifyDrawable(Drawable drawable) {
|
|
return super.verifyDrawable(drawable) || drawable == this.mMarginDrawable;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void drawableStateChanged() {
|
|
super.drawableStateChanged();
|
|
Drawable drawable = this.mMarginDrawable;
|
|
if (drawable == null || !drawable.isStateful()) {
|
|
return;
|
|
}
|
|
drawable.setState(getDrawableState());
|
|
}
|
|
|
|
float distanceInfluenceForSnapDuration(float f) {
|
|
return (float) Math.sin((f - 0.5f) * 0.47123894f);
|
|
}
|
|
|
|
void smoothScrollTo(int i, int i2) {
|
|
smoothScrollTo(i, i2, 0);
|
|
}
|
|
|
|
void smoothScrollTo(int i, int i2, int i3) {
|
|
int scrollX;
|
|
int abs;
|
|
if (getChildCount() == 0) {
|
|
setScrollingCacheEnabled(false);
|
|
return;
|
|
}
|
|
Scroller scroller = this.mScroller;
|
|
if (scroller != null && !scroller.isFinished()) {
|
|
scrollX = this.mIsScrollStarted ? this.mScroller.getCurrX() : this.mScroller.getStartX();
|
|
this.mScroller.abortAnimation();
|
|
setScrollingCacheEnabled(false);
|
|
} else {
|
|
scrollX = getScrollX();
|
|
}
|
|
int i4 = scrollX;
|
|
int scrollY = getScrollY();
|
|
int i5 = i - i4;
|
|
int i6 = i2 - scrollY;
|
|
if (i5 == 0 && i6 == 0) {
|
|
completeScroll(false);
|
|
populate();
|
|
setScrollState(0);
|
|
return;
|
|
}
|
|
setScrollingCacheEnabled(true);
|
|
setScrollState(2);
|
|
int clientWidth = getClientWidth();
|
|
int i7 = clientWidth / 2;
|
|
float f = clientWidth;
|
|
float f2 = i7;
|
|
float distanceInfluenceForSnapDuration = f2 + (distanceInfluenceForSnapDuration(Math.min(1.0f, (Math.abs(i5) * 1.0f) / f)) * f2);
|
|
int abs2 = Math.abs(i3);
|
|
if (abs2 > 0) {
|
|
abs = Math.round(Math.abs(distanceInfluenceForSnapDuration / abs2) * 1000.0f) * 4;
|
|
} else {
|
|
abs = (int) (((Math.abs(i5) / ((f * this.mAdapter.getPageWidth(this.mCurItem)) + this.mPageMargin)) + 1.0f) * 100.0f);
|
|
}
|
|
int min = Math.min(abs, MAX_SETTLE_DURATION);
|
|
this.mIsScrollStarted = false;
|
|
this.mScroller.startScroll(i4, scrollY, i5, i6, min);
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
|
|
ItemInfo addNewItem(int i, int i2) {
|
|
ItemInfo itemInfo = new ItemInfo();
|
|
itemInfo.position = i;
|
|
itemInfo.object = this.mAdapter.instantiateItem((ViewGroup) this, i);
|
|
itemInfo.widthFactor = this.mAdapter.getPageWidth(i);
|
|
if (i2 < 0 || i2 >= this.mItems.size()) {
|
|
this.mItems.add(itemInfo);
|
|
} else {
|
|
this.mItems.add(i2, itemInfo);
|
|
}
|
|
return itemInfo;
|
|
}
|
|
|
|
void dataSetChanged() {
|
|
int count = this.mAdapter.getCount();
|
|
this.mExpectedAdapterCount = count;
|
|
boolean z = this.mItems.size() < (this.mOffscreenPageLimit * 2) + 1 && this.mItems.size() < count;
|
|
int i = this.mCurItem;
|
|
int i2 = 0;
|
|
boolean z2 = false;
|
|
while (i2 < this.mItems.size()) {
|
|
ItemInfo itemInfo = this.mItems.get(i2);
|
|
int itemPosition = this.mAdapter.getItemPosition(itemInfo.object);
|
|
if (itemPosition != -1) {
|
|
if (itemPosition == -2) {
|
|
this.mItems.remove(i2);
|
|
i2--;
|
|
if (!z2) {
|
|
this.mAdapter.startUpdate((ViewGroup) this);
|
|
z2 = true;
|
|
}
|
|
this.mAdapter.destroyItem((ViewGroup) this, itemInfo.position, itemInfo.object);
|
|
if (this.mCurItem == itemInfo.position) {
|
|
i = Math.max(0, Math.min(this.mCurItem, count - 1));
|
|
}
|
|
} else if (itemInfo.position != itemPosition) {
|
|
if (itemInfo.position == this.mCurItem) {
|
|
i = itemPosition;
|
|
}
|
|
itemInfo.position = itemPosition;
|
|
}
|
|
z = true;
|
|
}
|
|
i2++;
|
|
}
|
|
if (z2) {
|
|
this.mAdapter.finishUpdate((ViewGroup) this);
|
|
}
|
|
Collections.sort(this.mItems, COMPARATOR);
|
|
if (z) {
|
|
int childCount = getChildCount();
|
|
for (int i3 = 0; i3 < childCount; i3++) {
|
|
LayoutParams layoutParams = (LayoutParams) getChildAt(i3).getLayoutParams();
|
|
if (!layoutParams.isDecor) {
|
|
layoutParams.widthFactor = 0.0f;
|
|
}
|
|
}
|
|
setCurrentItemInternal(i, false, true);
|
|
requestLayout();
|
|
}
|
|
}
|
|
|
|
void populate() {
|
|
populate(this.mCurItem);
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:26:0x0064, code lost:
|
|
|
|
if (r8.position == r17.mCurItem) goto L29;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:27:0x006a, code lost:
|
|
|
|
r8 = null;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
void populate(int r18) {
|
|
/*
|
|
Method dump skipped, instructions count: 624
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.populate(int):void");
|
|
}
|
|
|
|
private void sortChildDrawingOrder() {
|
|
if (this.mDrawingOrder != 0) {
|
|
ArrayList<View> arrayList = this.mDrawingOrderedChildren;
|
|
if (arrayList == null) {
|
|
this.mDrawingOrderedChildren = new ArrayList<>();
|
|
} else {
|
|
arrayList.clear();
|
|
}
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
this.mDrawingOrderedChildren.add(getChildAt(i));
|
|
}
|
|
Collections.sort(this.mDrawingOrderedChildren, sPositionComparator);
|
|
}
|
|
}
|
|
|
|
private void calculatePageOffsets(ItemInfo itemInfo, int i, ItemInfo itemInfo2) {
|
|
ItemInfo itemInfo3;
|
|
ItemInfo itemInfo4;
|
|
int count = this.mAdapter.getCount();
|
|
int clientWidth = getClientWidth();
|
|
float f = clientWidth > 0 ? this.mPageMargin / clientWidth : 0.0f;
|
|
if (itemInfo2 != null) {
|
|
int i2 = itemInfo2.position;
|
|
if (i2 < itemInfo.position) {
|
|
float f2 = itemInfo2.offset + itemInfo2.widthFactor + f;
|
|
int i3 = i2 + 1;
|
|
int i4 = 0;
|
|
while (i3 <= itemInfo.position && i4 < this.mItems.size()) {
|
|
ItemInfo itemInfo5 = this.mItems.get(i4);
|
|
while (true) {
|
|
itemInfo4 = itemInfo5;
|
|
if (i3 <= itemInfo4.position || i4 >= this.mItems.size() - 1) {
|
|
break;
|
|
}
|
|
i4++;
|
|
itemInfo5 = this.mItems.get(i4);
|
|
}
|
|
while (i3 < itemInfo4.position) {
|
|
f2 += this.mAdapter.getPageWidth(i3) + f;
|
|
i3++;
|
|
}
|
|
itemInfo4.offset = f2;
|
|
f2 += itemInfo4.widthFactor + f;
|
|
i3++;
|
|
}
|
|
} else if (i2 > itemInfo.position) {
|
|
int size = this.mItems.size() - 1;
|
|
float f3 = itemInfo2.offset;
|
|
while (true) {
|
|
i2--;
|
|
if (i2 < itemInfo.position || size < 0) {
|
|
break;
|
|
}
|
|
ItemInfo itemInfo6 = this.mItems.get(size);
|
|
while (true) {
|
|
itemInfo3 = itemInfo6;
|
|
if (i2 >= itemInfo3.position || size <= 0) {
|
|
break;
|
|
}
|
|
size--;
|
|
itemInfo6 = this.mItems.get(size);
|
|
}
|
|
while (i2 > itemInfo3.position) {
|
|
f3 -= this.mAdapter.getPageWidth(i2) + f;
|
|
i2--;
|
|
}
|
|
f3 -= itemInfo3.widthFactor + f;
|
|
itemInfo3.offset = f3;
|
|
}
|
|
}
|
|
}
|
|
int size2 = this.mItems.size();
|
|
float f4 = itemInfo.offset;
|
|
int i5 = itemInfo.position - 1;
|
|
this.mFirstOffset = itemInfo.position == 0 ? itemInfo.offset : -3.4028235E38f;
|
|
int i6 = count - 1;
|
|
this.mLastOffset = itemInfo.position == i6 ? (itemInfo.offset + itemInfo.widthFactor) - 1.0f : Float.MAX_VALUE;
|
|
int i7 = i - 1;
|
|
while (i7 >= 0) {
|
|
ItemInfo itemInfo7 = this.mItems.get(i7);
|
|
while (i5 > itemInfo7.position) {
|
|
f4 -= this.mAdapter.getPageWidth(i5) + f;
|
|
i5--;
|
|
}
|
|
f4 -= itemInfo7.widthFactor + f;
|
|
itemInfo7.offset = f4;
|
|
if (itemInfo7.position == 0) {
|
|
this.mFirstOffset = f4;
|
|
}
|
|
i7--;
|
|
i5--;
|
|
}
|
|
float f5 = itemInfo.offset + itemInfo.widthFactor + f;
|
|
int i8 = itemInfo.position + 1;
|
|
int i9 = i + 1;
|
|
while (i9 < size2) {
|
|
ItemInfo itemInfo8 = this.mItems.get(i9);
|
|
while (i8 < itemInfo8.position) {
|
|
f5 += this.mAdapter.getPageWidth(i8) + f;
|
|
i8++;
|
|
}
|
|
if (itemInfo8.position == i6) {
|
|
this.mLastOffset = (itemInfo8.widthFactor + f5) - 1.0f;
|
|
}
|
|
itemInfo8.offset = f5;
|
|
f5 += itemInfo8.widthFactor + f;
|
|
i9++;
|
|
i8++;
|
|
}
|
|
this.mNeedCalculatePageOffsets = false;
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class SavedState extends AbsSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: androidx.viewpager.widget.ViewPager.SavedState.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.ClassLoaderCreator
|
|
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
|
|
return new SavedState(parcel, classLoader);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel, null);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
};
|
|
Parcelable adapterState;
|
|
ClassLoader loader;
|
|
int position;
|
|
|
|
public SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
|
|
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
super.writeToParcel(parcel, i);
|
|
parcel.writeInt(this.position);
|
|
parcel.writeParcelable(this.adapterState, i);
|
|
}
|
|
|
|
public String toString() {
|
|
return "FragmentPager.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " position=" + this.position + "}";
|
|
}
|
|
|
|
SavedState(Parcel parcel, ClassLoader classLoader) {
|
|
super(parcel, classLoader);
|
|
classLoader = classLoader == null ? getClass().getClassLoader() : classLoader;
|
|
this.position = parcel.readInt();
|
|
this.adapterState = parcel.readParcelable(classLoader);
|
|
this.loader = classLoader;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public Parcelable onSaveInstanceState() {
|
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
|
savedState.position = this.mCurItem;
|
|
PagerAdapter pagerAdapter = this.mAdapter;
|
|
if (pagerAdapter != null) {
|
|
savedState.adapterState = pagerAdapter.saveState();
|
|
}
|
|
return savedState;
|
|
}
|
|
|
|
@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());
|
|
PagerAdapter pagerAdapter = this.mAdapter;
|
|
if (pagerAdapter != null) {
|
|
pagerAdapter.restoreState(savedState.adapterState, savedState.loader);
|
|
setCurrentItemInternal(savedState.position, false, true);
|
|
} else {
|
|
this.mRestoredCurItem = savedState.position;
|
|
this.mRestoredAdapterState = savedState.adapterState;
|
|
this.mRestoredClassLoader = savedState.loader;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
|
if (!checkLayoutParams(layoutParams)) {
|
|
layoutParams = generateLayoutParams(layoutParams);
|
|
}
|
|
LayoutParams layoutParams2 = (LayoutParams) layoutParams;
|
|
layoutParams2.isDecor |= isDecorView(view);
|
|
if (this.mInLayout) {
|
|
if (layoutParams2 != null && layoutParams2.isDecor) {
|
|
throw new IllegalStateException("Cannot add pager decor view during layout");
|
|
}
|
|
layoutParams2.needsMeasure = true;
|
|
addViewInLayout(view, i, layoutParams);
|
|
return;
|
|
}
|
|
super.addView(view, i, layoutParams);
|
|
}
|
|
|
|
private static boolean isDecorView(View view) {
|
|
return view.getClass().getAnnotation(DecorView.class) != null;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewManager
|
|
public void removeView(View view) {
|
|
if (this.mInLayout) {
|
|
removeViewInLayout(view);
|
|
} else {
|
|
super.removeView(view);
|
|
}
|
|
}
|
|
|
|
ItemInfo infoForChild(View view) {
|
|
for (int i = 0; i < this.mItems.size(); i++) {
|
|
ItemInfo itemInfo = this.mItems.get(i);
|
|
if (this.mAdapter.isViewFromObject(view, itemInfo.object)) {
|
|
return itemInfo;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
ItemInfo infoForAnyChild(View view) {
|
|
while (true) {
|
|
Object parent = view.getParent();
|
|
if (parent != this) {
|
|
if (parent == null || !(parent instanceof View)) {
|
|
return null;
|
|
}
|
|
view = (View) parent;
|
|
} else {
|
|
return infoForChild(view);
|
|
}
|
|
}
|
|
}
|
|
|
|
ItemInfo infoForPosition(int i) {
|
|
for (int i2 = 0; i2 < this.mItems.size(); i2++) {
|
|
ItemInfo itemInfo = this.mItems.get(i2);
|
|
if (itemInfo.position == i) {
|
|
return itemInfo;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
this.mFirstLayout = true;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
LayoutParams layoutParams;
|
|
LayoutParams layoutParams2;
|
|
int i3;
|
|
int i4;
|
|
int i5;
|
|
int i6;
|
|
boolean z = false;
|
|
setMeasuredDimension(getDefaultSize(0, i), getDefaultSize(0, i2));
|
|
int measuredWidth = getMeasuredWidth();
|
|
this.mGutterSize = Math.min(measuredWidth / 10, this.mDefaultGutterSize);
|
|
int paddingLeft = (measuredWidth - getPaddingLeft()) - getPaddingRight();
|
|
int measuredHeight = (getMeasuredHeight() - getPaddingTop()) - getPaddingBottom();
|
|
int childCount = getChildCount();
|
|
int i7 = 0;
|
|
while (true) {
|
|
boolean z2 = true;
|
|
int i8 = 1073741824;
|
|
if (i7 >= childCount) {
|
|
break;
|
|
}
|
|
View childAt = getChildAt(i7);
|
|
if (childAt.getVisibility() != 8 && (layoutParams2 = (LayoutParams) childAt.getLayoutParams()) != null && layoutParams2.isDecor) {
|
|
int i9 = layoutParams2.gravity & 7;
|
|
int i10 = layoutParams2.gravity & 112;
|
|
boolean z3 = (i10 == 48 || i10 == 80) ? true : z;
|
|
if (i9 != 3 && i9 != 5) {
|
|
z2 = z;
|
|
}
|
|
int i11 = Integer.MIN_VALUE;
|
|
if (z3) {
|
|
i3 = Integer.MIN_VALUE;
|
|
i11 = 1073741824;
|
|
} else {
|
|
i3 = z2 ? 1073741824 : Integer.MIN_VALUE;
|
|
}
|
|
if (layoutParams2.width != -2) {
|
|
i5 = layoutParams2.width != -1 ? layoutParams2.width : paddingLeft;
|
|
i4 = 1073741824;
|
|
} else {
|
|
i4 = i11;
|
|
i5 = paddingLeft;
|
|
}
|
|
if (layoutParams2.height != -2) {
|
|
i6 = layoutParams2.height != -1 ? layoutParams2.height : measuredHeight;
|
|
} else {
|
|
i6 = measuredHeight;
|
|
i8 = i3;
|
|
}
|
|
childAt.measure(View.MeasureSpec.makeMeasureSpec(i5, i4), View.MeasureSpec.makeMeasureSpec(i6, i8));
|
|
if (z3) {
|
|
measuredHeight -= childAt.getMeasuredHeight();
|
|
} else if (z2) {
|
|
paddingLeft -= childAt.getMeasuredWidth();
|
|
}
|
|
}
|
|
i7++;
|
|
z = false;
|
|
}
|
|
this.mChildWidthMeasureSpec = View.MeasureSpec.makeMeasureSpec(paddingLeft, 1073741824);
|
|
this.mChildHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(measuredHeight, 1073741824);
|
|
this.mInLayout = true;
|
|
populate();
|
|
this.mInLayout = false;
|
|
int childCount2 = getChildCount();
|
|
for (int i12 = 0; i12 < childCount2; i12++) {
|
|
View childAt2 = getChildAt(i12);
|
|
if (childAt2.getVisibility() != 8 && ((layoutParams = (LayoutParams) childAt2.getLayoutParams()) == null || !layoutParams.isDecor)) {
|
|
childAt2.measure(View.MeasureSpec.makeMeasureSpec((int) (paddingLeft * layoutParams.widthFactor), 1073741824), this.mChildHeightMeasureSpec);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
if (i != i3) {
|
|
int i5 = this.mPageMargin;
|
|
recomputeScrollPosition(i, i3, i5, i5);
|
|
}
|
|
}
|
|
|
|
private void recomputeScrollPosition(int i, int i2, int i3, int i4) {
|
|
if (i2 > 0 && !this.mItems.isEmpty()) {
|
|
if (!this.mScroller.isFinished()) {
|
|
this.mScroller.setFinalX(getCurrentItem() * getClientWidth());
|
|
return;
|
|
} else {
|
|
scrollTo((int) ((getScrollX() / (((i2 - getPaddingLeft()) - getPaddingRight()) + i4)) * (((i - getPaddingLeft()) - getPaddingRight()) + i3)), getScrollY());
|
|
return;
|
|
}
|
|
}
|
|
ItemInfo infoForPosition = infoForPosition(this.mCurItem);
|
|
int min = (int) ((infoForPosition != null ? Math.min(infoForPosition.offset, this.mLastOffset) : 0.0f) * ((i - getPaddingLeft()) - getPaddingRight()));
|
|
if (min != getScrollX()) {
|
|
completeScroll(false);
|
|
scrollTo(min, getScrollY());
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:17:0x0073 */
|
|
/* JADX WARN: Removed duplicated region for block: B:28:0x0090 */
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
protected void onLayout(boolean r19, int r20, int r21, int r22, int r23) {
|
|
/*
|
|
Method dump skipped, instructions count: 286
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.onLayout(boolean, int, int, int, int):void");
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void computeScroll() {
|
|
this.mIsScrollStarted = true;
|
|
if (!this.mScroller.isFinished() && this.mScroller.computeScrollOffset()) {
|
|
int scrollX = getScrollX();
|
|
int scrollY = getScrollY();
|
|
int currX = this.mScroller.getCurrX();
|
|
int currY = this.mScroller.getCurrY();
|
|
if (scrollX != currX || scrollY != currY) {
|
|
scrollTo(currX, currY);
|
|
if (!pageScrolled(currX)) {
|
|
this.mScroller.abortAnimation();
|
|
scrollTo(0, currY);
|
|
}
|
|
}
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
return;
|
|
}
|
|
completeScroll(true);
|
|
}
|
|
|
|
private boolean pageScrolled(int i) {
|
|
if (this.mItems.size() == 0) {
|
|
if (this.mFirstLayout) {
|
|
return false;
|
|
}
|
|
this.mCalledSuper = false;
|
|
onPageScrolled(0, 0.0f, 0);
|
|
if (this.mCalledSuper) {
|
|
return false;
|
|
}
|
|
throw new IllegalStateException("onPageScrolled did not call superclass implementation");
|
|
}
|
|
ItemInfo infoForCurrentScrollPosition = infoForCurrentScrollPosition();
|
|
int clientWidth = getClientWidth();
|
|
int i2 = this.mPageMargin;
|
|
int i3 = clientWidth + i2;
|
|
float f = clientWidth;
|
|
int i4 = infoForCurrentScrollPosition.position;
|
|
float f2 = ((i / f) - infoForCurrentScrollPosition.offset) / (infoForCurrentScrollPosition.widthFactor + (i2 / f));
|
|
this.mCalledSuper = false;
|
|
onPageScrolled(i4, f2, (int) (i3 * f2));
|
|
if (this.mCalledSuper) {
|
|
return true;
|
|
}
|
|
throw new IllegalStateException("onPageScrolled did not call superclass implementation");
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:16:0x0064 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
protected void onPageScrolled(int r13, float r14, int r15) {
|
|
/*
|
|
r12 = this;
|
|
int r0 = r12.mDecorChildCount
|
|
r1 = 0
|
|
r2 = 1
|
|
if (r0 <= 0) goto L6b
|
|
int r0 = r12.getScrollX()
|
|
int r3 = r12.getPaddingLeft()
|
|
int r4 = r12.getPaddingRight()
|
|
int r5 = r12.getWidth()
|
|
int r6 = r12.getChildCount()
|
|
r7 = r1
|
|
L1b:
|
|
if (r7 >= r6) goto L6b
|
|
android.view.View r8 = r12.getChildAt(r7)
|
|
android.view.ViewGroup$LayoutParams r9 = r8.getLayoutParams()
|
|
androidx.viewpager.widget.ViewPager$LayoutParams r9 = (androidx.viewpager.widget.ViewPager.LayoutParams) r9
|
|
boolean r10 = r9.isDecor
|
|
if (r10 != 0) goto L2c
|
|
goto L68
|
|
L2c:
|
|
int r9 = r9.gravity
|
|
r9 = r9 & 7
|
|
if (r9 == r2) goto L4d
|
|
r10 = 3
|
|
if (r9 == r10) goto L47
|
|
r10 = 5
|
|
if (r9 == r10) goto L3a
|
|
r9 = r3
|
|
goto L5c
|
|
L3a:
|
|
int r9 = r5 - r4
|
|
int r10 = r8.getMeasuredWidth()
|
|
int r9 = r9 - r10
|
|
int r10 = r8.getMeasuredWidth()
|
|
int r4 = r4 + r10
|
|
goto L59
|
|
L47:
|
|
int r9 = r8.getWidth()
|
|
int r9 = r9 + r3
|
|
goto L5c
|
|
L4d:
|
|
int r9 = r8.getMeasuredWidth()
|
|
int r9 = r5 - r9
|
|
int r9 = r9 / 2
|
|
int r9 = java.lang.Math.max(r9, r3)
|
|
L59:
|
|
r11 = r9
|
|
r9 = r3
|
|
r3 = r11
|
|
L5c:
|
|
int r3 = r3 + r0
|
|
int r10 = r8.getLeft()
|
|
int r3 = r3 - r10
|
|
if (r3 == 0) goto L67
|
|
r8.offsetLeftAndRight(r3)
|
|
L67:
|
|
r3 = r9
|
|
L68:
|
|
int r7 = r7 + 1
|
|
goto L1b
|
|
L6b:
|
|
r12.dispatchOnPageScrolled(r13, r14, r15)
|
|
androidx.viewpager.widget.ViewPager$PageTransformer r13 = r12.mPageTransformer
|
|
if (r13 == 0) goto L9f
|
|
int r13 = r12.getScrollX()
|
|
int r14 = r12.getChildCount()
|
|
L7a:
|
|
if (r1 >= r14) goto L9f
|
|
android.view.View r15 = r12.getChildAt(r1)
|
|
android.view.ViewGroup$LayoutParams r0 = r15.getLayoutParams()
|
|
androidx.viewpager.widget.ViewPager$LayoutParams r0 = (androidx.viewpager.widget.ViewPager.LayoutParams) r0
|
|
boolean r0 = r0.isDecor
|
|
if (r0 == 0) goto L8b
|
|
goto L9c
|
|
L8b:
|
|
int r0 = r15.getLeft()
|
|
int r0 = r0 - r13
|
|
float r0 = (float) r0
|
|
int r3 = r12.getClientWidth()
|
|
float r3 = (float) r3
|
|
float r0 = r0 / r3
|
|
androidx.viewpager.widget.ViewPager$PageTransformer r3 = r12.mPageTransformer
|
|
r3.transformPage(r15, r0)
|
|
L9c:
|
|
int r1 = r1 + 1
|
|
goto L7a
|
|
L9f:
|
|
r12.mCalledSuper = r2
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.onPageScrolled(int, float, int):void");
|
|
}
|
|
|
|
private void dispatchOnPageScrolled(int i, float f, int i2) {
|
|
OnPageChangeListener onPageChangeListener = this.mOnPageChangeListener;
|
|
if (onPageChangeListener != null) {
|
|
onPageChangeListener.onPageScrolled(i, f, i2);
|
|
}
|
|
List<OnPageChangeListener> list = this.mOnPageChangeListeners;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
OnPageChangeListener onPageChangeListener2 = this.mOnPageChangeListeners.get(i3);
|
|
if (onPageChangeListener2 != null) {
|
|
onPageChangeListener2.onPageScrolled(i, f, i2);
|
|
}
|
|
}
|
|
}
|
|
OnPageChangeListener onPageChangeListener3 = this.mInternalPageChangeListener;
|
|
if (onPageChangeListener3 != null) {
|
|
onPageChangeListener3.onPageScrolled(i, f, i2);
|
|
}
|
|
}
|
|
|
|
private void dispatchOnPageSelected(int i) {
|
|
OnPageChangeListener onPageChangeListener = this.mOnPageChangeListener;
|
|
if (onPageChangeListener != null) {
|
|
onPageChangeListener.onPageSelected(i);
|
|
}
|
|
List<OnPageChangeListener> list = this.mOnPageChangeListeners;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
OnPageChangeListener onPageChangeListener2 = this.mOnPageChangeListeners.get(i2);
|
|
if (onPageChangeListener2 != null) {
|
|
onPageChangeListener2.onPageSelected(i);
|
|
}
|
|
}
|
|
}
|
|
OnPageChangeListener onPageChangeListener3 = this.mInternalPageChangeListener;
|
|
if (onPageChangeListener3 != null) {
|
|
onPageChangeListener3.onPageSelected(i);
|
|
}
|
|
}
|
|
|
|
private void dispatchOnScrollStateChanged(int i) {
|
|
OnPageChangeListener onPageChangeListener = this.mOnPageChangeListener;
|
|
if (onPageChangeListener != null) {
|
|
onPageChangeListener.onPageScrollStateChanged(i);
|
|
}
|
|
List<OnPageChangeListener> list = this.mOnPageChangeListeners;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
OnPageChangeListener onPageChangeListener2 = this.mOnPageChangeListeners.get(i2);
|
|
if (onPageChangeListener2 != null) {
|
|
onPageChangeListener2.onPageScrollStateChanged(i);
|
|
}
|
|
}
|
|
}
|
|
OnPageChangeListener onPageChangeListener3 = this.mInternalPageChangeListener;
|
|
if (onPageChangeListener3 != null) {
|
|
onPageChangeListener3.onPageScrollStateChanged(i);
|
|
}
|
|
}
|
|
|
|
private void completeScroll(boolean z) {
|
|
boolean z2 = this.mScrollState == 2;
|
|
if (z2) {
|
|
setScrollingCacheEnabled(false);
|
|
if (!this.mScroller.isFinished()) {
|
|
this.mScroller.abortAnimation();
|
|
int scrollX = getScrollX();
|
|
int scrollY = getScrollY();
|
|
int currX = this.mScroller.getCurrX();
|
|
int currY = this.mScroller.getCurrY();
|
|
if (scrollX != currX || scrollY != currY) {
|
|
scrollTo(currX, currY);
|
|
if (currX != scrollX) {
|
|
pageScrolled(currX);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.mPopulatePending = false;
|
|
for (int i = 0; i < this.mItems.size(); i++) {
|
|
ItemInfo itemInfo = this.mItems.get(i);
|
|
if (itemInfo.scrolling) {
|
|
itemInfo.scrolling = false;
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (z2) {
|
|
if (z) {
|
|
ViewCompat.postOnAnimation(this, this.mEndScrollRunnable);
|
|
} else {
|
|
this.mEndScrollRunnable.run();
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean isGutterDrag(float f, float f2) {
|
|
return (f < ((float) this.mGutterSize) && f2 > 0.0f) || (f > ((float) (getWidth() - this.mGutterSize)) && f2 < 0.0f);
|
|
}
|
|
|
|
private void enableLayers(boolean z) {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
getChildAt(i).setLayerType(z ? this.mPageTransformerLayerType : 0, null);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
|
int action = motionEvent.getAction() & 255;
|
|
if (action == 3 || action == 1) {
|
|
resetTouch();
|
|
return false;
|
|
}
|
|
if (action != 0) {
|
|
if (this.mIsBeingDragged) {
|
|
return true;
|
|
}
|
|
if (this.mIsUnableToDrag) {
|
|
return false;
|
|
}
|
|
}
|
|
if (action == 0) {
|
|
float x = motionEvent.getX();
|
|
this.mInitialMotionX = x;
|
|
this.mLastMotionX = x;
|
|
float y = motionEvent.getY();
|
|
this.mInitialMotionY = y;
|
|
this.mLastMotionY = y;
|
|
this.mActivePointerId = motionEvent.getPointerId(0);
|
|
this.mIsUnableToDrag = false;
|
|
this.mIsScrollStarted = true;
|
|
this.mScroller.computeScrollOffset();
|
|
if (this.mScrollState == 2 && Math.abs(this.mScroller.getFinalX() - this.mScroller.getCurrX()) > this.mCloseEnough) {
|
|
this.mScroller.abortAnimation();
|
|
this.mPopulatePending = false;
|
|
populate();
|
|
this.mIsBeingDragged = true;
|
|
requestParentDisallowInterceptTouchEvent(true);
|
|
setScrollState(1);
|
|
} else {
|
|
completeScroll(false);
|
|
this.mIsBeingDragged = false;
|
|
}
|
|
} else if (action == 2) {
|
|
int i = this.mActivePointerId;
|
|
if (i != -1) {
|
|
int findPointerIndex = motionEvent.findPointerIndex(i);
|
|
float x2 = motionEvent.getX(findPointerIndex);
|
|
float f = x2 - this.mLastMotionX;
|
|
float abs = Math.abs(f);
|
|
float y2 = motionEvent.getY(findPointerIndex);
|
|
float abs2 = Math.abs(y2 - this.mInitialMotionY);
|
|
if (f != 0.0f && !isGutterDrag(this.mLastMotionX, f) && canScroll(this, false, (int) f, (int) x2, (int) y2)) {
|
|
this.mLastMotionX = x2;
|
|
this.mLastMotionY = y2;
|
|
this.mIsUnableToDrag = true;
|
|
return false;
|
|
}
|
|
int i2 = this.mTouchSlop;
|
|
if (abs > i2 && abs * 0.5f > abs2) {
|
|
this.mIsBeingDragged = true;
|
|
requestParentDisallowInterceptTouchEvent(true);
|
|
setScrollState(1);
|
|
float f2 = this.mInitialMotionX;
|
|
float f3 = this.mTouchSlop;
|
|
this.mLastMotionX = f > 0.0f ? f2 + f3 : f2 - f3;
|
|
this.mLastMotionY = y2;
|
|
setScrollingCacheEnabled(true);
|
|
} else if (abs2 > i2) {
|
|
this.mIsUnableToDrag = true;
|
|
}
|
|
if (this.mIsBeingDragged && performDrag(x2)) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
}
|
|
} else if (action == 6) {
|
|
onSecondaryPointerUp(motionEvent);
|
|
}
|
|
if (this.mVelocityTracker == null) {
|
|
this.mVelocityTracker = VelocityTracker.obtain();
|
|
}
|
|
this.mVelocityTracker.addMovement(motionEvent);
|
|
return this.mIsBeingDragged;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:35:0x0139 */
|
|
@Override // android.view.View
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public boolean onTouchEvent(android.view.MotionEvent r8) {
|
|
/*
|
|
Method dump skipped, instructions count: 351
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.onTouchEvent(android.view.MotionEvent):boolean");
|
|
}
|
|
|
|
private boolean resetTouch() {
|
|
this.mActivePointerId = -1;
|
|
endDrag();
|
|
this.mLeftEdge.onRelease();
|
|
this.mRightEdge.onRelease();
|
|
return this.mLeftEdge.isFinished() || this.mRightEdge.isFinished();
|
|
}
|
|
|
|
private void requestParentDisallowInterceptTouchEvent(boolean z) {
|
|
ViewParent parent = getParent();
|
|
if (parent != null) {
|
|
parent.requestDisallowInterceptTouchEvent(z);
|
|
}
|
|
}
|
|
|
|
private boolean performDrag(float f) {
|
|
boolean z;
|
|
boolean z2;
|
|
float f2 = this.mLastMotionX - f;
|
|
this.mLastMotionX = f;
|
|
float scrollX = getScrollX() + f2;
|
|
float clientWidth = getClientWidth();
|
|
float f3 = this.mFirstOffset * clientWidth;
|
|
float f4 = this.mLastOffset * clientWidth;
|
|
boolean z3 = false;
|
|
ItemInfo itemInfo = this.mItems.get(0);
|
|
ArrayList<ItemInfo> arrayList = this.mItems;
|
|
ItemInfo itemInfo2 = arrayList.get(arrayList.size() - 1);
|
|
if (itemInfo.position != 0) {
|
|
f3 = itemInfo.offset * clientWidth;
|
|
z = false;
|
|
} else {
|
|
z = true;
|
|
}
|
|
if (itemInfo2.position != this.mAdapter.getCount() - 1) {
|
|
f4 = itemInfo2.offset * clientWidth;
|
|
z2 = false;
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
if (scrollX < f3) {
|
|
if (z) {
|
|
this.mLeftEdge.onPull(Math.abs(f3 - scrollX) / clientWidth);
|
|
z3 = true;
|
|
}
|
|
scrollX = f3;
|
|
} else if (scrollX > f4) {
|
|
if (z2) {
|
|
this.mRightEdge.onPull(Math.abs(scrollX - f4) / clientWidth);
|
|
z3 = true;
|
|
}
|
|
scrollX = f4;
|
|
}
|
|
int i = (int) scrollX;
|
|
this.mLastMotionX += scrollX - i;
|
|
scrollTo(i, getScrollY());
|
|
pageScrolled(i);
|
|
return z3;
|
|
}
|
|
|
|
private ItemInfo infoForCurrentScrollPosition() {
|
|
int i;
|
|
int clientWidth = getClientWidth();
|
|
float f = 0.0f;
|
|
float scrollX = clientWidth > 0 ? getScrollX() / clientWidth : 0.0f;
|
|
float f2 = clientWidth > 0 ? this.mPageMargin / clientWidth : 0.0f;
|
|
int i2 = 0;
|
|
boolean z = true;
|
|
ItemInfo itemInfo = null;
|
|
int i3 = -1;
|
|
float f3 = 0.0f;
|
|
while (i2 < this.mItems.size()) {
|
|
ItemInfo itemInfo2 = this.mItems.get(i2);
|
|
if (!z && itemInfo2.position != (i = i3 + 1)) {
|
|
itemInfo2 = this.mTempItem;
|
|
itemInfo2.offset = f + f3 + f2;
|
|
itemInfo2.position = i;
|
|
itemInfo2.widthFactor = this.mAdapter.getPageWidth(itemInfo2.position);
|
|
i2--;
|
|
}
|
|
ItemInfo itemInfo3 = itemInfo2;
|
|
f = itemInfo3.offset;
|
|
float f4 = itemInfo3.widthFactor + f + f2;
|
|
if (!z && scrollX < f) {
|
|
return itemInfo;
|
|
}
|
|
if (scrollX < f4 || i2 == this.mItems.size() - 1) {
|
|
return itemInfo3;
|
|
}
|
|
int i4 = itemInfo3.position;
|
|
float f5 = itemInfo3.widthFactor;
|
|
i2++;
|
|
z = false;
|
|
i3 = i4;
|
|
f3 = f5;
|
|
itemInfo = itemInfo3;
|
|
}
|
|
return itemInfo;
|
|
}
|
|
|
|
private int determineTargetPage(int i, float f, int i2, int i3) {
|
|
if (Math.abs(i3) <= this.mFlingDistance || Math.abs(i2) <= this.mMinimumVelocity) {
|
|
i += (int) (f + (i >= this.mCurItem ? 0.4f : 0.6f));
|
|
} else if (i2 <= 0) {
|
|
i++;
|
|
}
|
|
if (this.mItems.size() <= 0) {
|
|
return i;
|
|
}
|
|
return Math.max(this.mItems.get(0).position, Math.min(i, this.mItems.get(r1.size() - 1).position));
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void draw(Canvas canvas) {
|
|
boolean z;
|
|
PagerAdapter pagerAdapter;
|
|
super.draw(canvas);
|
|
int overScrollMode = getOverScrollMode();
|
|
if (overScrollMode == 0 || (overScrollMode == 1 && (pagerAdapter = this.mAdapter) != null && pagerAdapter.getCount() > 1)) {
|
|
if (this.mLeftEdge.isFinished()) {
|
|
z = false;
|
|
} else {
|
|
int save = canvas.save();
|
|
int height = (getHeight() - getPaddingTop()) - getPaddingBottom();
|
|
int width = getWidth();
|
|
canvas.rotate(270.0f);
|
|
canvas.translate((-height) + getPaddingTop(), this.mFirstOffset * width);
|
|
this.mLeftEdge.setSize(height, width);
|
|
z = this.mLeftEdge.draw(canvas);
|
|
canvas.restoreToCount(save);
|
|
}
|
|
if (!this.mRightEdge.isFinished()) {
|
|
int save2 = canvas.save();
|
|
int width2 = getWidth();
|
|
int height2 = (getHeight() - getPaddingTop()) - getPaddingBottom();
|
|
canvas.rotate(90.0f);
|
|
canvas.translate(-getPaddingTop(), (-(this.mLastOffset + 1.0f)) * width2);
|
|
this.mRightEdge.setSize(height2, width2);
|
|
z |= this.mRightEdge.draw(canvas);
|
|
canvas.restoreToCount(save2);
|
|
}
|
|
if (z) {
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.mLeftEdge.finish();
|
|
this.mRightEdge.finish();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onDraw(Canvas canvas) {
|
|
float f;
|
|
float f2;
|
|
float f3;
|
|
super.onDraw(canvas);
|
|
if (this.mPageMargin <= 0 || this.mMarginDrawable == null || this.mItems.size() <= 0 || this.mAdapter == null) {
|
|
return;
|
|
}
|
|
int scrollX = getScrollX();
|
|
float width = getWidth();
|
|
float f4 = this.mPageMargin / width;
|
|
int i = 0;
|
|
ItemInfo itemInfo = this.mItems.get(0);
|
|
float f5 = itemInfo.offset;
|
|
int size = this.mItems.size();
|
|
int i2 = itemInfo.position;
|
|
int i3 = this.mItems.get(size - 1).position;
|
|
while (i2 < i3) {
|
|
while (i2 > itemInfo.position && i < size) {
|
|
i++;
|
|
itemInfo = this.mItems.get(i);
|
|
}
|
|
if (i2 == itemInfo.position) {
|
|
f2 = (itemInfo.offset + itemInfo.widthFactor) * width;
|
|
f = itemInfo.offset + itemInfo.widthFactor + f4;
|
|
} else {
|
|
float pageWidth = this.mAdapter.getPageWidth(i2);
|
|
float f6 = (f5 + pageWidth) * width;
|
|
f = f5 + pageWidth + f4;
|
|
f2 = f6;
|
|
}
|
|
if (this.mPageMargin + f2 > scrollX) {
|
|
f3 = f4;
|
|
this.mMarginDrawable.setBounds(Math.round(f2), this.mTopPageBounds, Math.round(this.mPageMargin + f2), this.mBottomPageBounds);
|
|
this.mMarginDrawable.draw(canvas);
|
|
} else {
|
|
f3 = f4;
|
|
}
|
|
if (f2 > scrollX + r2) {
|
|
return;
|
|
}
|
|
i2++;
|
|
f5 = f;
|
|
f4 = f3;
|
|
}
|
|
}
|
|
|
|
public boolean beginFakeDrag() {
|
|
if (this.mIsBeingDragged) {
|
|
return false;
|
|
}
|
|
this.mFakeDragging = true;
|
|
setScrollState(1);
|
|
this.mLastMotionX = 0.0f;
|
|
this.mInitialMotionX = 0.0f;
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker == null) {
|
|
this.mVelocityTracker = VelocityTracker.obtain();
|
|
} else {
|
|
velocityTracker.clear();
|
|
}
|
|
long uptimeMillis = SystemClock.uptimeMillis();
|
|
MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 0, 0.0f, 0.0f, 0);
|
|
this.mVelocityTracker.addMovement(obtain);
|
|
obtain.recycle();
|
|
this.mFakeDragBeginTime = uptimeMillis;
|
|
return true;
|
|
}
|
|
|
|
public void endFakeDrag() {
|
|
if (!this.mFakeDragging) {
|
|
throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
|
|
}
|
|
if (this.mAdapter != null) {
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
velocityTracker.computeCurrentVelocity(1000, this.mMaximumVelocity);
|
|
int xVelocity = (int) velocityTracker.getXVelocity(this.mActivePointerId);
|
|
this.mPopulatePending = true;
|
|
int clientWidth = getClientWidth();
|
|
int scrollX = getScrollX();
|
|
ItemInfo infoForCurrentScrollPosition = infoForCurrentScrollPosition();
|
|
setCurrentItemInternal(determineTargetPage(infoForCurrentScrollPosition.position, ((scrollX / clientWidth) - infoForCurrentScrollPosition.offset) / infoForCurrentScrollPosition.widthFactor, xVelocity, (int) (this.mLastMotionX - this.mInitialMotionX)), true, true, xVelocity);
|
|
}
|
|
endDrag();
|
|
this.mFakeDragging = false;
|
|
}
|
|
|
|
public void fakeDragBy(float f) {
|
|
if (!this.mFakeDragging) {
|
|
throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
|
|
}
|
|
if (this.mAdapter == null) {
|
|
return;
|
|
}
|
|
this.mLastMotionX += f;
|
|
float scrollX = getScrollX() - f;
|
|
float clientWidth = getClientWidth();
|
|
float f2 = this.mFirstOffset * clientWidth;
|
|
float f3 = this.mLastOffset * clientWidth;
|
|
ItemInfo itemInfo = this.mItems.get(0);
|
|
ItemInfo itemInfo2 = this.mItems.get(r4.size() - 1);
|
|
if (itemInfo.position != 0) {
|
|
f2 = itemInfo.offset * clientWidth;
|
|
}
|
|
if (itemInfo2.position != this.mAdapter.getCount() - 1) {
|
|
f3 = itemInfo2.offset * clientWidth;
|
|
}
|
|
if (scrollX < f2) {
|
|
scrollX = f2;
|
|
} else if (scrollX > f3) {
|
|
scrollX = f3;
|
|
}
|
|
int i = (int) scrollX;
|
|
this.mLastMotionX += scrollX - i;
|
|
scrollTo(i, getScrollY());
|
|
pageScrolled(i);
|
|
MotionEvent obtain = MotionEvent.obtain(this.mFakeDragBeginTime, SystemClock.uptimeMillis(), 2, this.mLastMotionX, 0.0f, 0);
|
|
this.mVelocityTracker.addMovement(obtain);
|
|
obtain.recycle();
|
|
}
|
|
|
|
private void onSecondaryPointerUp(MotionEvent motionEvent) {
|
|
int actionIndex = motionEvent.getActionIndex();
|
|
if (motionEvent.getPointerId(actionIndex) == this.mActivePointerId) {
|
|
int i = actionIndex == 0 ? 1 : 0;
|
|
this.mLastMotionX = motionEvent.getX(i);
|
|
this.mActivePointerId = motionEvent.getPointerId(i);
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void endDrag() {
|
|
this.mIsBeingDragged = false;
|
|
this.mIsUnableToDrag = false;
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.recycle();
|
|
this.mVelocityTracker = null;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean canScrollHorizontally(int i) {
|
|
if (this.mAdapter == null) {
|
|
return false;
|
|
}
|
|
int clientWidth = getClientWidth();
|
|
int scrollX = getScrollX();
|
|
return i < 0 ? scrollX > ((int) (((float) clientWidth) * this.mFirstOffset)) : i > 0 && scrollX < ((int) (((float) clientWidth) * this.mLastOffset));
|
|
}
|
|
|
|
protected boolean canScroll(View view, boolean z, int i, int i2, int i3) {
|
|
int i4;
|
|
if (view instanceof ViewGroup) {
|
|
ViewGroup viewGroup = (ViewGroup) view;
|
|
int scrollX = view.getScrollX();
|
|
int scrollY = view.getScrollY();
|
|
for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) {
|
|
View childAt = viewGroup.getChildAt(childCount);
|
|
int i5 = i2 + scrollX;
|
|
if (i5 >= childAt.getLeft() && i5 < childAt.getRight() && (i4 = i3 + scrollY) >= childAt.getTop() && i4 < childAt.getBottom() && canScroll(childAt, true, i, i5 - childAt.getLeft(), i4 - childAt.getTop())) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return z && view.canScrollHorizontally(-i);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
|
|
return super.dispatchKeyEvent(keyEvent) || executeKeyEvent(keyEvent);
|
|
}
|
|
|
|
public boolean executeKeyEvent(KeyEvent keyEvent) {
|
|
if (keyEvent.getAction() == 0) {
|
|
int keyCode = keyEvent.getKeyCode();
|
|
if (keyCode == 21) {
|
|
if (keyEvent.hasModifiers(2)) {
|
|
return pageLeft();
|
|
}
|
|
return arrowScroll(17);
|
|
}
|
|
if (keyCode == 22) {
|
|
if (keyEvent.hasModifiers(2)) {
|
|
return pageRight();
|
|
}
|
|
return arrowScroll(66);
|
|
}
|
|
if (keyCode == 61) {
|
|
if (keyEvent.hasNoModifiers()) {
|
|
return arrowScroll(2);
|
|
}
|
|
if (keyEvent.hasModifiers(1)) {
|
|
return arrowScroll(1);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:13:0x00cb */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public boolean arrowScroll(int r6) {
|
|
/*
|
|
r5 = this;
|
|
android.view.View r0 = r5.findFocus()
|
|
r1 = 0
|
|
if (r0 != r5) goto L9
|
|
L7:
|
|
r0 = r1
|
|
goto L62
|
|
L9:
|
|
if (r0 == 0) goto L62
|
|
android.view.ViewParent r2 = r0.getParent()
|
|
Lf:
|
|
boolean r3 = r2 instanceof android.view.ViewGroup
|
|
if (r3 == 0) goto L1b
|
|
if (r2 != r5) goto L16
|
|
goto L62
|
|
L16:
|
|
android.view.ViewParent r2 = r2.getParent()
|
|
goto Lf
|
|
L1b:
|
|
java.lang.StringBuilder r2 = new java.lang.StringBuilder
|
|
r2.<init>()
|
|
java.lang.Class r3 = r0.getClass()
|
|
java.lang.String r3 = r3.getSimpleName()
|
|
r2.append(r3)
|
|
android.view.ViewParent r0 = r0.getParent()
|
|
L2f:
|
|
boolean r3 = r0 instanceof android.view.ViewGroup
|
|
if (r3 == 0) goto L49
|
|
java.lang.String r3 = " => "
|
|
java.lang.StringBuilder r3 = r2.append(r3)
|
|
java.lang.Class r4 = r0.getClass()
|
|
java.lang.String r4 = r4.getSimpleName()
|
|
r3.append(r4)
|
|
android.view.ViewParent r0 = r0.getParent()
|
|
goto L2f
|
|
L49:
|
|
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
|
java.lang.String r3 = "arrowScroll tried to find focus based on non-child current focused view "
|
|
r0.<init>(r3)
|
|
java.lang.String r2 = r2.toString()
|
|
java.lang.StringBuilder r0 = r0.append(r2)
|
|
java.lang.String r0 = r0.toString()
|
|
java.lang.String r2 = "ViewPager"
|
|
android.util.Log.e(r2, r0)
|
|
goto L7
|
|
L62:
|
|
android.view.FocusFinder r1 = android.view.FocusFinder.getInstance()
|
|
android.view.View r1 = r1.findNextFocus(r5, r0, r6)
|
|
r2 = 66
|
|
r3 = 17
|
|
if (r1 == 0) goto Lb2
|
|
if (r1 == r0) goto Lb2
|
|
if (r6 != r3) goto L92
|
|
android.graphics.Rect r2 = r5.mTempRect
|
|
android.graphics.Rect r2 = r5.getChildRectInPagerCoordinates(r2, r1)
|
|
int r2 = r2.left
|
|
android.graphics.Rect r3 = r5.mTempRect
|
|
android.graphics.Rect r3 = r5.getChildRectInPagerCoordinates(r3, r0)
|
|
int r3 = r3.left
|
|
if (r0 == 0) goto L8d
|
|
if (r2 < r3) goto L8d
|
|
boolean r0 = r5.pageLeft()
|
|
goto Lc9
|
|
L8d:
|
|
boolean r0 = r1.requestFocus()
|
|
goto Lc9
|
|
L92:
|
|
if (r6 != r2) goto Lbe
|
|
android.graphics.Rect r2 = r5.mTempRect
|
|
android.graphics.Rect r2 = r5.getChildRectInPagerCoordinates(r2, r1)
|
|
int r2 = r2.left
|
|
android.graphics.Rect r3 = r5.mTempRect
|
|
android.graphics.Rect r3 = r5.getChildRectInPagerCoordinates(r3, r0)
|
|
int r3 = r3.left
|
|
if (r0 == 0) goto Lad
|
|
if (r2 > r3) goto Lad
|
|
boolean r0 = r5.pageRight()
|
|
goto Lc9
|
|
Lad:
|
|
boolean r0 = r1.requestFocus()
|
|
goto Lc9
|
|
Lb2:
|
|
if (r6 == r3) goto Lc5
|
|
r0 = 1
|
|
if (r6 != r0) goto Lb8
|
|
goto Lc5
|
|
Lb8:
|
|
if (r6 == r2) goto Lc0
|
|
r0 = 2
|
|
if (r6 != r0) goto Lbe
|
|
goto Lc0
|
|
Lbe:
|
|
r0 = 0
|
|
goto Lc9
|
|
Lc0:
|
|
boolean r0 = r5.pageRight()
|
|
goto Lc9
|
|
Lc5:
|
|
boolean r0 = r5.pageLeft()
|
|
Lc9:
|
|
if (r0 == 0) goto Ld2
|
|
int r6 = android.view.SoundEffectConstants.getContantForFocusDirection(r6)
|
|
r5.playSoundEffect(r6)
|
|
Ld2:
|
|
return r0
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.arrowScroll(int):boolean");
|
|
}
|
|
|
|
private Rect getChildRectInPagerCoordinates(Rect rect, View view) {
|
|
if (rect == null) {
|
|
rect = new Rect();
|
|
}
|
|
if (view == null) {
|
|
rect.set(0, 0, 0, 0);
|
|
return rect;
|
|
}
|
|
rect.left = view.getLeft();
|
|
rect.right = view.getRight();
|
|
rect.top = view.getTop();
|
|
rect.bottom = view.getBottom();
|
|
ViewParent parent = view.getParent();
|
|
while ((parent instanceof ViewGroup) && parent != this) {
|
|
ViewGroup viewGroup = (ViewGroup) parent;
|
|
rect.left += viewGroup.getLeft();
|
|
rect.right += viewGroup.getRight();
|
|
rect.top += viewGroup.getTop();
|
|
rect.bottom += viewGroup.getBottom();
|
|
parent = viewGroup.getParent();
|
|
}
|
|
return rect;
|
|
}
|
|
|
|
boolean pageLeft() {
|
|
int i = this.mCurItem;
|
|
if (i <= 0) {
|
|
return false;
|
|
}
|
|
setCurrentItem(i - 1, true);
|
|
return true;
|
|
}
|
|
|
|
boolean pageRight() {
|
|
PagerAdapter pagerAdapter = this.mAdapter;
|
|
if (pagerAdapter == null || this.mCurItem >= pagerAdapter.getCount() - 1) {
|
|
return false;
|
|
}
|
|
setCurrentItem(this.mCurItem + 1, true);
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void addFocusables(ArrayList<View> arrayList, int i, int i2) {
|
|
ItemInfo infoForChild;
|
|
int size = arrayList.size();
|
|
int descendantFocusability = getDescendantFocusability();
|
|
if (descendantFocusability != 393216) {
|
|
for (int i3 = 0; i3 < getChildCount(); i3++) {
|
|
View childAt = getChildAt(i3);
|
|
if (childAt.getVisibility() == 0 && (infoForChild = infoForChild(childAt)) != null && infoForChild.position == this.mCurItem) {
|
|
childAt.addFocusables(arrayList, i, i2);
|
|
}
|
|
}
|
|
}
|
|
if ((descendantFocusability != 262144 || size == arrayList.size()) && isFocusable()) {
|
|
if (((i2 & 1) == 1 && isInTouchMode() && !isFocusableInTouchMode()) || arrayList == null) {
|
|
return;
|
|
}
|
|
arrayList.add(this);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void addTouchables(ArrayList<View> arrayList) {
|
|
ItemInfo infoForChild;
|
|
for (int i = 0; i < getChildCount(); i++) {
|
|
View childAt = getChildAt(i);
|
|
if (childAt.getVisibility() == 0 && (infoForChild = infoForChild(childAt)) != null && infoForChild.position == this.mCurItem) {
|
|
childAt.addTouchables(arrayList);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected boolean onRequestFocusInDescendants(int i, Rect rect) {
|
|
int i2;
|
|
int i3;
|
|
int i4;
|
|
ItemInfo infoForChild;
|
|
int childCount = getChildCount();
|
|
if ((i & 2) != 0) {
|
|
i3 = childCount;
|
|
i2 = 0;
|
|
i4 = 1;
|
|
} else {
|
|
i2 = childCount - 1;
|
|
i3 = -1;
|
|
i4 = -1;
|
|
}
|
|
while (i2 != i3) {
|
|
View childAt = getChildAt(i2);
|
|
if (childAt.getVisibility() == 0 && (infoForChild = infoForChild(childAt)) != null && infoForChild.position == this.mCurItem && childAt.requestFocus(i, rect)) {
|
|
return true;
|
|
}
|
|
i2 += i4;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
|
ItemInfo infoForChild;
|
|
if (accessibilityEvent.getEventType() == 4096) {
|
|
return super.dispatchPopulateAccessibilityEvent(accessibilityEvent);
|
|
}
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
if (childAt.getVisibility() == 0 && (infoForChild = infoForChild(childAt)) != null && infoForChild.position == this.mCurItem && childAt.dispatchPopulateAccessibilityEvent(accessibilityEvent)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
|
return new LayoutParams();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return generateDefaultLayoutParams();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return (layoutParams instanceof LayoutParams) && super.checkLayoutParams(layoutParams);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
|
return new LayoutParams(getContext(), attributeSet);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class MyAccessibilityDelegate extends AccessibilityDelegateCompat {
|
|
MyAccessibilityDelegate() {
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
|
|
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
|
|
accessibilityEvent.setClassName(ViewPager.class.getName());
|
|
accessibilityEvent.setScrollable(canScroll());
|
|
if (accessibilityEvent.getEventType() != 4096 || ViewPager.this.mAdapter == null) {
|
|
return;
|
|
}
|
|
accessibilityEvent.setItemCount(ViewPager.this.mAdapter.getCount());
|
|
accessibilityEvent.setFromIndex(ViewPager.this.mCurItem);
|
|
accessibilityEvent.setToIndex(ViewPager.this.mCurItem);
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
|
accessibilityNodeInfoCompat.setClassName(ViewPager.class.getName());
|
|
accessibilityNodeInfoCompat.setScrollable(canScroll());
|
|
if (ViewPager.this.canScrollHorizontally(1)) {
|
|
accessibilityNodeInfoCompat.addAction(4096);
|
|
}
|
|
if (ViewPager.this.canScrollHorizontally(-1)) {
|
|
accessibilityNodeInfoCompat.addAction(8192);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
|
|
if (super.performAccessibilityAction(view, i, bundle)) {
|
|
return true;
|
|
}
|
|
if (i == 4096) {
|
|
if (!ViewPager.this.canScrollHorizontally(1)) {
|
|
return false;
|
|
}
|
|
ViewPager viewPager = ViewPager.this;
|
|
viewPager.setCurrentItem(viewPager.mCurItem + 1);
|
|
return true;
|
|
}
|
|
if (i != 8192 || !ViewPager.this.canScrollHorizontally(-1)) {
|
|
return false;
|
|
}
|
|
ViewPager viewPager2 = ViewPager.this;
|
|
viewPager2.setCurrentItem(viewPager2.mCurItem - 1);
|
|
return true;
|
|
}
|
|
|
|
private boolean canScroll() {
|
|
return ViewPager.this.mAdapter != null && ViewPager.this.mAdapter.getCount() > 1;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private class PagerObserver extends DataSetObserver {
|
|
PagerObserver() {
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onChanged() {
|
|
ViewPager.this.dataSetChanged();
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onInvalidated() {
|
|
ViewPager.this.dataSetChanged();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class LayoutParams extends ViewGroup.LayoutParams {
|
|
int childIndex;
|
|
public int gravity;
|
|
public boolean isDecor;
|
|
boolean needsMeasure;
|
|
int position;
|
|
float widthFactor;
|
|
|
|
public LayoutParams() {
|
|
super(-1, -1);
|
|
this.widthFactor = 0.0f;
|
|
}
|
|
|
|
public LayoutParams(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.widthFactor = 0.0f;
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ViewPager.LAYOUT_ATTRS);
|
|
this.gravity = obtainStyledAttributes.getInteger(0, 48);
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class ViewPositionComparator implements Comparator<View> {
|
|
ViewPositionComparator() {
|
|
}
|
|
|
|
@Override // java.util.Comparator
|
|
public int compare(View view, View view2) {
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
LayoutParams layoutParams2 = (LayoutParams) view2.getLayoutParams();
|
|
if (layoutParams.isDecor != layoutParams2.isDecor) {
|
|
return layoutParams.isDecor ? 1 : -1;
|
|
}
|
|
return layoutParams.position - layoutParams2.position;
|
|
}
|
|
}
|
|
}
|