package androidx.viewpager.widget; import android.content.Context; import android.content.res.Resources; 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.FocusFinder; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SoundEffectConstants; 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.annotation.CallSuper; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Px; 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 c.d.b.a.a; 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; public class ViewPager extends ViewGroup { private static final int CLOSE_ENOUGH = 2; private static final Comparator COMPARATOR = new AnonymousClass1(); 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; public static final int[] LAYOUT_ATTRS = {16842931}; 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 static final Interpolator sInterpolator = new AnonymousClass2(); private static final ViewPositionComparator sPositionComparator = new ViewPositionComparator(); private int mActivePointerId = -1; public PagerAdapter mAdapter; private List mAdapterChangeListeners; private int mBottomPageBounds; private boolean mCalledSuper; private int mChildHeightMeasureSpec; private int mChildWidthMeasureSpec; private int mCloseEnough; public int mCurItem; private int mDecorChildCount; private int mDefaultGutterSize; private int mDrawingOrder; private ArrayList mDrawingOrderedChildren; private final Runnable mEndScrollRunnable = new AnonymousClass3(); private int mExpectedAdapterCount; private long mFakeDragBeginTime; private boolean mFakeDragging; private boolean mFirstLayout = true; private float mFirstOffset = -3.4028235E38f; 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 mItems = new ArrayList<>(); private float mLastMotionX; private float mLastMotionY; private float mLastOffset = Float.MAX_VALUE; private EdgeEffect mLeftEdge; private Drawable mMarginDrawable; private int mMaximumVelocity; private int mMinimumVelocity; private boolean mNeedCalculatePageOffsets = false; private PagerObserver mObserver; private int mOffscreenPageLimit = 1; private OnPageChangeListener mOnPageChangeListener; private List mOnPageChangeListeners; private int mPageMargin; private PageTransformer mPageTransformer; private int mPageTransformerLayerType; private boolean mPopulatePending; private Parcelable mRestoredAdapterState = null; private ClassLoader mRestoredClassLoader = null; private int mRestoredCurItem = -1; private EdgeEffect mRightEdge; private int mScrollState = 0; private Scroller mScroller; private boolean mScrollingCacheEnabled; private final ItemInfo mTempItem = new ItemInfo(); private final Rect mTempRect = new Rect(); private int mTopPageBounds; private int mTouchSlop; private VelocityTracker mVelocityTracker; /* renamed from: androidx.viewpager.widget.ViewPager$1 reason: invalid class name */ public static class AnonymousClass1 implements Comparator { public int compare(ItemInfo itemInfo, ItemInfo itemInfo2) { return itemInfo.position - itemInfo2.position; } } /* renamed from: androidx.viewpager.widget.ViewPager$2 reason: invalid class name */ public static class AnonymousClass2 implements Interpolator { @Override // android.animation.TimeInterpolator public float getInterpolation(float f) { float f2 = f - 1.0f; return (f2 * f2 * f2 * f2 * f2) + 1.0f; } } /* renamed from: androidx.viewpager.widget.ViewPager$3 reason: invalid class name */ public class AnonymousClass3 implements Runnable { public AnonymousClass3() { } @Override // java.lang.Runnable public void run() { ViewPager.this.setScrollState(0); ViewPager.this.populate(); } } /* renamed from: androidx.viewpager.widget.ViewPager$4 reason: invalid class name */ public class AnonymousClass4 implements OnApplyWindowInsetsListener { private final Rect mTempRect = new Rect(); public AnonymousClass4() { } @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); } } @Target({ElementType.TYPE}) @Inherited @Retention(RetentionPolicy.RUNTIME) public @interface DecorView { } public static class ItemInfo { public Object object; public float offset; public int position; public boolean scrolling; public float widthFactor; } public static class LayoutParams extends ViewGroup.LayoutParams { public int childIndex; public int gravity; public boolean isDecor; public boolean needsMeasure; public int position; public float widthFactor = 0.0f; public LayoutParams() { super(-1, -1); } public LayoutParams(Context context, AttributeSet attributeSet) { super(context, attributeSet); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ViewPager.LAYOUT_ATTRS); this.gravity = obtainStyledAttributes.getInteger(0, 48); obtainStyledAttributes.recycle(); } } public class MyAccessibilityDelegate extends AccessibilityDelegateCompat { public MyAccessibilityDelegate() { } private boolean canScroll() { PagerAdapter pagerAdapter = ViewPager.this.mAdapter; return pagerAdapter != null && pagerAdapter.getCount() > 1; } @Override // androidx.core.view.AccessibilityDelegateCompat public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) { PagerAdapter pagerAdapter; super.onInitializeAccessibilityEvent(view, accessibilityEvent); accessibilityEvent.setClassName(ViewPager.class.getName()); accessibilityEvent.setScrollable(canScroll()); if (accessibilityEvent.getEventType() == 4096 && (pagerAdapter = ViewPager.this.mAdapter) != null) { accessibilityEvent.setItemCount(pagerAdapter.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 (i != 8192 || !ViewPager.this.canScrollHorizontally(-1)) { return false; } ViewPager viewPager = ViewPager.this; viewPager.setCurrentItem(viewPager.mCurItem - 1); return true; } else if (!ViewPager.this.canScrollHorizontally(1)) { return false; } else { ViewPager viewPager2 = ViewPager.this; viewPager2.setCurrentItem(viewPager2.mCurItem + 1); return true; } } } public interface OnAdapterChangeListener { void onAdapterChanged(@NonNull ViewPager viewPager, @Nullable PagerAdapter pagerAdapter, @Nullable PagerAdapter pagerAdapter2); } public interface OnPageChangeListener { void onPageScrollStateChanged(int i); void onPageScrolled(int i, float f, @Px int i2); void onPageSelected(int i); } public interface PageTransformer { void transformPage(@NonNull View view, float f); } public class PagerObserver extends DataSetObserver { public PagerObserver() { } @Override // android.database.DataSetObserver public void onChanged() { ViewPager.this.dataSetChanged(); } @Override // android.database.DataSetObserver public void onInvalidated() { ViewPager.this.dataSetChanged(); } } public static class SavedState extends AbsSavedState { public static final Parcelable.Creator CREATOR = new AnonymousClass1(); public Parcelable adapterState; public ClassLoader loader; public int position; /* renamed from: androidx.viewpager.widget.ViewPager$SavedState$1 reason: invalid class name */ public static class AnonymousClass1 implements Parcelable.ClassLoaderCreator { @Override // android.os.Parcelable.Creator public SavedState createFromParcel(Parcel parcel) { return new SavedState(parcel, null); } @Override // android.os.Parcelable.ClassLoaderCreator public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) { return new SavedState(parcel, classLoader); } @Override // android.os.Parcelable.Creator public SavedState[] newArray(int i) { return new SavedState[i]; } } public 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; } public SavedState(@NonNull Parcelable parcelable) { super(parcelable); } @Override // java.lang.Object public String toString() { StringBuilder L = a.L("FragmentPager.SavedState{"); L.append(Integer.toHexString(System.identityHashCode(this))); L.append(" position="); return a.y(L, this.position, "}"); } @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 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) { } } public static class ViewPositionComparator implements Comparator { public int compare(View view, View view2) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); LayoutParams layoutParams2 = (LayoutParams) view2.getLayoutParams(); boolean z2 = layoutParams.isDecor; return z2 != layoutParams2.isDecor ? z2 ? 1 : -1 : layoutParams.position - layoutParams2.position; } } public ViewPager(@NonNull Context context) { super(context); initViewPager(); } public ViewPager(@NonNull Context context, @Nullable AttributeSet attributeSet) { super(context, attributeSet); initViewPager(); } private void calculatePageOffsets(ItemInfo itemInfo, int i, ItemInfo itemInfo2) { int i2; int i3; ItemInfo itemInfo3; ItemInfo itemInfo4; int count = this.mAdapter.getCount(); int clientWidth = getClientWidth(); float f = clientWidth > 0 ? ((float) this.mPageMargin) / ((float) clientWidth) : 0.0f; if (itemInfo2 != null) { int i4 = itemInfo2.position; int i5 = itemInfo.position; if (i4 < i5) { float f2 = itemInfo2.offset + itemInfo2.widthFactor + f; int i6 = i4 + 1; int i7 = 0; while (i6 <= itemInfo.position && i7 < this.mItems.size()) { ItemInfo itemInfo5 = this.mItems.get(i7); while (true) { itemInfo4 = itemInfo5; if (i6 <= itemInfo4.position || i7 >= this.mItems.size() - 1) { break; } i7++; itemInfo5 = this.mItems.get(i7); } while (i6 < itemInfo4.position) { f2 += this.mAdapter.getPageWidth(i6) + f; i6++; } itemInfo4.offset = f2; f2 += itemInfo4.widthFactor + f; i6++; } } else if (i4 > i5) { int size = this.mItems.size() - 1; float f3 = itemInfo2.offset; while (true) { i4--; if (i4 < itemInfo.position || size < 0) { break; } ItemInfo itemInfo6 = this.mItems.get(size); while (true) { itemInfo3 = itemInfo6; if (i4 >= itemInfo3.position || size <= 0) { break; } size--; itemInfo6 = this.mItems.get(size); } while (i4 > itemInfo3.position) { f3 -= this.mAdapter.getPageWidth(i4) + f; i4--; } f3 -= itemInfo3.widthFactor + f; itemInfo3.offset = f3; } } } int size2 = this.mItems.size(); float f4 = itemInfo.offset; int i8 = itemInfo.position; int i9 = i8 - 1; this.mFirstOffset = i8 == 0 ? f4 : -3.4028235E38f; int i10 = count - 1; this.mLastOffset = i8 == i10 ? (itemInfo.widthFactor + f4) - 1.0f : Float.MAX_VALUE; int i11 = i - 1; while (i11 >= 0) { ItemInfo itemInfo7 = this.mItems.get(i11); while (true) { i3 = itemInfo7.position; if (i9 <= i3) { break; } f4 -= this.mAdapter.getPageWidth(i9) + f; i9--; } f4 -= itemInfo7.widthFactor + f; itemInfo7.offset = f4; if (i3 == 0) { this.mFirstOffset = f4; } i11--; i9--; } float f5 = itemInfo.offset + itemInfo.widthFactor + f; int i12 = itemInfo.position + 1; int i13 = i + 1; while (i13 < size2) { ItemInfo itemInfo8 = this.mItems.get(i13); while (true) { i2 = itemInfo8.position; if (i12 >= i2) { break; } f5 += this.mAdapter.getPageWidth(i12) + f; i12++; } if (i2 == i10) { this.mLastOffset = (itemInfo8.widthFactor + f5) - 1.0f; } itemInfo8.offset = f5; f5 += itemInfo8.widthFactor + f; i13++; i12++; } this.mNeedCalculatePageOffsets = false; } private void completeScroll(boolean z2) { boolean z3 = this.mScrollState == 2; if (z3) { 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; z3 = true; } } if (!z3) { return; } if (z2) { ViewCompat.postOnAnimation(this, this.mEndScrollRunnable); } else { this.mEndScrollRunnable.run(); } } 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; } ArrayList arrayList = this.mItems; return Math.max(this.mItems.get(0).position, Math.min(i, arrayList.get(arrayList.size() - 1).position)); } private void dispatchOnPageScrolled(int i, float f, int i2) { OnPageChangeListener onPageChangeListener = this.mOnPageChangeListener; if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(i, f, i2); } List 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 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 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 enableLayers(boolean z2) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { getChildAt(i).setLayerType(z2 ? this.mPageTransformerLayerType : 0, null); } } private void endDrag() { this.mIsBeingDragged = false; this.mIsUnableToDrag = false; VelocityTracker velocityTracker = this.mVelocityTracker; if (velocityTracker != null) { velocityTracker.recycle(); this.mVelocityTracker = null; } } 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.left; rect.right = viewGroup.getRight() + rect.right; rect.top = viewGroup.getTop() + rect.top; rect.bottom = viewGroup.getBottom() + rect.bottom; parent = viewGroup.getParent(); } return rect; } private int getClientWidth() { return (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight(); } private ItemInfo infoForCurrentScrollPosition() { int i; int clientWidth = getClientWidth(); float f = 0.0f; float scrollX = clientWidth > 0 ? ((float) getScrollX()) / ((float) clientWidth) : 0.0f; float f2 = clientWidth > 0 ? ((float) this.mPageMargin) / ((float) clientWidth) : 0.0f; ItemInfo itemInfo = null; float f3 = 0.0f; int i2 = -1; int i3 = 0; boolean z2 = true; while (i3 < this.mItems.size()) { ItemInfo itemInfo2 = this.mItems.get(i3); if (!z2 && itemInfo2.position != (i = i2 + 1)) { itemInfo2 = this.mTempItem; itemInfo2.offset = f + f3 + f2; itemInfo2.position = i; itemInfo2.widthFactor = this.mAdapter.getPageWidth(i); i3--; } f = itemInfo2.offset; float f4 = itemInfo2.widthFactor + f + f2; if (!z2 && scrollX < f) { return itemInfo; } if (scrollX < f4 || i3 == this.mItems.size() - 1) { return itemInfo2; } i2 = itemInfo2.position; f3 = itemInfo2.widthFactor; i3++; itemInfo = itemInfo2; z2 = false; } return itemInfo; } private static boolean isDecorView(@NonNull View view) { return view.getClass().getAnnotation(DecorView.class) != null; } 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 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 boolean pageScrolled(int i) { if (this.mItems.size() != 0) { ItemInfo infoForCurrentScrollPosition = infoForCurrentScrollPosition(); int clientWidth = getClientWidth(); int i2 = this.mPageMargin; int i3 = clientWidth + i2; float f = (float) clientWidth; int i4 = infoForCurrentScrollPosition.position; float f2 = ((((float) i) / f) - infoForCurrentScrollPosition.offset) / (infoForCurrentScrollPosition.widthFactor + (((float) i2) / f)); this.mCalledSuper = false; onPageScrolled(i4, f2, (int) (((float) i3) * f2)); if (this.mCalledSuper) { return true; } throw new IllegalStateException("onPageScrolled did not call superclass implementation"); } else if (this.mFirstLayout) { return false; } else { this.mCalledSuper = false; onPageScrolled(0, 0.0f, 0); if (this.mCalledSuper) { return false; } throw new IllegalStateException("onPageScrolled did not call superclass implementation"); } } private boolean performDrag(float f) { boolean z2; boolean z3; float f2 = this.mLastMotionX - f; this.mLastMotionX = f; float scrollX = ((float) getScrollX()) + f2; float clientWidth = (float) getClientWidth(); float f3 = this.mFirstOffset * clientWidth; float f4 = this.mLastOffset * clientWidth; boolean z4 = false; ItemInfo itemInfo = this.mItems.get(0); ArrayList arrayList = this.mItems; ItemInfo itemInfo2 = arrayList.get(arrayList.size() - 1); if (itemInfo.position != 0) { f3 = itemInfo.offset * clientWidth; z2 = false; } else { z2 = true; } if (itemInfo2.position != this.mAdapter.getCount() - 1) { f4 = itemInfo2.offset * clientWidth; z3 = false; } else { z3 = true; } if (scrollX < f3) { if (z2) { this.mLeftEdge.onPull(Math.abs(f3 - scrollX) / clientWidth); z4 = true; } scrollX = f3; } else if (scrollX > f4) { if (z3) { this.mRightEdge.onPull(Math.abs(scrollX - f4) / clientWidth); z4 = true; } scrollX = f4; } int i = (int) scrollX; this.mLastMotionX = (scrollX - ((float) i)) + this.mLastMotionX; scrollTo(i, getScrollY()); pageScrolled(i); return z4; } private void recomputeScrollPosition(int i, int i2, int i3, int i4) { if (i2 <= 0 || this.mItems.isEmpty()) { ItemInfo infoForPosition = infoForPosition(this.mCurItem); int min = (int) ((infoForPosition != null ? Math.min(infoForPosition.offset, this.mLastOffset) : 0.0f) * ((float) ((i - getPaddingLeft()) - getPaddingRight()))); if (min != getScrollX()) { completeScroll(false); scrollTo(min, getScrollY()); } } else if (!this.mScroller.isFinished()) { this.mScroller.setFinalX(getCurrentItem() * getClientWidth()); } else { scrollTo((int) ((((float) getScrollX()) / ((float) (((i2 - getPaddingLeft()) - getPaddingRight()) + i4))) * ((float) (((i - getPaddingLeft()) - getPaddingRight()) + i3))), getScrollY()); } } private void removeNonDecorViews() { int i = 0; while (i < getChildCount()) { if (!((LayoutParams) getChildAt(i).getLayoutParams()).isDecor) { removeViewAt(i); i--; } i++; } } private void requestParentDisallowInterceptTouchEvent(boolean z2) { ViewParent parent = getParent(); if (parent != null) { parent.requestDisallowInterceptTouchEvent(z2); } } private boolean resetTouch() { this.mActivePointerId = -1; endDrag(); this.mLeftEdge.onRelease(); this.mRightEdge.onRelease(); return this.mLeftEdge.isFinished() || this.mRightEdge.isFinished(); } private void scrollToItem(int i, boolean z2, int i2, boolean z3) { int i3; ItemInfo infoForPosition = infoForPosition(i); if (infoForPosition != null) { i3 = (int) (Math.max(this.mFirstOffset, Math.min(infoForPosition.offset, this.mLastOffset)) * ((float) getClientWidth())); } else { i3 = 0; } if (z2) { smoothScrollTo(i3, 0, i2); if (z3) { dispatchOnPageSelected(i); return; } return; } if (z3) { dispatchOnPageSelected(i); } completeScroll(false); scrollTo(i3, 0); pageScrolled(i3); } private void setScrollingCacheEnabled(boolean z2) { if (this.mScrollingCacheEnabled != z2) { this.mScrollingCacheEnabled = z2; } } private void sortChildDrawingOrder() { if (this.mDrawingOrder != 0) { ArrayList 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); } } @Override // android.view.ViewGroup, android.view.View public void addFocusables(ArrayList 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()) { return; } if ((i2 & 1) != 1 || !isInTouchMode() || isFocusableInTouchMode()) { arrayList.add(this); } } public 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; } public void addOnAdapterChangeListener(@NonNull OnAdapterChangeListener onAdapterChangeListener) { if (this.mAdapterChangeListeners == null) { this.mAdapterChangeListeners = new ArrayList(); } this.mAdapterChangeListeners.add(onAdapterChangeListener); } public void addOnPageChangeListener(@NonNull OnPageChangeListener onPageChangeListener) { if (this.mOnPageChangeListeners == null) { this.mOnPageChangeListeners = new ArrayList(); } this.mOnPageChangeListeners.add(onPageChangeListener); } @Override // android.view.ViewGroup, android.view.View public void addTouchables(ArrayList 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 public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) { if (!checkLayoutParams(layoutParams)) { layoutParams = generateLayoutParams(layoutParams); } LayoutParams layoutParams2 = (LayoutParams) layoutParams; boolean isDecorView = layoutParams2.isDecor | isDecorView(view); layoutParams2.isDecor = isDecorView; if (!this.mInLayout) { super.addView(view, i, layoutParams); } else if (!isDecorView) { layoutParams2.needsMeasure = true; addViewInLayout(view, i, layoutParams); } else { throw new IllegalStateException("Cannot add pager decor view during layout"); } } /* JADX WARNING: Removed duplicated region for block: B:41:0x00ca */ public boolean arrowScroll(int i) { View findNextFocus; boolean requestFocus; boolean z2; View findFocus = findFocus(); boolean z3 = false; if (findFocus != this) { if (findFocus != null) { ViewParent parent = findFocus.getParent(); while (true) { if (!(parent instanceof ViewGroup)) { z2 = false; break; } else if (parent == this) { z2 = true; break; } else { parent = parent.getParent(); } } if (!z2) { StringBuilder sb = new StringBuilder(); sb.append(findFocus.getClass().getSimpleName()); for (ViewParent parent2 = findFocus.getParent(); parent2 instanceof ViewGroup; parent2 = parent2.getParent()) { sb.append(" => "); sb.append(parent2.getClass().getSimpleName()); } StringBuilder L = a.L("arrowScroll tried to find focus based on non-child current focused view "); L.append(sb.toString()); Log.e("ViewPager", L.toString()); } } findNextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, i); if (findNextFocus == null && findNextFocus != findFocus) { if (i == 17) { requestFocus = (findFocus == null || getChildRectInPagerCoordinates(this.mTempRect, findNextFocus).left < getChildRectInPagerCoordinates(this.mTempRect, findFocus).left) ? findNextFocus.requestFocus() : pageLeft(); } else if (i == 66) { requestFocus = (findFocus == null || getChildRectInPagerCoordinates(this.mTempRect, findNextFocus).left > getChildRectInPagerCoordinates(this.mTempRect, findFocus).left) ? findNextFocus.requestFocus() : pageRight(); } z3 = requestFocus; } else if (i != 17 || i == 1) { z3 = pageLeft(); } else if (i == 66 || i == 2) { z3 = pageRight(); } if (z3) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(i)); } return z3; } findFocus = null; findNextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, i); if (findNextFocus == null) { } if (i != 17) { } z3 = pageLeft(); if (z3) { } return z3; } 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 boolean canScroll(View view, boolean z2, 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 z2 && view.canScrollHorizontally(-i); } @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)); } @Override // android.view.ViewGroup public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) { return (layoutParams instanceof LayoutParams) && super.checkLayoutParams(layoutParams); } public void clearOnPageChangeListeners() { List list = this.mOnPageChangeListeners; if (list != null) { list.clear(); } } @Override // android.view.View public void computeScroll() { this.mIsScrollStarted = true; if (this.mScroller.isFinished() || !this.mScroller.computeScrollOffset()) { completeScroll(true); return; } 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); } public void dataSetChanged() { int count = this.mAdapter.getCount(); this.mExpectedAdapterCount = count; boolean z2 = this.mItems.size() < (this.mOffscreenPageLimit * 2) + 1 && this.mItems.size() < count; int i = this.mCurItem; int i2 = 0; boolean z3 = 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 (!z3) { this.mAdapter.startUpdate((ViewGroup) this); z3 = true; } this.mAdapter.destroyItem((ViewGroup) this, itemInfo.position, itemInfo.object); int i3 = this.mCurItem; if (i3 == itemInfo.position) { i = Math.max(0, Math.min(i3, count - 1)); } } else { int i4 = itemInfo.position; if (i4 != itemPosition) { if (i4 == this.mCurItem) { i = itemPosition; } itemInfo.position = itemPosition; } } z2 = true; } i2++; } if (z3) { this.mAdapter.finishUpdate((ViewGroup) this); } Collections.sort(this.mItems, COMPARATOR); if (z2) { int childCount = getChildCount(); for (int i5 = 0; i5 < childCount; i5++) { LayoutParams layoutParams = (LayoutParams) getChildAt(i5).getLayoutParams(); if (!layoutParams.isDecor) { layoutParams.widthFactor = 0.0f; } } setCurrentItemInternal(i, false, true); requestLayout(); } } @Override // android.view.ViewGroup, android.view.View public boolean dispatchKeyEvent(KeyEvent keyEvent) { return super.dispatchKeyEvent(keyEvent) || executeKeyEvent(keyEvent); } @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; } public float distanceInfluenceForSnapDuration(float f) { return (float) Math.sin((double) ((f - 0.5f) * 0.47123894f)); } @Override // android.view.View public void draw(Canvas canvas) { PagerAdapter pagerAdapter; super.draw(canvas); int overScrollMode = getOverScrollMode(); boolean z2 = false; if (overScrollMode == 0 || (overScrollMode == 1 && (pagerAdapter = this.mAdapter) != null && pagerAdapter.getCount() > 1)) { if (!this.mLeftEdge.isFinished()) { int save = canvas.save(); int height = (getHeight() - getPaddingTop()) - getPaddingBottom(); int width = getWidth(); canvas.rotate(270.0f); canvas.translate((float) (getPaddingTop() + (-height)), this.mFirstOffset * ((float) width)); this.mLeftEdge.setSize(height, width); z2 = false | 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((float) (-getPaddingTop()), (-(this.mLastOffset + 1.0f)) * ((float) width2)); this.mRightEdge.setSize(height2, width2); z2 |= this.mRightEdge.draw(canvas); canvas.restoreToCount(save2); } } else { this.mLeftEdge.finish(); this.mRightEdge.finish(); } if (z2) { ViewCompat.postInvalidateOnAnimation(this); } } @Override // android.view.ViewGroup, android.view.View public void drawableStateChanged() { super.drawableStateChanged(); Drawable drawable = this.mMarginDrawable; if (drawable != null && drawable.isStateful()) { drawable.setState(getDrawableState()); } } public void endFakeDrag() { if (this.mFakeDragging) { if (this.mAdapter != null) { VelocityTracker velocityTracker = this.mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, (float) 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, ((((float) scrollX) / ((float) clientWidth)) - infoForCurrentScrollPosition.offset) / infoForCurrentScrollPosition.widthFactor, xVelocity, (int) (this.mLastMotionX - this.mInitialMotionX)), true, true, xVelocity); } endDrag(); this.mFakeDragging = false; return; } throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first."); } public boolean executeKeyEvent(@NonNull KeyEvent keyEvent) { if (keyEvent.getAction() == 0) { int keyCode = keyEvent.getKeyCode(); if (keyCode == 21) { return keyEvent.hasModifiers(2) ? pageLeft() : arrowScroll(17); } if (keyCode == 22) { return keyEvent.hasModifiers(2) ? pageRight() : arrowScroll(66); } if (keyCode == 61) { if (keyEvent.hasNoModifiers()) { return arrowScroll(2); } if (keyEvent.hasModifiers(1)) { return arrowScroll(1); } } } return false; } public void fakeDragBy(float f) { if (!this.mFakeDragging) { throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first."); } else if (this.mAdapter != null) { this.mLastMotionX += f; float scrollX = ((float) getScrollX()) - f; float clientWidth = (float) getClientWidth(); float f2 = this.mFirstOffset * clientWidth; float f3 = this.mLastOffset * clientWidth; ItemInfo itemInfo = this.mItems.get(0); ArrayList arrayList = this.mItems; ItemInfo itemInfo2 = arrayList.get(arrayList.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 - ((float) i)) + this.mLastMotionX; 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(); } } @Override // android.view.ViewGroup public ViewGroup.LayoutParams generateDefaultLayoutParams() { return new LayoutParams(); } @Override // android.view.ViewGroup public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) { return new LayoutParams(getContext(), attributeSet); } @Override // android.view.ViewGroup public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) { return generateDefaultLayoutParams(); } @Nullable public PagerAdapter getAdapter() { return this.mAdapter; } @Override // android.view.ViewGroup public int getChildDrawingOrder(int i, int i2) { if (this.mDrawingOrder == 2) { i2 = (i - 1) - i2; } return ((LayoutParams) this.mDrawingOrderedChildren.get(i2).getLayoutParams()).childIndex; } public int getCurrentItem() { return this.mCurItem; } public int getOffscreenPageLimit() { return this.mOffscreenPageLimit; } public int getPageMargin() { return this.mPageMargin; } public ItemInfo infoForAnyChild(View view) { while (true) { ViewParent parent = view.getParent(); if (parent == this) { return infoForChild(view); } if (parent == null || !(parent instanceof View)) { return null; } view = (View) parent; } } public 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; } public 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; } public 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 AnonymousClass4()); } public boolean isFakeDragging() { return this.mFakeDragging; } @Override // android.view.ViewGroup, android.view.View public void onAttachedToWindow() { super.onAttachedToWindow(); this.mFirstLayout = true; } @Override // android.view.ViewGroup, android.view.View public void onDetachedFromWindow() { removeCallbacks(this.mEndScrollRunnable); Scroller scroller = this.mScroller; if (scroller != null && !scroller.isFinished()) { this.mScroller.abortAnimation(); } super.onDetachedFromWindow(); } @Override // android.view.View public void onDraw(Canvas canvas) { int i; float f; float f2; super.onDraw(canvas); if (this.mPageMargin > 0 && this.mMarginDrawable != null && this.mItems.size() > 0 && this.mAdapter != null) { int scrollX = getScrollX(); int width = getWidth(); float f3 = (float) width; float f4 = ((float) this.mPageMargin) / f3; int i2 = 0; ItemInfo itemInfo = this.mItems.get(0); float f5 = itemInfo.offset; int size = this.mItems.size(); int i3 = itemInfo.position; int i4 = this.mItems.get(size - 1).position; while (i3 < i4) { while (true) { i = itemInfo.position; if (i3 <= i || i2 >= size) { break; } i2++; itemInfo = this.mItems.get(i2); } if (i3 == i) { float f6 = itemInfo.offset; float f7 = itemInfo.widthFactor; f = (f6 + f7) * f3; f5 = f6 + f7 + f4; } else { float pageWidth = this.mAdapter.getPageWidth(i3); f = (f5 + pageWidth) * f3; f5 = pageWidth + f4 + f5; } if (((float) this.mPageMargin) + f > ((float) scrollX)) { f2 = f4; this.mMarginDrawable.setBounds(Math.round(f), this.mTopPageBounds, Math.round(((float) this.mPageMargin) + f), this.mBottomPageBounds); this.mMarginDrawable.draw(canvas); } else { f2 = f4; } if (f <= ((float) (scrollX + width))) { i3++; f4 = f2; } else { return; } } } } @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 x2 = motionEvent.getX(); this.mInitialMotionX = x2; this.mLastMotionX = x2; float y2 = motionEvent.getY(); this.mInitialMotionY = y2; this.mLastMotionY = y2; 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) { completeScroll(false); this.mIsBeingDragged = false; } else { this.mScroller.abortAnimation(); this.mPopulatePending = false; populate(); this.mIsBeingDragged = true; requestParentDisallowInterceptTouchEvent(true); setScrollState(1); } } else if (action == 2) { int i = this.mActivePointerId; if (i != -1) { int findPointerIndex = motionEvent.findPointerIndex(i); float x3 = motionEvent.getX(findPointerIndex); float f = x3 - this.mLastMotionX; float abs = Math.abs(f); float y3 = motionEvent.getY(findPointerIndex); float abs2 = Math.abs(y3 - this.mInitialMotionY); int i2 = (f > 0.0f ? 1 : (f == 0.0f ? 0 : -1)); if (i2 == 0 || isGutterDrag(this.mLastMotionX, f) || !canScroll(this, false, (int) f, (int) x3, (int) y3)) { int i3 = this.mTouchSlop; if (abs > ((float) i3) && abs * 0.5f > abs2) { this.mIsBeingDragged = true; requestParentDisallowInterceptTouchEvent(true); setScrollState(1); float f2 = this.mInitialMotionX; float f3 = (float) this.mTouchSlop; this.mLastMotionX = i2 > 0 ? f2 + f3 : f2 - f3; this.mLastMotionY = y3; setScrollingCacheEnabled(true); } else if (abs2 > ((float) i3)) { this.mIsUnableToDrag = true; } if (this.mIsBeingDragged && performDrag(x3)) { ViewCompat.postInvalidateOnAnimation(this); } } else { this.mLastMotionX = x3; this.mLastMotionY = y3; this.mIsUnableToDrag = true; return false; } } } else if (action == 6) { onSecondaryPointerUp(motionEvent); } if (this.mVelocityTracker == null) { this.mVelocityTracker = VelocityTracker.obtain(); } this.mVelocityTracker.addMovement(motionEvent); return this.mIsBeingDragged; } /* JADX WARNING: Removed duplicated region for block: B:20:0x0071 */ /* JADX WARNING: Removed duplicated region for block: B:27:0x008e */ @Override // android.view.ViewGroup, android.view.View public void onLayout(boolean z2, int i, int i2, int i3, int i4) { boolean z3; ItemInfo infoForChild; int i5; int i6; int i7; int i8; int childCount = getChildCount(); int i9 = i3 - i; int i10 = i4 - i2; int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); int scrollX = getScrollX(); int i11 = 0; for (int i12 = 0; i12 < childCount; i12++) { View childAt = getChildAt(i12); if (childAt.getVisibility() != 8) { LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isDecor) { int i13 = layoutParams.gravity; int i14 = i13 & 7; int i15 = i13 & 112; if (i14 != 1) { if (i14 == 3) { i5 = childAt.getMeasuredWidth() + paddingLeft; } else if (i14 != 5) { i5 = paddingLeft; } else { i8 = (i9 - paddingRight) - childAt.getMeasuredWidth(); paddingRight += childAt.getMeasuredWidth(); } if (i15 == 16) { if (i15 == 48) { i6 = childAt.getMeasuredHeight() + paddingTop; } else if (i15 != 80) { i6 = paddingTop; } else { i7 = (i10 - paddingBottom) - childAt.getMeasuredHeight(); paddingBottom += childAt.getMeasuredHeight(); } int i16 = paddingLeft + scrollX; childAt.layout(i16, paddingTop, childAt.getMeasuredWidth() + i16, childAt.getMeasuredHeight() + paddingTop); i11++; paddingTop = i6; paddingLeft = i5; } else { i7 = Math.max((i10 - childAt.getMeasuredHeight()) / 2, paddingTop); } i6 = paddingTop; paddingTop = i7; int i16 = paddingLeft + scrollX; childAt.layout(i16, paddingTop, childAt.getMeasuredWidth() + i16, childAt.getMeasuredHeight() + paddingTop); i11++; paddingTop = i6; paddingLeft = i5; } else { i8 = Math.max((i9 - childAt.getMeasuredWidth()) / 2, paddingLeft); } i5 = paddingLeft; paddingLeft = i8; if (i15 == 16) { } i6 = paddingTop; paddingTop = i7; int i16 = paddingLeft + scrollX; childAt.layout(i16, paddingTop, childAt.getMeasuredWidth() + i16, childAt.getMeasuredHeight() + paddingTop); i11++; paddingTop = i6; paddingLeft = i5; } } } int i17 = (i9 - paddingLeft) - paddingRight; for (int i18 = 0; i18 < childCount; i18++) { View childAt2 = getChildAt(i18); if (childAt2.getVisibility() != 8) { LayoutParams layoutParams2 = (LayoutParams) childAt2.getLayoutParams(); if (!layoutParams2.isDecor && (infoForChild = infoForChild(childAt2)) != null) { float f = (float) i17; int i19 = ((int) (infoForChild.offset * f)) + paddingLeft; if (layoutParams2.needsMeasure) { layoutParams2.needsMeasure = false; childAt2.measure(View.MeasureSpec.makeMeasureSpec((int) (f * layoutParams2.widthFactor), 1073741824), View.MeasureSpec.makeMeasureSpec((i10 - paddingTop) - paddingBottom, 1073741824)); } childAt2.layout(i19, paddingTop, childAt2.getMeasuredWidth() + i19, childAt2.getMeasuredHeight() + paddingTop); } } } this.mTopPageBounds = paddingTop; this.mBottomPageBounds = i10 - paddingBottom; this.mDecorChildCount = i11; if (this.mFirstLayout) { z3 = false; scrollToItem(this.mCurItem, false, 0, false); } else { z3 = false; } this.mFirstLayout = z3; } /* JADX WARNING: Removed duplicated region for block: B:28:0x0082 */ /* JADX WARNING: Removed duplicated region for block: B:31:0x0089 */ /* JADX WARNING: Removed duplicated region for block: B:34:0x008e */ /* JADX WARNING: Removed duplicated region for block: B:36:0x0093 */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00a2 */ /* JADX WARNING: Removed duplicated region for block: B:40:0x00a8 */ @Override // android.view.View public void onMeasure(int i, int i2) { LayoutParams layoutParams; LayoutParams layoutParams2; int i3; int i4; int i5; setMeasuredDimension(ViewGroup.getDefaultSize(0, i), ViewGroup.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 i6 = 0; while (true) { boolean z2 = true; int i7 = 1073741824; if (i6 >= childCount) { break; } View childAt = getChildAt(i6); if (!(childAt.getVisibility() == 8 || (layoutParams2 = (LayoutParams) childAt.getLayoutParams()) == null || !layoutParams2.isDecor)) { int i8 = layoutParams2.gravity; int i9 = i8 & 7; int i10 = i8 & 112; boolean z3 = i10 == 48 || i10 == 80; if (!(i9 == 3 || i9 == 5)) { z2 = false; } int i11 = Integer.MIN_VALUE; if (z3) { i11 = 1073741824; } else if (z2) { i3 = 1073741824; i4 = ((ViewGroup.LayoutParams) layoutParams2).width; if (i4 == -2) { if (i4 == -1) { i4 = paddingLeft; } i11 = 1073741824; } else { i4 = paddingLeft; } i5 = ((ViewGroup.LayoutParams) layoutParams2).height; if (i5 != -2) { i5 = measuredHeight; i7 = i3; } else if (i5 == -1) { i5 = measuredHeight; } childAt.measure(View.MeasureSpec.makeMeasureSpec(i4, i11), View.MeasureSpec.makeMeasureSpec(i5, i7)); if (!z3) { measuredHeight -= childAt.getMeasuredHeight(); } else if (z2) { paddingLeft -= childAt.getMeasuredWidth(); } } i3 = Integer.MIN_VALUE; i4 = ((ViewGroup.LayoutParams) layoutParams2).width; if (i4 == -2) { } i5 = ((ViewGroup.LayoutParams) layoutParams2).height; if (i5 != -2) { } childAt.measure(View.MeasureSpec.makeMeasureSpec(i4, i11), View.MeasureSpec.makeMeasureSpec(i5, i7)); if (!z3) { } } i6++; } 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) (((float) paddingLeft) * layoutParams.widthFactor), 1073741824), this.mChildHeightMeasureSpec); } } } /* JADX WARNING: Removed duplicated region for block: B:19:0x0064 */ @CallSuper public void onPageScrolled(int i, float f, int i2) { int i3; int left; int i4; if (this.mDecorChildCount > 0) { int scrollX = getScrollX(); int paddingLeft = getPaddingLeft(); int paddingRight = getPaddingRight(); int width = getWidth(); int childCount = getChildCount(); for (int i5 = 0; i5 < childCount; i5++) { View childAt = getChildAt(i5); LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isDecor) { int i6 = layoutParams.gravity & 7; if (i6 != 1) { if (i6 == 3) { i3 = childAt.getWidth() + paddingLeft; } else if (i6 != 5) { i3 = paddingLeft; } else { i4 = (width - paddingRight) - childAt.getMeasuredWidth(); paddingRight += childAt.getMeasuredWidth(); } left = (paddingLeft + scrollX) - childAt.getLeft(); if (left != 0) { childAt.offsetLeftAndRight(left); } paddingLeft = i3; } else { i4 = Math.max((width - childAt.getMeasuredWidth()) / 2, paddingLeft); } i3 = paddingLeft; paddingLeft = i4; left = (paddingLeft + scrollX) - childAt.getLeft(); if (left != 0) { } paddingLeft = i3; } } } dispatchOnPageScrolled(i, f, i2); if (this.mPageTransformer != null) { int scrollX2 = getScrollX(); int childCount2 = getChildCount(); for (int i7 = 0; i7 < childCount2; i7++) { View childAt2 = getChildAt(i7); if (!((LayoutParams) childAt2.getLayoutParams()).isDecor) { this.mPageTransformer.transformPage(childAt2, ((float) (childAt2.getLeft() - scrollX2)) / ((float) getClientWidth())); } } } this.mCalledSuper = true; } @Override // android.view.ViewGroup public boolean onRequestFocusInDescendants(int i, Rect rect) { int i2; int i3; ItemInfo infoForChild; int childCount = getChildCount(); int i4 = -1; if ((i & 2) != 0) { i4 = childCount; i3 = 0; i2 = 1; } else { i3 = childCount - 1; i2 = -1; } while (i3 != i4) { View childAt = getChildAt(i3); if (childAt.getVisibility() == 0 && (infoForChild = infoForChild(childAt)) != null && infoForChild.position == this.mCurItem && childAt.requestFocus(i, rect)) { return true; } i3 += i2; } 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()); PagerAdapter pagerAdapter = this.mAdapter; if (pagerAdapter != null) { pagerAdapter.restoreState(savedState.adapterState, savedState.loader); setCurrentItemInternal(savedState.position, false, true); return; } this.mRestoredCurItem = savedState.position; this.mRestoredAdapterState = savedState.adapterState; this.mRestoredClassLoader = savedState.loader; } @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 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); } } @Override // android.view.View public boolean onTouchEvent(MotionEvent motionEvent) { PagerAdapter pagerAdapter; if (this.mFakeDragging) { return true; } boolean z2 = false; if ((motionEvent.getAction() == 0 && motionEvent.getEdgeFlags() != 0) || (pagerAdapter = this.mAdapter) == null || pagerAdapter.getCount() == 0) { return false; } if (this.mVelocityTracker == null) { this.mVelocityTracker = VelocityTracker.obtain(); } this.mVelocityTracker.addMovement(motionEvent); int action = motionEvent.getAction() & 255; if (action == 0) { this.mScroller.abortAnimation(); this.mPopulatePending = false; populate(); float x2 = motionEvent.getX(); this.mInitialMotionX = x2; this.mLastMotionX = x2; float y2 = motionEvent.getY(); this.mInitialMotionY = y2; this.mLastMotionY = y2; this.mActivePointerId = motionEvent.getPointerId(0); } else if (action != 1) { if (action == 2) { if (!this.mIsBeingDragged) { int findPointerIndex = motionEvent.findPointerIndex(this.mActivePointerId); if (findPointerIndex == -1) { z2 = resetTouch(); } else { float x3 = motionEvent.getX(findPointerIndex); float abs = Math.abs(x3 - this.mLastMotionX); float y3 = motionEvent.getY(findPointerIndex); float abs2 = Math.abs(y3 - this.mLastMotionY); if (abs > ((float) this.mTouchSlop) && abs > abs2) { this.mIsBeingDragged = true; requestParentDisallowInterceptTouchEvent(true); float f = this.mInitialMotionX; this.mLastMotionX = x3 - f > 0.0f ? f + ((float) this.mTouchSlop) : f - ((float) this.mTouchSlop); this.mLastMotionY = y3; setScrollState(1); setScrollingCacheEnabled(true); ViewParent parent = getParent(); if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); } } } } if (this.mIsBeingDragged) { z2 = false | performDrag(motionEvent.getX(motionEvent.findPointerIndex(this.mActivePointerId))); } } else if (action != 3) { if (action == 5) { int actionIndex = motionEvent.getActionIndex(); this.mLastMotionX = motionEvent.getX(actionIndex); this.mActivePointerId = motionEvent.getPointerId(actionIndex); } else if (action == 6) { onSecondaryPointerUp(motionEvent); this.mLastMotionX = motionEvent.getX(motionEvent.findPointerIndex(this.mActivePointerId)); } } else if (this.mIsBeingDragged) { scrollToItem(this.mCurItem, true, 0, false); z2 = resetTouch(); } } else if (this.mIsBeingDragged) { VelocityTracker velocityTracker = this.mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, (float) this.mMaximumVelocity); int xVelocity = (int) velocityTracker.getXVelocity(this.mActivePointerId); this.mPopulatePending = true; int clientWidth = getClientWidth(); int scrollX = getScrollX(); ItemInfo infoForCurrentScrollPosition = infoForCurrentScrollPosition(); float f2 = (float) clientWidth; setCurrentItemInternal(determineTargetPage(infoForCurrentScrollPosition.position, ((((float) scrollX) / f2) - infoForCurrentScrollPosition.offset) / (infoForCurrentScrollPosition.widthFactor + (((float) this.mPageMargin) / f2)), xVelocity, (int) (motionEvent.getX(motionEvent.findPointerIndex(this.mActivePointerId)) - this.mInitialMotionX)), true, true, xVelocity); z2 = resetTouch(); } if (z2) { ViewCompat.postInvalidateOnAnimation(this); } return true; } public boolean pageLeft() { int i = this.mCurItem; if (i <= 0) { return false; } setCurrentItem(i - 1, true); return true; } public boolean pageRight() { PagerAdapter pagerAdapter = this.mAdapter; if (pagerAdapter == null || this.mCurItem >= pagerAdapter.getCount() - 1) { return false; } setCurrentItem(this.mCurItem + 1, true); return true; } public void populate() { populate(this.mCurItem); } /* JADX WARNING: Code restructure failed: missing block: B:22:0x005c, code lost: if (r5 == r6) goto L_0x0063; */ public void populate(int i) { ItemInfo itemInfo; String str; ItemInfo itemInfo2; ItemInfo infoForChild; int i2 = this.mCurItem; if (i2 != i) { itemInfo = infoForPosition(i2); this.mCurItem = i; } else { itemInfo = null; } if (this.mAdapter == null) { sortChildDrawingOrder(); } else if (this.mPopulatePending) { sortChildDrawingOrder(); } else if (getWindowToken() != null) { this.mAdapter.startUpdate((ViewGroup) this); int i3 = this.mOffscreenPageLimit; int max = Math.max(0, this.mCurItem - i3); int count = this.mAdapter.getCount(); int min = Math.min(count - 1, this.mCurItem + i3); if (count == this.mExpectedAdapterCount) { int i4 = 0; while (true) { if (i4 >= this.mItems.size()) { break; } itemInfo2 = this.mItems.get(i4); int i5 = itemInfo2.position; int i6 = this.mCurItem; if (i5 < i6) { i4++; } } itemInfo2 = null; if (itemInfo2 == null && count > 0) { itemInfo2 = addNewItem(this.mCurItem, i4); } if (itemInfo2 != null) { int i7 = i4 - 1; ItemInfo itemInfo3 = i7 >= 0 ? this.mItems.get(i7) : null; int clientWidth = getClientWidth(); float paddingLeft = clientWidth <= 0 ? 0.0f : (2.0f - itemInfo2.widthFactor) + (((float) getPaddingLeft()) / ((float) clientWidth)); float f = 0.0f; for (int i8 = this.mCurItem - 1; i8 >= 0; i8--) { if (f < paddingLeft || i8 >= max) { if (itemInfo3 == null || i8 != itemInfo3.position) { f += addNewItem(i8, i7 + 1).widthFactor; i4++; if (i7 >= 0) { itemInfo3 = this.mItems.get(i7); } } else { f += itemInfo3.widthFactor; i7--; if (i7 >= 0) { itemInfo3 = this.mItems.get(i7); } } } else if (itemInfo3 == null) { break; } else { if (i8 == itemInfo3.position && !itemInfo3.scrolling) { this.mItems.remove(i7); this.mAdapter.destroyItem((ViewGroup) this, i8, itemInfo3.object); i7--; i4--; if (i7 >= 0) { itemInfo3 = this.mItems.get(i7); } } } itemInfo3 = null; } float f2 = itemInfo2.widthFactor; int i9 = i4 + 1; if (f2 < 2.0f) { ItemInfo itemInfo4 = i9 < this.mItems.size() ? this.mItems.get(i9) : null; float paddingRight = clientWidth <= 0 ? 0.0f : (((float) getPaddingRight()) / ((float) clientWidth)) + 2.0f; int i10 = this.mCurItem; while (true) { i10++; if (i10 >= count) { break; } if (f2 < paddingRight || i10 <= min) { if (itemInfo4 == null || i10 != itemInfo4.position) { ItemInfo addNewItem = addNewItem(i10, i9); i9++; f2 += addNewItem.widthFactor; if (i9 < this.mItems.size()) { itemInfo4 = this.mItems.get(i9); } } else { f2 += itemInfo4.widthFactor; i9++; if (i9 < this.mItems.size()) { itemInfo4 = this.mItems.get(i9); } } } else if (itemInfo4 == null) { break; } else if (i10 == itemInfo4.position && !itemInfo4.scrolling) { this.mItems.remove(i9); this.mAdapter.destroyItem((ViewGroup) this, i10, itemInfo4.object); if (i9 < this.mItems.size()) { itemInfo4 = this.mItems.get(i9); } } itemInfo4 = null; } } calculatePageOffsets(itemInfo2, i4, itemInfo); this.mAdapter.setPrimaryItem((ViewGroup) this, this.mCurItem, itemInfo2.object); } this.mAdapter.finishUpdate((ViewGroup) this); int childCount = getChildCount(); for (int i11 = 0; i11 < childCount; i11++) { View childAt = getChildAt(i11); LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); layoutParams.childIndex = i11; if (!layoutParams.isDecor && layoutParams.widthFactor == 0.0f && (infoForChild = infoForChild(childAt)) != null) { layoutParams.widthFactor = infoForChild.widthFactor; layoutParams.position = infoForChild.position; } } sortChildDrawingOrder(); if (hasFocus()) { View findFocus = findFocus(); ItemInfo infoForAnyChild = findFocus != null ? infoForAnyChild(findFocus) : null; if (infoForAnyChild == null || infoForAnyChild.position != this.mCurItem) { for (int i12 = 0; i12 < getChildCount(); i12++) { View childAt2 = getChildAt(i12); ItemInfo infoForChild2 = infoForChild(childAt2); if (infoForChild2 != null && infoForChild2.position == this.mCurItem && childAt2.requestFocus(2)) { return; } } return; } return; } return; } try { str = getResources().getResourceName(getId()); } catch (Resources.NotFoundException unused) { str = Integer.toHexString(getId()); } StringBuilder L = a.L("The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: "); L.append(this.mExpectedAdapterCount); L.append(", found: "); L.append(count); L.append(" Pager id: "); L.append(str); L.append(" Pager class: "); L.append(getClass()); L.append(" Problematic adapter: "); L.append(this.mAdapter.getClass()); throw new IllegalStateException(L.toString()); } } public void removeOnAdapterChangeListener(@NonNull OnAdapterChangeListener onAdapterChangeListener) { List list = this.mAdapterChangeListeners; if (list != null) { list.remove(onAdapterChangeListener); } } public void removeOnPageChangeListener(@NonNull OnPageChangeListener onPageChangeListener) { List list = this.mOnPageChangeListeners; if (list != null) { list.remove(onPageChangeListener); } } @Override // android.view.ViewGroup, android.view.ViewManager public void removeView(View view) { if (this.mInLayout) { removeViewInLayout(view); } else { super.removeView(view); } } public void setAdapter(@Nullable 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 z2 = 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 (!z2) { populate(); } else { requestLayout(); } } List list = this.mAdapterChangeListeners; if (!(list == null || list.isEmpty())) { int size = this.mAdapterChangeListeners.size(); for (int i2 = 0; i2 < size; i2++) { this.mAdapterChangeListeners.get(i2).onAdapterChanged(this, pagerAdapter3, pagerAdapter); } } } public void setCurrentItem(int i) { this.mPopulatePending = false; setCurrentItemInternal(i, !this.mFirstLayout, false); } public void setCurrentItem(int i, boolean z2) { this.mPopulatePending = false; setCurrentItemInternal(i, z2, false); } public void setCurrentItemInternal(int i, boolean z2, boolean z3) { setCurrentItemInternal(i, z2, z3, 0); } public void setCurrentItemInternal(int i, boolean z2, boolean z3, int i2) { PagerAdapter pagerAdapter = this.mAdapter; boolean z4 = false; if (pagerAdapter == null || pagerAdapter.getCount() <= 0) { setScrollingCacheEnabled(false); } else if (z3 || this.mCurItem != i || this.mItems.size() == 0) { 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; } } if (this.mCurItem != i) { z4 = true; } if (this.mFirstLayout) { this.mCurItem = i; if (z4) { dispatchOnPageSelected(i); } requestLayout(); return; } populate(i); scrollToItem(i, z2, i2, z4); } else { setScrollingCacheEnabled(false); } } public OnPageChangeListener setInternalPageChangeListener(OnPageChangeListener onPageChangeListener) { OnPageChangeListener onPageChangeListener2 = this.mInternalPageChangeListener; this.mInternalPageChangeListener = onPageChangeListener; return onPageChangeListener2; } public void setOffscreenPageLimit(int i) { if (i < 1) { Log.w("ViewPager", "Requested offscreen page limit " + i + " too small; defaulting to 1"); i = 1; } if (i != this.mOffscreenPageLimit) { this.mOffscreenPageLimit = i; populate(); } } @Deprecated public void setOnPageChangeListener(OnPageChangeListener onPageChangeListener) { this.mOnPageChangeListener = onPageChangeListener; } public void setPageMargin(int i) { int i2 = this.mPageMargin; this.mPageMargin = i; int width = getWidth(); recomputeScrollPosition(width, width, i, i2); requestLayout(); } public void setPageMarginDrawable(@DrawableRes int i) { setPageMarginDrawable(ContextCompat.getDrawable(getContext(), i)); } public void setPageMarginDrawable(@Nullable Drawable drawable) { this.mMarginDrawable = drawable; if (drawable != null) { refreshDrawableState(); } setWillNotDraw(drawable == null); invalidate(); } public void setPageTransformer(boolean z2, @Nullable PageTransformer pageTransformer) { setPageTransformer(z2, pageTransformer, 2); } public void setPageTransformer(boolean z2, @Nullable PageTransformer pageTransformer, int i) { int i2 = 1; boolean z3 = pageTransformer != null; boolean z4 = z3 != (this.mPageTransformer != null); this.mPageTransformer = pageTransformer; setChildrenDrawingOrderEnabled(z3); if (z3) { if (z2) { i2 = 2; } this.mDrawingOrder = i2; this.mPageTransformerLayerType = i; } else { this.mDrawingOrder = 0; } if (z4) { populate(); } } public void setScrollState(int i) { if (this.mScrollState != i) { this.mScrollState = i; if (this.mPageTransformer != null) { enableLayers(i != 0); } dispatchOnScrollStateChanged(i); } } public void smoothScrollTo(int i, int i2) { smoothScrollTo(i, i2, 0); } public void smoothScrollTo(int i, int i2, int i3) { int i4; if (getChildCount() == 0) { setScrollingCacheEnabled(false); return; } Scroller scroller = this.mScroller; if (scroller != null && !scroller.isFinished()) { i4 = this.mIsScrollStarted ? this.mScroller.getCurrX() : this.mScroller.getStartX(); this.mScroller.abortAnimation(); setScrollingCacheEnabled(false); } else { i4 = getScrollX(); } 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 = (float) clientWidth; float f2 = (float) i7; float distanceInfluenceForSnapDuration = (distanceInfluenceForSnapDuration(Math.min(1.0f, (((float) Math.abs(i5)) * 1.0f) / f)) * f2) + f2; int abs = Math.abs(i3); int min = Math.min(abs > 0 ? Math.round(Math.abs(distanceInfluenceForSnapDuration / ((float) abs)) * 1000.0f) * 4 : (int) (((((float) Math.abs(i5)) / ((this.mAdapter.getPageWidth(this.mCurItem) * f) + ((float) this.mPageMargin))) + 1.0f) * 100.0f), 600); this.mIsScrollStarted = false; this.mScroller.startScroll(i4, scrollY, i5, i6, min); ViewCompat.postInvalidateOnAnimation(this); } @Override // android.view.View public boolean verifyDrawable(Drawable drawable) { return super.verifyDrawable(drawable) || drawable == this.mMarginDrawable; } }