package com.kwad.components.ct.detail.viewpager; 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.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; 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.Scroller; import androidx.core.os.ParcelableCompat; import androidx.core.os.ParcelableCompatCreatorCallbacks; import androidx.core.view.AccessibilityDelegateCompat; import androidx.core.view.MotionEventCompat; import androidx.core.view.VelocityTrackerCompat; import androidx.core.view.ViewCompat; import androidx.core.view.ViewConfigurationCompat; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import androidx.core.view.accessibility.AccessibilityRecordCompat; import androidx.core.widget.EdgeEffectCompat; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public class e extends ViewGroup { private static final int[] ahN = {16842931}; private static final Comparator<b> ahP = new Comparator<b>() { /* class com.kwad.components.ct.detail.viewpager.e.AnonymousClass1 */ private static int a(b bVar, b bVar2) { return bVar.position - bVar2.position; } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */ @Override // java.util.Comparator public final /* synthetic */ int compare(b bVar, b bVar2) { return a(bVar, bVar2); } }; private static final Interpolator ahQ = new Interpolator() { /* class com.kwad.components.ct.detail.viewpager.e.AnonymousClass2 */ public final float getInterpolation(float f) { float f2 = f - 1.0f; return (f2 * f2 * f2 * f2 * f2) + 1.0f; } }; private static final i aiN = new i(); private int JE; private int JF; private int ahO; private final ArrayList<b> ahR = new ArrayList<>(); private final b ahS = new b(); private final Rect ahT = new Rect(); private PagerAdapter ahU; private int ahV; private int ahW = -1; private int ahX = -1; private int ahY = -1; private Parcelable ahZ = null; private boolean aiA = true; private boolean aiB = false; private boolean aiC; private int aiD; private long aiE; private List<ViewPager.OnPageChangeListener> aiF; private ViewPager.OnPageChangeListener aiG; private AbstractC0121e aiH; private f aiI; private ViewPager.PageTransformer aiJ; private Method aiK; private int aiL; private ArrayList<View> aiM; private final Runnable aiO = new Runnable() { /* class com.kwad.components.ct.detail.viewpager.e.AnonymousClass3 */ public final void run() { e.this.setScrollState(0); e.this.wW(); e.this.wL(); } }; private int aiP = 0; private ClassLoader aia = null; private Scroller aib; private g aic; private List<DataSetObserver> aid; private int aie; private Drawable aif; private int aig; private int aih; private float aii = -3.4028235E38f; private float aij = Float.MAX_VALUE; private int aik; private int ail; private boolean aim; private boolean ain; private boolean aio; private int aip = 1; private boolean aiq; private int air; private int ais; private float ait; private float aiu; private int aiv; private int aiw; private boolean aix; private EdgeEffectCompat aiy; private EdgeEffectCompat aiz; private float fF; private float fG; private int mActivePointerId = -1; private boolean mIsBeingDragged; protected int mTouchSlop; private VelocityTracker mVelocityTracker; interface a { } public static class b { public Object aiR; boolean aiS; float aiT; float aiU; public int position; } public static class c extends ViewGroup.LayoutParams { float aiT = 0.0f; boolean aiV; int aiW; public int gravity; public boolean isDecor; int position; public c() { super(-1, -1); } public c(Context context, AttributeSet attributeSet) { super(context, attributeSet); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, e.ahN); this.gravity = obtainStyledAttributes.getInteger(0, 48); obtainStyledAttributes.recycle(); } } /* access modifiers changed from: package-private */ public class d extends AccessibilityDelegateCompat { d() { } private boolean xf() { return e.this.ahU != null && e.this.ahU.getCount() > 1; } @Override // androidx.core.view.AccessibilityDelegateCompat public final void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) { super.onInitializeAccessibilityEvent(view, accessibilityEvent); accessibilityEvent.setClassName(ViewPager.class.getName()); AccessibilityRecordCompat obtain = AccessibilityRecordCompat.obtain(); obtain.setScrollable(xf()); if (accessibilityEvent.getEventType() == 4096 && e.this.ahU != null) { obtain.setItemCount(e.this.ahU.getCount()); obtain.setFromIndex(e.this.ahV); obtain.setToIndex(e.this.ahV); } } @Override // androidx.core.view.AccessibilityDelegateCompat public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); accessibilityNodeInfoCompat.setClassName(ViewPager.class.getName()); accessibilityNodeInfoCompat.setScrollable(xf()); if (e.this.bh(1)) { accessibilityNodeInfoCompat.addAction(4096); } if (e.this.bh(-1)) { accessibilityNodeInfoCompat.addAction(8192); } } @Override // androidx.core.view.AccessibilityDelegateCompat public final boolean performAccessibilityAction(View view, int i, Bundle bundle) { e eVar; int i2; if (super.performAccessibilityAction(view, i, bundle)) { return true; } if (i != 4096) { if (i != 8192 || !e.this.bh(-1)) { return false; } eVar = e.this; i2 = eVar.ahV - 1; } else if (!e.this.bh(1)) { return false; } else { eVar = e.this; i2 = eVar.ahV + 1; } eVar.setCurrentItem(i2); return true; } } /* renamed from: com.kwad.components.ct.detail.viewpager.e$e reason: collision with other inner class name */ interface AbstractC0121e { } public interface f { void wL(); } /* access modifiers changed from: package-private */ public class g extends DataSetObserver { private g() { } /* synthetic */ g(e eVar, byte b) { this(); } public final void onChanged() { e.this.wV(); e.this.wY(); } public final void onInvalidated() { e.this.wV(); e.this.wZ(); } } public static class h extends View.BaseSavedState { public static final Parcelable.Creator<h> CREATOR = ParcelableCompat.newCreator(new ParcelableCompatCreatorCallbacks<h>() { /* class com.kwad.components.ct.detail.viewpager.e.h.AnonymousClass1 */ private static h a(Parcel parcel, ClassLoader classLoader) { return new h(parcel, classLoader); } private static h[] bi(int i) { return new h[i]; } /* Return type fixed from 'java.lang.Object' to match base method */ @Override // androidx.core.os.ParcelableCompatCreatorCallbacks public final /* synthetic */ h createFromParcel(Parcel parcel, ClassLoader classLoader) { return a(parcel, classLoader); } /* Return type fixed from 'java.lang.Object[]' to match base method */ @Override // androidx.core.os.ParcelableCompatCreatorCallbacks public final /* synthetic */ h[] newArray(int i) { return bi(i); } }); Parcelable aiX; ClassLoader aiY; int position; h(Parcel parcel, ClassLoader classLoader) { super(parcel); classLoader = classLoader == null ? getClass().getClassLoader() : classLoader; this.position = parcel.readInt(); this.aiX = parcel.readParcelable(classLoader); this.aiY = classLoader; } public final String toString() { return "FragmentPager.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " position=" + this.position + "}"; } public final void writeToParcel(Parcel parcel, int i) { super.writeToParcel(parcel, i); parcel.writeInt(this.position); parcel.writeParcelable(this.aiX, i); } } /* access modifiers changed from: package-private */ public static class i implements Comparator<View> { i() { } private static int compare(View view, View view2) { c cVar = (c) view.getLayoutParams(); c cVar2 = (c) view2.getLayoutParams(); return cVar.isDecor != cVar2.isDecor ? cVar.isDecor ? 1 : -1 : cVar.position - cVar2.position; } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */ @Override // java.util.Comparator public final /* bridge */ /* synthetic */ int compare(View view, View view2) { return compare(view, view2); } } public e(Context context) { super(context); wT(); } public e(Context context, AttributeSet attributeSet) { super(context, attributeSet); wT(); } private b D(View view) { for (int i2 = 0; i2 < this.ahR.size(); i2++) { b bVar = this.ahR.get(i2); if (this.ahU.isViewFromObject(view, bVar.aiR)) { return bVar; } } return null; } private b E(View view) { while (true) { ViewParent parent = view.getParent(); if (parent == this) { return D(view); } if (parent == null || !(parent instanceof View)) { return null; } view = (View) parent; } } private Rect a(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; } private void a(int i2, float f2, int i3) { List<ViewPager.OnPageChangeListener> list = this.aiF; if (list != null) { int size = list.size(); for (int i4 = 0; i4 < size; i4++) { ViewPager.OnPageChangeListener onPageChangeListener = this.aiF.get(i4); if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(i2, f2, i3); } } } ViewPager.OnPageChangeListener onPageChangeListener2 = this.aiG; if (onPageChangeListener2 != null) { onPageChangeListener2.onPageScrolled(i2, f2, i3); } } private void a(int i2, int i3, int i4, int i5) { if (i3 <= 0 || this.ahR.isEmpty()) { b bf = bf(this.ahV); int min = (int) ((bf != null ? Math.min(bf.aiU, this.aij) : 0.0f) * ((float) ((i2 - getPaddingTop()) - getPaddingBottom()))); if (min != getScrollY()) { bj(false); scrollTo(getScrollX(), min); return; } return; } int scrollY = (int) ((((float) getScrollY()) / ((float) (((i3 - getPaddingTop()) - getPaddingBottom()) + i5))) * ((float) (((i2 - getPaddingTop()) - getPaddingBottom()) + i4))); scrollTo(getScrollX(), scrollY); if (!this.aib.isFinished()) { this.aib.startScroll(0, scrollY, 0, (int) (bf(this.ahV).aiU * ((float) i2)), this.aib.getDuration() - this.aib.timePassed()); } } private void a(int i2, int i3, int i4, boolean z) { int i5; if (getChildCount() == 0) { setScrollingCacheEnabled(false); return; } int scrollX = getScrollX(); int scrollY = getScrollY(); int i6 = 0 - scrollX; int i7 = i3 - scrollY; if (i6 == 0 && i7 == 0) { bj(false); wW(); if (z) { wL(); } setScrollState(0); return; } setScrollingCacheEnabled(true); setScrollState(2); int clientHeight = getClientHeight(); int i8 = clientHeight / 2; float f2 = (float) clientHeight; float f3 = (float) i8; float o = f3 + (o(Math.min(1.0f, (((float) Math.abs(i7)) * 1.0f) / f2)) * f3); int abs = Math.abs(i4); if (abs > 0) { i5 = Math.round(Math.abs(o / ((float) abs)) * 1000.0f) * 4; } else { i5 = ((int) (((((float) Math.abs(i7)) / ((f2 * this.ahU.getPageWidth(this.ahV)) + ((float) this.aie))) + 1.0f) * 100.0f)) * 2; } this.aib.startScroll(scrollX, scrollY, i6, i7, Math.min(i5, 600)); ViewCompat.postInvalidateOnAnimation(this); } private void a(int i2, boolean z, int i3, boolean z2, boolean z3) { b bf = bf(i2); int clientHeight = bf != null ? (int) (((float) getClientHeight()) * Math.max(this.aii, Math.min(bf.aiU, this.aij))) : 0; if (z) { a(0, clientHeight, i3, z3); if (z2) { bc(i2); return; } return; } if (z2) { bc(i2); } bj(false); scrollTo(0, clientHeight); bg(clientHeight); if (z2 && this.aiP != 2) { wL(); } } private void a(int i2, boolean z, boolean z2, int i3) { a(i2, z, z2, 0, false); } private void a(int i2, boolean z, boolean z2, int i3, boolean z3) { int i4; PagerAdapter pagerAdapter = this.ahU; if (pagerAdapter == null || pagerAdapter.getCount() <= 0) { setScrollingCacheEnabled(false); } else if (z2 || this.ahV != i2 || this.ahR.size() == 0) { if (i2 < 0) { i4 = 0; } else { if (i2 >= this.ahU.getCount()) { i2 = this.ahU.getCount() - 1; } i4 = i2; } int i5 = this.aip; int i6 = this.ahV; if (i4 > i6 + i5 || i4 < i6 - i5) { for (int i7 = 0; i7 < this.ahR.size(); i7++) { this.ahR.get(i7).aiS = true; } } boolean z4 = this.ahV != i4; if (this.aiA) { this.ahW = i4; this.ahV = i4; if (z4) { bc(i4); } requestLayout(); return; } be(i4); a(i4, z, i3, z4, z3); } else { setScrollingCacheEnabled(false); } } private void a(b bVar, int i2, b bVar2) { b bVar3; b bVar4; int count = this.ahU.getCount(); int clientHeight = getClientHeight(); float f2 = clientHeight > 0 ? ((float) this.aie) / ((float) clientHeight) : 0.0f; if (bVar2 != null) { int i3 = bVar2.position; if (i3 < bVar.position) { float f3 = bVar2.aiU + bVar2.aiT + f2; int i4 = i3 + 1; int i5 = 0; while (i4 <= bVar.position && i5 < this.ahR.size()) { while (true) { bVar4 = this.ahR.get(i5); if (i4 > bVar4.position && i5 < this.ahR.size() - 1) { i5++; } } while (i4 < bVar4.position) { f3 += this.ahU.getPageWidth(i4) + f2; i4++; } bVar4.aiU = f3; f3 += bVar4.aiT + f2; i4++; } } else if (i3 > bVar.position) { int size = this.ahR.size() - 1; float f4 = bVar2.aiU; while (true) { i3--; if (i3 < bVar.position || size < 0) { break; } while (true) { bVar3 = this.ahR.get(size); if (i3 < bVar3.position && size > 0) { size--; } } while (i3 > bVar3.position) { f4 -= this.ahU.getPageWidth(i3) + f2; i3--; } f4 -= bVar3.aiT + f2; bVar3.aiU = f4; } } } int size2 = this.ahR.size(); float f5 = bVar.aiU; int i6 = bVar.position - 1; this.aii = bVar.position == 0 ? bVar.aiU : -3.4028235E38f; int i7 = count - 1; this.aij = bVar.position == i7 ? (bVar.aiU + bVar.aiT) - 1.0f : Float.MAX_VALUE; int i8 = i2 - 1; while (i8 >= 0) { b bVar5 = this.ahR.get(i8); while (i6 > bVar5.position) { f5 -= this.ahU.getPageWidth(i6) + f2; i6--; } f5 -= bVar5.aiT + f2; bVar5.aiU = f5; if (bVar5.position == 0) { this.aii = f5; } i8--; i6--; } float f6 = bVar.aiU + bVar.aiT + f2; int i9 = bVar.position + 1; int i10 = i2 + 1; while (i10 < size2) { b bVar6 = this.ahR.get(i10); while (i9 < bVar6.position) { f6 += this.ahU.getPageWidth(i9) + f2; i9++; } if (bVar6.position == i7) { this.aij = (bVar6.aiT + f6) - 1.0f; } bVar6.aiU = f6; f6 += bVar6.aiT + f2; i10++; i9++; } this.aiB = false; } /* JADX WARNING: Code restructure failed: missing block: B:23:0x008a, code lost: if (r1 >= r2) goto L_0x00b8; */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x00a6, code lost: if (r1 <= r2) goto L_0x00b3; */ /* JADX WARNING: Code restructure failed: missing block: B:33:0x00b1, code lost: if (r7 != 2) goto L_0x00bc; */ /* JADX WARNING: Removed duplicated region for block: B:32:0x00b0 */ /* JADX WARNING: Removed duplicated region for block: B:37:0x00be */ private boolean arrowScroll(int i2) { View findNextFocus; boolean z; View findFocus = findFocus(); boolean z2 = false; if (findFocus != this) { if (findFocus != null) { ViewParent parent = findFocus.getParent(); while (true) { if (!(parent instanceof ViewGroup)) { z = false; break; } else if (parent == this) { z = true; break; } else { parent = parent.getParent(); } } if (!z) { 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()); } com.kwad.sdk.core.e.b.d("VerticalViewPager", "arrowScroll tried to find focus based on non-child current focused view " + sb.toString()); } } findNextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, i2); if (findNextFocus != null || findNextFocus == findFocus) { if (!(i2 == 33 || i2 == 1)) { if (i2 != 130) { } } z2 = xc(); if (z2) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(i2)); } return z2; } if (i2 == 33) { int i3 = a(this.ahT, findNextFocus).top; int i4 = a(this.ahT, findFocus).top; if (findFocus != null) { } } else { if (i2 == 130) { int i5 = a(this.ahT, findNextFocus).bottom; int i6 = a(this.ahT, findFocus).bottom; if (findFocus != null) { } } if (z2) { } return z2; } z2 = findNextFocus.requestFocus(); if (z2) { } return z2; z2 = xd(); if (z2) { } return z2; } findFocus = null; findNextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, i2); if (findNextFocus != null) { } if (i2 != 130) { } z2 = xd(); if (z2) { } return z2; } private void bc(int i2) { List<ViewPager.OnPageChangeListener> list = this.aiF; if (list != null) { int size = list.size(); for (int i3 = 0; i3 < size; i3++) { ViewPager.OnPageChangeListener onPageChangeListener = this.aiF.get(i3); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(i2); } } } ViewPager.OnPageChangeListener onPageChangeListener2 = this.aiG; if (onPageChangeListener2 != null) { onPageChangeListener2.onPageSelected(i2); } } private void bd(int i2) { List<ViewPager.OnPageChangeListener> list = this.aiF; if (list != null) { int size = list.size(); for (int i3 = 0; i3 < size; i3++) { ViewPager.OnPageChangeListener onPageChangeListener = this.aiF.get(i3); if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(i2); } } } ViewPager.OnPageChangeListener onPageChangeListener2 = this.aiG; if (onPageChangeListener2 != null) { onPageChangeListener2.onPageScrollStateChanged(i2); } } /* JADX WARNING: Code restructure failed: missing block: B:29:0x0072, code lost: if (r10.position == r17.ahV) goto L_0x0079; */ /* JADX WARNING: Code restructure failed: missing block: B:56:0x00d2, code lost: if (r1 >= 0) goto L_0x00f0; */ /* JADX WARNING: Code restructure failed: missing block: B:61:0x00e0, code lost: if (r1 >= 0) goto L_0x00f0; */ /* JADX WARNING: Code restructure failed: missing block: B:63:0x00ee, code lost: if (r1 >= 0) goto L_0x00f0; */ /* JADX WARNING: Code restructure failed: missing block: B:65:0x00f9, code lost: r11 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:89:0x014c, code lost: if (r3 < r17.ahR.size()) goto L_0x014e; */ /* JADX WARNING: Code restructure failed: missing block: B:91:0x0157, code lost: r5 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:96:0x016a, code lost: if (r3 < r17.ahR.size()) goto L_0x014e; */ /* JADX WARNING: Code restructure failed: missing block: B:98:0x017c, code lost: if (r3 < r17.ahR.size()) goto L_0x014e; */ private void be(int i2) { int i3; b bVar; String str; b bVar2; b D; int i4 = this.ahV; if (i4 != i2) { i3 = i4 < i2 ? 130 : 33; bVar = bf(i4); int i5 = this.ahV; if (i5 != i2) { this.ahW = i5; } this.ahV = i2; } else { i3 = 2; bVar = null; } if (this.ahU == null) { wX(); } else if (this.aio) { wX(); } else if (getWindowToken() != null) { this.ahU.startUpdate((ViewGroup) this); int i6 = this.aip; int max = Math.max(0, this.ahV - i6); int count = this.ahU.getCount(); int min = Math.min(count - 1, this.ahV + i6); if (count == this.ahO) { int i7 = 0; while (true) { if (i7 >= this.ahR.size()) { break; } bVar2 = this.ahR.get(i7); if (bVar2.position < this.ahV) { i7++; } } bVar2 = null; if (bVar2 == null && count > 0) { bVar2 = r(this.ahV, i7); } if (bVar2 != null && i6 > 0) { int i8 = i7 - 1; b bVar3 = i8 >= 0 ? this.ahR.get(i8) : null; int clientHeight = getClientHeight(); float paddingLeft = clientHeight <= 0 ? 0.0f : (2.0f - bVar2.aiT) + (((float) getPaddingLeft()) / ((float) clientHeight)); float f2 = 0.0f; for (int i9 = this.ahV - 1; i9 >= 0; i9--) { if (f2 >= paddingLeft && i9 < max) { if (bVar3 == null) { break; } if (i9 == bVar3.position && !bVar3.aiS) { this.ahR.remove(i8); this.ahU.destroyItem((ViewGroup) this, i9, bVar3.aiR); i8--; i7--; } } else if (bVar3 == null || i9 != bVar3.position) { f2 += r(i9, i8 + 1).aiT; i7++; } else { f2 += bVar3.aiT; i8--; } b bVar4 = this.ahR.get(i8); bVar3 = bVar4; } float f3 = bVar2.aiT; int i10 = i7 + 1; if (f3 < 2.0f) { b bVar5 = i10 < this.ahR.size() ? this.ahR.get(i10) : null; float paddingRight = clientHeight <= 0 ? 0.0f : (((float) getPaddingRight()) / ((float) clientHeight)) + 2.0f; int i11 = this.ahV; while (true) { i11++; if (i11 >= count) { break; } if (f3 >= paddingRight && i11 > min) { if (bVar5 == null) { break; } else if (i11 == bVar5.position && !bVar5.aiS) { this.ahR.remove(i10); this.ahU.destroyItem((ViewGroup) this, i11, bVar5.aiR); } } else if (bVar5 == null || i11 != bVar5.position) { b r = r(i11, i10); i10++; f3 += r.aiT; } else { f3 += bVar5.aiT; i10++; } bVar5 = this.ahR.get(i10); } } a(bVar2, i7, bVar); } this.ahU.setPrimaryItem((ViewGroup) this, this.ahV, bVar2 != null ? bVar2.aiR : null); this.ahU.finishUpdate((ViewGroup) this); int childCount = getChildCount(); for (int i12 = 0; i12 < childCount; i12++) { View childAt = getChildAt(i12); c cVar = (c) childAt.getLayoutParams(); cVar.aiW = i12; if (!cVar.isDecor) { if (cVar.aiT == 0.0f && (D = D(childAt)) != null) { cVar.aiT = D.aiT; cVar.position = D.position; } } } wX(); if (hasFocus()) { View findFocus = findFocus(); b E = findFocus != null ? E(findFocus) : null; if (E == null || E.position != this.ahV) { for (int i13 = 0; i13 < getChildCount(); i13++) { View childAt2 = getChildAt(i13); b D2 = D(childAt2); if (D2 != null && D2.position == this.ahV && childAt2.requestFocus(i3)) { return; } } return; } return; } return; } try { str = getResources().getResourceName(getId()); } catch (Resources.NotFoundException unused) { str = Integer.toHexString(getId()); } throw new IllegalStateException("The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: " + this.ahO + ", found: " + count + " Pager id: " + str + " Pager class: " + getClass() + " Problematic adapter: " + this.ahU.getClass()); } } private b bf(int i2) { for (int i3 = 0; i3 < this.ahR.size(); i3++) { b bVar = this.ahR.get(i3); if (bVar.position == i2) { return bVar; } } return null; } private boolean bg(int i2) { if (this.ahR.size() == 0) { this.aiC = false; onPageScrolled(0, 0.0f, 0); if (this.aiC) { return false; } throw new IllegalStateException("onPageScrolled did not call superclass implementation"); } b xa = xa(); int clientHeight = getClientHeight(); int i3 = this.aie; int i4 = clientHeight + i3; float f2 = (float) clientHeight; int i5 = xa.position; float f3 = ((((float) i2) / f2) - xa.aiU) / (xa.aiT + (((float) i3) / f2)); this.aiC = false; onPageScrolled(i5, f3, (int) (((float) i4) * f3)); if (this.aiC) { return true; } throw new IllegalStateException("onPageScrolled did not call superclass implementation"); } private void bj(boolean z) { boolean z2 = this.aiP == 2; if (z2) { setScrollingCacheEnabled(false); this.aib.abortAnimation(); int scrollX = getScrollX(); int scrollY = getScrollY(); int currX = this.aib.getCurrX(); int currY = this.aib.getCurrY(); if (!(scrollX == currX && scrollY == currY)) { scrollTo(currX, currY); } } this.aio = false; for (int i2 = 0; i2 < this.ahR.size(); i2++) { b bVar = this.ahR.get(i2); if (bVar.aiS) { bVar.aiS = false; z2 = true; } } if (!z2) { return; } if (z) { ViewCompat.postOnAnimation(this, this.aiO); } else { this.aiO.run(); } } private void bk(boolean z) { int childCount = getChildCount(); for (int i2 = 0; i2 < childCount; i2++) { ViewCompat.setLayerType(getChildAt(i2), z ? 2 : 0, null); } } private void bl(boolean z) { ViewParent parent = getParent(); if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); } } private boolean canScroll(View view, boolean z, int i2, int i3, int i4) { int i5; int i6; 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); if (childAt.isEnabled() && childAt.getVisibility() == 0 && (i5 = i4 + scrollY) >= childAt.getTop() && i5 < childAt.getBottom() && (i6 = i3 + scrollX) >= childAt.getLeft() && i6 < childAt.getRight() && canScroll(childAt, true, i2, i6 - childAt.getLeft(), i5 - childAt.getTop())) { return true; } } } return z && ViewCompat.canScrollVertically(view, -i2); } private void e(MotionEvent motionEvent) { int actionIndex = MotionEventCompat.getActionIndex(motionEvent); if (MotionEventCompat.getPointerId(motionEvent, actionIndex) == this.mActivePointerId) { int i2 = actionIndex == 0 ? 1 : 0; this.aiu = getY(motionEvent, i2); this.mActivePointerId = MotionEventCompat.getPointerId(motionEvent, i2); VelocityTracker velocityTracker = this.mVelocityTracker; if (velocityTracker != null) { velocityTracker.clear(); } } } private boolean executeKeyEvent(KeyEvent keyEvent) { int i2; if (keyEvent.getAction() == 0) { int keyCode = keyEvent.getKeyCode(); if (keyCode == 21) { i2 = 17; } else if (keyCode == 22) { i2 = 66; } else if (keyCode == 61 && Build.VERSION.SDK_INT >= 11) { if (keyEvent.hasNoModifiers()) { i2 = 2; } else if (keyEvent.hasModifiers(1)) { return arrowScroll(1); } } return arrowScroll(i2); } return false; } private int getClientHeight() { return (getMeasuredHeight() - getPaddingTop()) - getPaddingBottom(); } private static float getX(MotionEvent motionEvent, int i2) { return (i2 == -1 || motionEvent.getPointerCount() <= i2) ? motionEvent.getX() : MotionEventCompat.getX(motionEvent, i2); } private static float getY(MotionEvent motionEvent, int i2) { return (i2 == -1 || motionEvent.getPointerCount() <= i2) ? motionEvent.getY() : MotionEventCompat.getY(motionEvent, i2); } private boolean h(float f2, float f3) { if (f2 >= ((float) this.ais) || f3 <= 0.0f) { return f2 > ((float) (getHeight() - this.ais)) && f3 < 0.0f; } return true; } private static float o(float f2) { return (float) Math.sin((double) ((float) (((double) (f2 - 0.5f)) * 0.4712389167638204d))); } /* JADX WARNING: Removed duplicated region for block: B:19:0x0066 */ private void onPageScrolled(int i2, float f2, int i3) { int i4; int top; int i5; if (this.aiD > 0) { int scrollY = getScrollY(); int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); int height = getHeight(); int childCount = getChildCount(); for (int i6 = 0; i6 < childCount; i6++) { View childAt = getChildAt(i6); c cVar = (c) childAt.getLayoutParams(); if (cVar.isDecor) { int i7 = cVar.gravity & 112; if (i7 != 16) { if (i7 == 48) { i4 = childAt.getHeight() + paddingTop; } else if (i7 != 80) { i4 = paddingTop; } else { i5 = (height - paddingBottom) - childAt.getMeasuredHeight(); paddingBottom += childAt.getMeasuredHeight(); } top = (paddingTop + scrollY) - childAt.getTop(); if (top != 0) { childAt.offsetTopAndBottom(top); } paddingTop = i4; } else { i5 = Math.max((height - childAt.getMeasuredHeight()) / 2, paddingTop); } i4 = paddingTop; paddingTop = i5; top = (paddingTop + scrollY) - childAt.getTop(); if (top != 0) { } paddingTop = i4; } } } a(i2, f2, i3); if (this.aiJ != null) { int scrollY2 = getScrollY(); int childCount2 = getChildCount(); for (int i8 = 0; i8 < childCount2; i8++) { View childAt2 = getChildAt(i8); if (!((c) childAt2.getLayoutParams()).isDecor) { this.aiJ.transformPage(childAt2, ((float) (childAt2.getTop() - scrollY2)) / ((float) getClientHeight())); } } } this.aiC = true; } /* JADX WARNING: Removed duplicated region for block: B:13:0x005a */ /* JADX WARNING: Removed duplicated region for block: B:16:0x006b */ private boolean p(float f2) { boolean z; boolean z2; float f3 = this.aiu - f2; this.aiu = f2; float scrollY = ((float) getScrollY()) + f3; float clientHeight = (float) getClientHeight(); float f4 = this.aii * clientHeight; float f5 = this.aij * clientHeight; boolean z3 = true; boolean z4 = false; if (this.ahR.size() > 0) { b bVar = this.ahR.get(0); ArrayList<b> arrayList = this.ahR; b bVar2 = arrayList.get(arrayList.size() - 1); if (bVar.position != 0) { f4 = bVar.aiU * clientHeight; z2 = false; } else { z2 = true; } if (bVar2.position != this.ahU.getCount() - 1) { f5 = bVar2.aiU * clientHeight; z3 = z2; z = false; if (scrollY >= f4) { if (z3) { z4 = this.aiy.onPull(Math.abs(f4 - scrollY) / clientHeight); } scrollY = f4; } else if (scrollY > f5) { if (z) { z4 = this.aiz.onPull(Math.abs(scrollY - f5) / clientHeight); } scrollY = f5; } int i2 = (int) scrollY; this.ait += scrollY - ((float) i2); int ba = ba(i2); scrollTo(getScrollX(), ba); bg(ba(ba)); return z4; } z3 = z2; } z = true; if (scrollY >= f4) { } int i22 = (int) scrollY; this.ait += scrollY - ((float) i22); int ba2 = ba(i22); scrollTo(getScrollX(), ba2); bg(ba(ba2)); return z4; } private b r(int i2, int i3) { b bVar = new b(); bVar.position = i2; bVar.aiR = this.ahU.instantiateItem((ViewGroup) this, i2); bVar.aiT = this.ahU.getPageWidth(i2); if (i3 < 0 || i3 >= this.ahR.size()) { this.ahR.add(bVar); } else { this.ahR.add(i3, bVar); } return bVar; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void setScrollState(int i2) { if (this.aiP != i2) { this.aiP = i2; if (this.aiJ != null) { bk(i2 != 0); } bd(i2); } } private void setScrollingCacheEnabled(boolean z) { if (this.ain != z) { this.ain = z; } } private void wT() { setWillNotDraw(false); setDescendantFocusability(262144); setFocusable(true); Context context = getContext(); this.aib = new Scroller(context, ahQ); ViewConfiguration viewConfiguration = ViewConfiguration.get(context); float f2 = context.getResources().getDisplayMetrics().density; this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(viewConfiguration); this.JE = (int) (400.0f * f2); this.JF = viewConfiguration.getScaledMaximumFlingVelocity(); this.aiy = new EdgeEffectCompat(context); this.aiz = new EdgeEffectCompat(context); this.aiv = (int) (25.0f * f2); this.aiw = (int) (2.0f * f2); this.air = (int) (f2 * 16.0f); ViewCompat.setAccessibilityDelegate(this, new d()); if (ViewCompat.getImportantForAccessibility(this) == 0) { ViewCompat.setImportantForAccessibility(this, 1); } } private void wU() { int i2 = 0; while (i2 < getChildCount()) { if (!((c) getChildAt(i2).getLayoutParams()).isDecor) { removeViewAt(i2); i2--; } i2++; } } private void wX() { if (this.aiL != 0) { ArrayList<View> arrayList = this.aiM; if (arrayList == null) { this.aiM = new ArrayList<>(); } else { arrayList.clear(); } int childCount = getChildCount(); for (int i2 = 0; i2 < childCount; i2++) { this.aiM.add(getChildAt(i2)); } Collections.sort(this.aiM, aiN); } } private b xa() { int i2; int clientHeight = getClientHeight(); float f2 = 0.0f; float scrollY = clientHeight > 0 ? ((float) getScrollY()) / ((float) clientHeight) : 0.0f; float f3 = clientHeight > 0 ? ((float) this.aie) / ((float) clientHeight) : 0.0f; b bVar = null; float f4 = 0.0f; int i3 = -1; int i4 = 0; boolean z = true; while (i4 < this.ahR.size()) { b bVar2 = this.ahR.get(i4); if (!z && bVar2.position != (i2 = i3 + 1)) { bVar2 = this.ahS; bVar2.aiU = f2 + f4 + f3; bVar2.position = i2; bVar2.aiT = this.ahU.getPageWidth(bVar2.position); i4--; } f2 = bVar2.aiU; float f5 = bVar2.aiT + f2 + f3; if (!z && scrollY < f2) { return bVar; } if (scrollY < f5 || i4 == this.ahR.size() - 1) { return bVar2; } i3 = bVar2.position; f4 = bVar2.aiT; i4++; bVar = bVar2; z = false; } return bVar; } private void xb() { this.mIsBeingDragged = false; this.aiq = false; VelocityTracker velocityTracker = this.mVelocityTracker; if (velocityTracker != null) { velocityTracker.recycle(); this.mVelocityTracker = null; } } private boolean xc() { int i2 = this.ahV; if (i2 <= 0) { return false; } setCurrentItem(i2 - 1, true); return true; } private boolean xd() { PagerAdapter pagerAdapter = this.ahU; if (pagerAdapter == null || this.ahV >= pagerAdapter.getCount() - 1) { return false; } setCurrentItem(this.ahV + 1, true); return true; } /* access modifiers changed from: protected */ public int a(int i2, float f2, int i3, int i4) { if (Math.abs(i4) <= this.aiv || Math.abs(i3) <= this.JE) { i2 = (int) (((float) i2) + f2 + (i2 >= this.ahV ? 0.4f : 0.6f)); } else if (i3 <= 0) { i2++; } if (this.ahR.size() <= 0) { return i2; } ArrayList<b> arrayList = this.ahR; return Math.max(this.ahR.get(0).position, Math.min(i2, arrayList.get(arrayList.size() - 1).position)); } /* access modifiers changed from: protected */ public void a(int i2, boolean z, boolean z2) { a(i2, z, z2, 0); } public final void a(DataSetObserver dataSetObserver) { if (this.aid == null) { this.aid = new ArrayList(); } this.aid.add(dataSetObserver); } @Override // android.view.View, android.view.ViewGroup public void addFocusables(ArrayList<View> arrayList, int i2, int i3) { b D; int size = arrayList.size(); int descendantFocusability = getDescendantFocusability(); if (descendantFocusability != 393216) { for (int i4 = 0; i4 < getChildCount(); i4++) { View childAt = getChildAt(i4); if (childAt.getVisibility() == 0 && (D = D(childAt)) != null && D.position == this.ahV) { childAt.addFocusables(arrayList, i2, i3); } } } if ((descendantFocusability == 262144 && size != arrayList.size()) || !isFocusable()) { return; } if (((i3 & 1) != 1 || !isInTouchMode() || isFocusableInTouchMode()) && arrayList != null) { arrayList.add(this); } } public final void addOnPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { if (this.aiF == null) { this.aiF = new ArrayList(); } this.aiF.add(onPageChangeListener); } @Override // android.view.View, android.view.ViewGroup public void addTouchables(ArrayList<View> arrayList) { b D; for (int i2 = 0; i2 < getChildCount(); i2++) { View childAt = getChildAt(i2); if (childAt.getVisibility() == 0 && (D = D(childAt)) != null && D.position == this.ahV) { childAt.addTouchables(arrayList); } } } @Override // android.view.ViewGroup public void addView(View view, int i2, ViewGroup.LayoutParams layoutParams) { if (!checkLayoutParams(layoutParams)) { layoutParams = generateLayoutParams(layoutParams); } c cVar = (c) layoutParams; cVar.isDecor |= view instanceof a; if (!this.aim) { if (view.getParent() instanceof ViewGroup) { ((ViewGroup) view.getParent()).removeView(view); } super.addView(view, i2, layoutParams); } else if (cVar == null || !cVar.isDecor) { cVar.aiV = true; addViewInLayout(view, i2, layoutParams); } else { throw new IllegalStateException("Cannot add pager decor view during layout"); } } public final void b(DataSetObserver dataSetObserver) { List<DataSetObserver> list = this.aid; if (list != null) { list.remove(dataSetObserver); } } /* access modifiers changed from: protected */ public int ba(int i2) { return i2; } public final boolean bh(int i2) { if (this.ahU == null) { return false; } int clientHeight = getClientHeight(); int scrollY = getScrollY(); return i2 < 0 ? scrollY > ((int) (((float) clientHeight) * this.aii)) : i2 > 0 && scrollY < ((int) (((float) clientHeight) * this.aij)); } /* access modifiers changed from: protected */ public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) { return (layoutParams instanceof c) && super.checkLayoutParams(layoutParams); } public void computeScroll() { if (this.aib.isFinished() || !this.aib.computeScrollOffset()) { bj(true); return; } int scrollX = getScrollX(); int scrollY = getScrollY(); int currX = this.aib.getCurrX(); int currY = this.aib.getCurrY(); if (!(scrollX == currX && scrollY == currY)) { scrollTo(currX, currY); if (!bg(currY)) { this.aib.abortAnimation(); scrollTo(currX, 0); } } ViewCompat.postInvalidateOnAnimation(this); } public boolean dispatchKeyEvent(KeyEvent keyEvent) { return super.dispatchKeyEvent(keyEvent) || executeKeyEvent(keyEvent); } public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) { b D; if (accessibilityEvent.getEventType() == 4096) { return super.dispatchPopulateAccessibilityEvent(accessibilityEvent); } int childCount = getChildCount(); for (int i2 = 0; i2 < childCount; i2++) { View childAt = getChildAt(i2); if (childAt.getVisibility() == 0 && (D = D(childAt)) != null && D.position == this.ahV && childAt.dispatchPopulateAccessibilityEvent(accessibilityEvent)) { return true; } } return false; } public void draw(Canvas canvas) { PagerAdapter pagerAdapter; super.draw(canvas); int overScrollMode = ViewCompat.getOverScrollMode(this); boolean z = false; if (overScrollMode == 0 || (overScrollMode == 1 && (pagerAdapter = this.ahU) != null && pagerAdapter.getCount() > 1)) { if (!this.aiy.isFinished()) { int save = canvas.save(); int height = getHeight(); int width = (getWidth() - getPaddingLeft()) - getPaddingRight(); canvas.translate((float) getPaddingLeft(), this.aii * ((float) height)); this.aiy.setSize(width, height); z = false | this.aiy.draw(canvas); canvas.restoreToCount(save); } if (!this.aiz.isFinished()) { int save2 = canvas.save(); int height2 = getHeight(); int width2 = (getWidth() - getPaddingLeft()) - getPaddingRight(); canvas.rotate(180.0f); canvas.translate((float) ((-width2) - getPaddingLeft()), (-(this.aij + 1.0f)) * ((float) height2)); this.aiz.setSize(width2, height2); z |= this.aiz.draw(canvas); canvas.restoreToCount(save2); } } else { this.aiy.finish(); this.aiz.finish(); } if (z) { ViewCompat.postInvalidateOnAnimation(this); } } /* access modifiers changed from: protected */ public void drawableStateChanged() { super.drawableStateChanged(); Drawable drawable = this.aif; if (drawable != null && drawable.isStateful()) { drawable.setState(getDrawableState()); } } /* access modifiers changed from: protected */ public ViewGroup.LayoutParams generateDefaultLayoutParams() { return new c(); } @Override // android.view.ViewGroup public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) { return new c(getContext(), attributeSet); } /* access modifiers changed from: protected */ @Override // android.view.ViewGroup public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) { return generateDefaultLayoutParams(); } public PagerAdapter getAdapter() { return this.ahU; } /* access modifiers changed from: protected */ public int getChildDrawingOrder(int i2, int i3) { if (this.aiL == 2) { i3 = (i2 - 1) - i3; } return ((c) this.aiM.get(i3).getLayoutParams()).aiW; } public int getCurrentItem() { return this.ahV; } public int getOffscreenPageLimit() { return this.aip; } public int getPageMargin() { return this.aie; } public int getPreItem() { return this.ahW; } /* access modifiers changed from: protected */ public void onAttachedToWindow() { super.onAttachedToWindow(); this.aiA = true; } /* access modifiers changed from: protected */ public void onDetachedFromWindow() { com.kwad.sdk.core.e.b.i("VerticalViewPager", "onDetachedFromWindow"); removeCallbacks(this.aiO); super.onDetachedFromWindow(); } /* access modifiers changed from: protected */ public void onDraw(Canvas canvas) { float f2; float f3; float f4; super.onDraw(canvas); if (this.aie > 0 && this.aif != null && this.ahR.size() > 0 && this.ahU != null) { int scrollY = getScrollY(); int height = getHeight(); float f5 = (float) height; float f6 = ((float) this.aie) / f5; int i2 = 0; b bVar = this.ahR.get(0); float f7 = bVar.aiU; int size = this.ahR.size(); int i3 = bVar.position; int i4 = this.ahR.get(size - 1).position; while (i3 < i4) { while (i3 > bVar.position && i2 < size) { i2++; bVar = this.ahR.get(i2); } if (i3 == bVar.position) { f3 = (bVar.aiU + bVar.aiT) * f5; f2 = bVar.aiU + bVar.aiT + f6; } else { float pageWidth = this.ahU.getPageWidth(i3); f2 = f7 + pageWidth + f6; f3 = (f7 + pageWidth) * f5; } int i5 = this.aie; if (((float) i5) + f3 > ((float) scrollY)) { f4 = f6; this.aif.setBounds(this.aig, (int) f3, this.aih, (int) (((float) i5) + f3 + 0.5f)); this.aif.draw(canvas); } else { f4 = f6; } if (f3 <= ((float) (scrollY + height))) { i3++; f7 = f2; f6 = f4; } else { return; } } } } public boolean onInterceptTouchEvent(MotionEvent motionEvent) { int action = motionEvent.getAction() & 255; if (action == 3 || action == 1) { this.mIsBeingDragged = false; this.aiq = false; this.mActivePointerId = -1; VelocityTracker velocityTracker = this.mVelocityTracker; if (velocityTracker != null) { velocityTracker.recycle(); this.mVelocityTracker = null; } return false; } if (action != 0) { if (this.mIsBeingDragged) { return true; } if (this.aiq) { return false; } } if (action == 0) { float x = motionEvent.getX(); this.fF = x; this.ait = x; float y = motionEvent.getY(); this.fG = y; this.aiu = y; this.mActivePointerId = MotionEventCompat.getPointerId(motionEvent, 0); this.aiq = false; this.aib.computeScrollOffset(); if (this.aiP != 2 || Math.abs(this.aib.getFinalY() - this.aib.getCurrY()) <= this.aiw) { bj(false); this.mIsBeingDragged = false; } else { this.aib.abortAnimation(); this.aio = false; wW(); this.mIsBeingDragged = true; bl(true); setScrollState(1); } } else if (action == 2) { int i2 = this.mActivePointerId; if (i2 != -1) { int findPointerIndex = MotionEventCompat.findPointerIndex(motionEvent, i2); float y2 = getY(motionEvent, findPointerIndex); float f2 = y2 - this.aiu; float abs = Math.abs(f2); float x2 = getX(motionEvent, findPointerIndex); float abs2 = Math.abs(x2 - this.fF); boolean z = !h(this.aiu, f2); boolean canScroll = canScroll(this, false, (int) f2, (int) x2, (int) y2); int i3 = (f2 > 0.0f ? 1 : (f2 == 0.0f ? 0 : -1)); if (i3 == 0 || !z || !canScroll) { int i4 = this.mTouchSlop; if (abs > ((float) i4) && abs > abs2) { this.mIsBeingDragged = true; bl(true); setScrollState(1); float f3 = this.fG; this.aiu = i3 > 0 ? f3 + ((float) this.mTouchSlop) : f3 - ((float) this.mTouchSlop); this.ait = x2; setScrollingCacheEnabled(true); } else if (abs2 > ((float) i4)) { this.aiq = true; } if (this.mIsBeingDragged && p(y2)) { ViewCompat.postInvalidateOnAnimation(this); } } else { this.ait = x2; this.aiu = y2; this.aiq = true; return false; } } } else if (action == 6) { e(motionEvent); } if (this.mVelocityTracker == null) { this.mVelocityTracker = VelocityTracker.obtain(); } this.mVelocityTracker.addMovement(motionEvent); return this.mIsBeingDragged; } /* access modifiers changed from: protected */ /* JADX WARNING: Removed duplicated region for block: B:20:0x0073 */ /* JADX WARNING: Removed duplicated region for block: B:27:0x0090 */ public void onLayout(boolean z, int i2, int i3, int i4, int i5) { b D; int i6; int i7; int i8; int i9; int childCount = getChildCount(); int i10 = i4 - i2; int i11 = i5 - i3; int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); int scrollY = getScrollY(); int i12 = 0; for (int i13 = 0; i13 < childCount; i13++) { View childAt = getChildAt(i13); if (childAt.getVisibility() != 8) { c cVar = (c) childAt.getLayoutParams(); if (cVar.isDecor) { int i14 = cVar.gravity & 7; int i15 = cVar.gravity & 112; if (i14 != 1) { if (i14 == 3) { i6 = childAt.getMeasuredWidth() + paddingLeft; } else if (i14 != 5) { i6 = paddingLeft; } else { i9 = (i10 - paddingRight) - childAt.getMeasuredWidth(); paddingRight += childAt.getMeasuredWidth(); } if (i15 == 16) { if (i15 == 48) { i7 = childAt.getMeasuredHeight() + paddingTop; } else if (i15 != 80) { i7 = paddingTop; } else { i8 = (i11 - paddingBottom) - childAt.getMeasuredHeight(); paddingBottom += childAt.getMeasuredHeight(); } int i16 = paddingTop + scrollY; childAt.layout(paddingLeft, i16, childAt.getMeasuredWidth() + paddingLeft, i16 + childAt.getMeasuredHeight()); i12++; paddingTop = i7; paddingLeft = i6; } else { i8 = Math.max((i11 - childAt.getMeasuredHeight()) / 2, paddingTop); } i7 = paddingTop; paddingTop = i8; int i162 = paddingTop + scrollY; childAt.layout(paddingLeft, i162, childAt.getMeasuredWidth() + paddingLeft, i162 + childAt.getMeasuredHeight()); i12++; paddingTop = i7; paddingLeft = i6; } else { i9 = Math.max((i10 - childAt.getMeasuredWidth()) / 2, paddingLeft); } i6 = paddingLeft; paddingLeft = i9; if (i15 == 16) { } i7 = paddingTop; paddingTop = i8; int i1622 = paddingTop + scrollY; childAt.layout(paddingLeft, i1622, childAt.getMeasuredWidth() + paddingLeft, i1622 + childAt.getMeasuredHeight()); i12++; paddingTop = i7; paddingLeft = i6; } } } int i17 = (i11 - paddingTop) - paddingBottom; for (int i18 = 0; i18 < childCount; i18++) { View childAt2 = getChildAt(i18); if (childAt2.getVisibility() != 8) { c cVar2 = (c) childAt2.getLayoutParams(); if (!cVar2.isDecor && (D = D(childAt2)) != null) { float f2 = (float) i17; int i19 = ((int) (D.aiU * f2)) + paddingTop; if (cVar2.aiV) { cVar2.aiV = false; childAt2.measure(View.MeasureSpec.makeMeasureSpec((i10 - paddingLeft) - paddingRight, 1073741824), View.MeasureSpec.makeMeasureSpec((int) (f2 * cVar2.aiT), 1073741824)); } childAt2.layout(paddingLeft, i19, childAt2.getMeasuredWidth() + paddingLeft, childAt2.getMeasuredHeight() + i19); } } } this.aig = paddingLeft; this.aih = i10 - paddingRight; this.aiD = i12; if (this.aiA) { a(this.ahV, false, 0, false, false); } this.aiA = false; } /* access modifiers changed from: protected */ /* JADX WARNING: Removed duplicated region for block: B:28:0x008a */ /* JADX WARNING: Removed duplicated region for block: B:33:0x0096 */ /* JADX WARNING: Removed duplicated region for block: B:36:0x009b */ /* JADX WARNING: Removed duplicated region for block: B:40:0x00a4 */ /* JADX WARNING: Removed duplicated region for block: B:43:0x00b3 */ /* JADX WARNING: Removed duplicated region for block: B:44:0x00b9 */ public void onMeasure(int i2, int i3) { c cVar; c cVar2; int i4; int i5; int i6; setMeasuredDimension(getDefaultSize(0, i2), getDefaultSize(0, i3)); int measuredHeight = getMeasuredHeight(); this.ais = Math.min(measuredHeight / 10, this.air); int measuredWidth = (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight(); int paddingTop = (measuredHeight - getPaddingTop()) - getPaddingBottom(); int childCount = getChildCount(); int i7 = 0; while (true) { boolean z = true; int i8 = 1073741824; if (i7 >= childCount) { break; } View childAt = getChildAt(i7); if (!(childAt.getVisibility() == 8 || (cVar2 = (c) childAt.getLayoutParams()) == null || !cVar2.isDecor)) { int i9 = cVar2.gravity & 7; int i10 = cVar2.gravity & 112; boolean z2 = i10 == 48 || i10 == 80; if (!(i9 == 3 || i9 == 5)) { z = false; } int i11 = Integer.MIN_VALUE; if (z2) { i11 = 1073741824; } else if (z) { i4 = 1073741824; if (cVar2.width == -2) { i5 = cVar2.width != -1 ? cVar2.width : measuredWidth; i11 = 1073741824; } else { i5 = measuredWidth; } if (cVar2.height == -2) { i6 = cVar2.height != -1 ? cVar2.height : paddingTop; } else { i6 = paddingTop; i8 = i4; } childAt.measure(View.MeasureSpec.makeMeasureSpec(i5, i11), View.MeasureSpec.makeMeasureSpec(i6, i8)); if (!z2) { paddingTop -= childAt.getMeasuredHeight(); } else if (z) { measuredWidth -= childAt.getMeasuredWidth(); } } i4 = Integer.MIN_VALUE; if (cVar2.width == -2) { } if (cVar2.height == -2) { } childAt.measure(View.MeasureSpec.makeMeasureSpec(i5, i11), View.MeasureSpec.makeMeasureSpec(i6, i8)); if (!z2) { } } i7++; } this.aik = View.MeasureSpec.makeMeasureSpec(measuredWidth, 1073741824); this.ail = View.MeasureSpec.makeMeasureSpec(paddingTop, 1073741824); this.aim = true; wW(); this.aim = false; int childCount2 = getChildCount(); for (int i12 = 0; i12 < childCount2; i12++) { View childAt2 = getChildAt(i12); if (childAt2.getVisibility() != 8 && ((cVar = (c) childAt2.getLayoutParams()) == null || !cVar.isDecor)) { childAt2.measure(this.aik, View.MeasureSpec.makeMeasureSpec((int) (((float) paddingTop) * cVar.aiT), 1073741824)); } } } /* access modifiers changed from: protected */ public boolean onRequestFocusInDescendants(int i2, Rect rect) { int i3; int i4; b D; int childCount = getChildCount(); int i5 = -1; if ((i2 & 2) != 0) { i5 = childCount; i4 = 0; i3 = 1; } else { i4 = childCount - 1; i3 = -1; } while (i4 != i5) { View childAt = getChildAt(i4); if (childAt.getVisibility() == 0 && (D = D(childAt)) != null && D.position == this.ahV && childAt.requestFocus(i2, rect)) { return true; } i4 += i3; } return false; } public void onRestoreInstanceState(Parcelable parcelable) { if (!(parcelable instanceof h)) { super.onRestoreInstanceState(parcelable); return; } h hVar = (h) parcelable; super.onRestoreInstanceState(hVar.getSuperState()); PagerAdapter pagerAdapter = this.ahU; if (pagerAdapter != null) { pagerAdapter.restoreState(hVar.aiX, hVar.aiY); a(hVar.position, false, true); return; } this.ahX = hVar.position; this.ahZ = hVar.aiX; this.aia = hVar.aiY; } public Parcelable onSaveInstanceState() { return super.onSaveInstanceState(); } /* access modifiers changed from: protected */ public void onSizeChanged(int i2, int i3, int i4, int i5) { super.onSizeChanged(i2, i3, i4, i5); if (i3 != i5) { int i6 = this.aie; a(i3, i5, i6, i6); } } /* JADX WARNING: Removed duplicated region for block: B:57:0x017c */ public boolean onTouchEvent(MotionEvent motionEvent) { PagerAdapter pagerAdapter; int i2; if (this.aix) { return true; } boolean z = false; if ((motionEvent.getAction() == 0 && motionEvent.getEdgeFlags() != 0) || (pagerAdapter = this.ahU) == 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) { if (action == 1) { if (this.mIsBeingDragged) { VelocityTracker velocityTracker = this.mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, (float) this.JF); int yVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, this.mActivePointerId); this.aio = true; int clientHeight = getClientHeight(); int scrollY = getScrollY(); b xa = xa(); if (xa != null) { a(a(xa.position, ((((float) scrollY) / ((float) clientHeight)) - xa.aiU) / xa.aiT, yVelocity, (int) (getY(motionEvent, MotionEventCompat.findPointerIndex(motionEvent, this.mActivePointerId)) - this.fG)), true, true, yVelocity, true); this.mActivePointerId = -1; xb(); z = this.aiy.onRelease() | this.aiz.onRelease(); } } this.aiE = System.currentTimeMillis(); } else if (action == 2) { if (!this.mIsBeingDragged) { int findPointerIndex = MotionEventCompat.findPointerIndex(motionEvent, this.mActivePointerId); float y = getY(motionEvent, findPointerIndex); float abs = Math.abs(y - this.aiu); float x = getX(motionEvent, findPointerIndex); float abs2 = Math.abs(x - this.ait); if (abs > ((float) this.mTouchSlop) && abs > abs2) { this.mIsBeingDragged = true; bl(true); float f2 = this.fG; this.aiu = y - f2 > 0.0f ? f2 + ((float) this.mTouchSlop) : f2 - ((float) this.mTouchSlop); this.ait = x; setScrollState(1); setScrollingCacheEnabled(true); ViewParent parent = getParent(); if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); } } } if (this.mIsBeingDragged) { z = false | p(getY(motionEvent, MotionEventCompat.findPointerIndex(motionEvent, this.mActivePointerId))); } } else if (action != 3) { if (action == 5) { int actionIndex = MotionEventCompat.getActionIndex(motionEvent); this.aiu = getY(motionEvent, actionIndex); i2 = MotionEventCompat.getPointerId(motionEvent, actionIndex); } else if (action == 6) { e(motionEvent); this.aiu = getY(motionEvent, MotionEventCompat.findPointerIndex(motionEvent, this.mActivePointerId)); } } else if (this.mIsBeingDragged) { a(this.ahV, true, 0, false, false); this.mActivePointerId = -1; xb(); z = this.aiy.onRelease() | this.aiz.onRelease(); } if (z) { ViewCompat.postInvalidateOnAnimation(this); } return true; } this.aib.abortAnimation(); this.aio = false; wW(); float x2 = motionEvent.getX(); this.fF = x2; this.ait = x2; float y2 = motionEvent.getY(); this.fG = y2; this.aiu = y2; i2 = MotionEventCompat.getPointerId(motionEvent, 0); this.mActivePointerId = i2; if (z) { } return true; } public final void removeOnPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { List<ViewPager.OnPageChangeListener> list = this.aiF; if (list != null) { list.remove(onPageChangeListener); } } public void removeView(View view) { if (this.aim) { removeViewInLayout(view); } else { super.removeView(view); } } public void setAdapter(PagerAdapter pagerAdapter) { PagerAdapter pagerAdapter2 = this.ahU; if (pagerAdapter2 != null) { pagerAdapter2.unregisterDataSetObserver(this.aic); this.ahU.startUpdate((ViewGroup) this); for (int i2 = 0; i2 < this.ahR.size(); i2++) { b bVar = this.ahR.get(i2); this.ahU.destroyItem((ViewGroup) this, bVar.position, bVar.aiR); } this.ahU.finishUpdate((ViewGroup) this); this.ahR.clear(); wU(); int i3 = this.ahV; if (i3 != 0) { this.ahW = i3; } else { this.ahW = -1; } this.ahV = 0; scrollTo(0, 0); } int i4 = this.ahY; if (i4 > 0) { this.ahW = -1; this.ahV = i4; this.ahY = -1; } this.ahU = pagerAdapter; this.ahO = 0; if (pagerAdapter != null) { if (this.aic == null) { this.aic = new g(this, (byte) 0); } this.ahU.registerDataSetObserver(this.aic); this.aio = false; boolean z = this.aiA; this.aiA = true; this.ahO = this.ahU.getCount(); if (this.ahX >= 0) { this.ahU.restoreState(this.ahZ, this.aia); a(this.ahX, false, true); this.ahX = -1; this.ahZ = null; this.aia = null; } else if (!z) { wW(); } else { requestLayout(); } } } /* access modifiers changed from: package-private */ public void setChildrenDrawingOrderEnabledCompat(boolean z) { if (Build.VERSION.SDK_INT >= 7) { if (this.aiK == null) { try { this.aiK = ViewGroup.class.getDeclaredMethod("setChildrenDrawingOrderEnabled", Boolean.TYPE); } catch (NoSuchMethodException e) { com.kwad.sdk.core.e.b.e("VerticalViewPager", "Can't find setChildrenDrawingOrderEnabled", e); } } try { this.aiK.invoke(this, Boolean.valueOf(z)); } catch (Exception e2) { com.kwad.sdk.core.e.b.e("VerticalViewPager", "Error changing children drawing order", e2); } } } /* access modifiers changed from: protected */ public void setCurrentItem(int i2) { com.kwad.sdk.core.e.b.i("VerticalViewPager", "setCurrentItem item=" + i2); this.aio = false; a(i2, this.aiA ^ true, false); } public void setCurrentItem(int i2, boolean z) { com.kwad.sdk.core.e.b.i("VerticalViewPager", "setCurrentItem item=" + i2 + " smoothScroll=" + z); this.aio = false; a(i2, z, false); } public void setInitStartPosition(int i2) { this.ahY = i2; } public void setOffscreenPageLimit(int i2) { if (i2 <= 0) { com.kwad.sdk.core.e.b.d("VerticalViewPager", "Requested offscreen page limit " + i2 + " too small; defaulting to 1"); i2 = 1; } if (i2 != this.aip) { this.aip = i2; wW(); } } /* access modifiers changed from: package-private */ public void setOnAdapterChangeListener(AbstractC0121e eVar) { this.aiH = eVar; } public void setOnPageScrollEndListener(f fVar) { this.aiI = fVar; } public void setPageMargin(int i2) { int i3 = this.aie; this.aie = i2; int height = getHeight(); a(height, height, i2, i3); requestLayout(); } public void setPageMarginDrawable(int i2) { setPageMarginDrawable(getContext().getResources().getDrawable(i2)); } public void setPageMarginDrawable(Drawable drawable) { this.aif = drawable; if (drawable != null) { refreshDrawableState(); } setWillNotDraw(drawable == null); invalidate(); } /* access modifiers changed from: protected */ public boolean verifyDrawable(Drawable drawable) { return super.verifyDrawable(drawable) || drawable == this.aif; } /* access modifiers changed from: protected */ public void wL() { f fVar = this.aiI; if (fVar != null) { fVar.wL(); } } /* access modifiers changed from: package-private */ public final void wV() { int count = this.ahU.getCount(); this.ahO = count; boolean z = this.ahR.size() < (this.aip * 2) + 1 && this.ahR.size() < count; int i2 = this.ahV; int i3 = 0; boolean z2 = false; while (i3 < this.ahR.size()) { b bVar = this.ahR.get(i3); int itemPosition = this.ahU.getItemPosition(bVar); if (itemPosition != -1) { if (itemPosition == -2) { this.ahR.remove(i3); i3--; if (!z2) { this.ahU.startUpdate((ViewGroup) this); z2 = true; } this.ahU.destroyItem((ViewGroup) this, bVar.position, bVar.aiR); if (this.ahV == bVar.position) { i2 = Math.max(0, Math.min(this.ahV, count - 1)); } } else if (bVar.position != itemPosition) { if (bVar.position == this.ahV) { i2 = itemPosition; } bVar.position = itemPosition; } z = true; } i3++; } if (z2) { this.ahU.finishUpdate((ViewGroup) this); } Collections.sort(this.ahR, ahP); if (z) { int childCount = getChildCount(); for (int i4 = 0; i4 < childCount; i4++) { c cVar = (c) getChildAt(i4).getLayoutParams(); if (!cVar.isDecor) { cVar.aiT = 0.0f; } } a(i2, false, true); requestLayout(); } } /* access modifiers changed from: package-private */ public final void wW() { be(this.ahV); } public final void wY() { List<DataSetObserver> list = this.aid; if (list != null) { int size = list.size(); for (int i2 = 0; i2 < size; i2++) { DataSetObserver dataSetObserver = this.aid.get(i2); if (dataSetObserver != null) { dataSetObserver.onChanged(); } } } } public final void wZ() { List<DataSetObserver> list = this.aid; if (list != null) { int size = list.size(); for (int i2 = 0; i2 < size; i2++) { DataSetObserver dataSetObserver = this.aid.get(i2); if (dataSetObserver != null) { dataSetObserver.onInvalidated(); } } } } }