package androidx.viewpager.widget;

import a3.g0;
import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
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.widget.EdgeEffect;
import android.widget.Scroller;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.s1;
import com.google.android.gms.measurement.internal.u1;
import e.s0;
import g0.d;
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.WeakHashMap;
import w3.a;
import w3.e;
import w3.f;
import w3.h;
import w3.i;
import w3.j;
import y0.g;

/* JADX INFO: loaded from: classes.dex */
public class ViewPager extends ViewGroup {

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public static final int[] f4358r0 = {R.attr.layout_gravity};

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public static final g f4359s0 = new g(4);

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public static final d0.g f4360t0 = new d0.g(8);
    public boolean Q;
    public boolean R;
    public int S;
    public int T;
    public int U;
    public float V;
    public float W;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f4361a;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public float f4362a0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final e f4363b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public int f4364b0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Rect f4365c;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public VelocityTracker f4366c0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Parcelable f4367d;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public int f4368d0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Scroller f4369e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public EdgeEffect f4370e0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f4371f;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public EdgeEffect f4372f0;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public Drawable f4373g;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public boolean f4374g0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final float f4375h;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    public boolean f4376h0;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final float f4377i;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public int f4378i0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f4379j;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public ArrayList f4380j0;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f4381k;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public h f4382k0;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public boolean f4383l;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public h f4384l0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f4385m;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public ArrayList f4386m0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public int f4387n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public ArrayList f4388o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public final s0 f4389p0;

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    public int f4390q0;

    @Target({ElementType.TYPE})
    @Inherited
    @Retention(RetentionPolicy.RUNTIME)
    public @interface DecorView {
    }

    public ViewPager(@NonNull Context context) {
        super(context);
        this.f4361a = new ArrayList();
        this.f4363b = new e();
        this.f4365c = new Rect();
        this.f4375h = -3.4028235E38f;
        this.f4377i = Float.MAX_VALUE;
        this.f4385m = 1;
        this.f4364b0 = -1;
        this.f4374g0 = true;
        this.f4389p0 = new s0(this, 14);
        this.f4390q0 = 0;
        g();
    }

    public static boolean b(View view, boolean z10, int i10, int i11, int i12) {
        int i13;
        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 i14 = i11 + scrollX;
                if (i14 >= childAt.getLeft() && i14 < childAt.getRight() && (i13 = i12 + scrollY) >= childAt.getTop() && i13 < childAt.getBottom() && b(childAt, true, i10, i14 - childAt.getLeft(), i13 - childAt.getTop())) {
                    return true;
                }
            }
        }
        return z10 && view.canScrollHorizontally(-i10);
    }

    private int getClientWidth() {
        return (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
    }

    private void setScrollingCacheEnabled(boolean z10) {
        if (this.f4383l != z10) {
            this.f4383l = z10;
        }
    }

    public final boolean a(int i10) {
        View viewFindFocus = findFocus();
        if (viewFindFocus == this) {
            viewFindFocus = null;
        } else if (viewFindFocus != null) {
            for (ViewParent parent = viewFindFocus.getParent(); parent instanceof ViewGroup; parent = parent.getParent()) {
                if (parent == this) {
                    break;
                }
            }
            for (ViewParent parent2 = viewFindFocus.getParent(); parent2 instanceof ViewGroup; parent2 = parent2.getParent()) {
                parent2.getClass();
            }
            viewFindFocus = null;
        }
        View viewFindNextFocus = FocusFinder.getInstance().findNextFocus(this, viewFindFocus, i10);
        boolean zRequestFocus = false;
        if (viewFindNextFocus != null && viewFindNextFocus != viewFindFocus) {
            Rect rect = this.f4365c;
            if (i10 == 17) {
                int i11 = d(rect, viewFindNextFocus).left;
                int i12 = d(rect, viewFindFocus).left;
                if (viewFindFocus == null || i11 < i12) {
                    zRequestFocus = viewFindNextFocus.requestFocus();
                }
            } else if (i10 == 66) {
                int i13 = d(rect, viewFindNextFocus).left;
                int i14 = d(rect, viewFindFocus).left;
                if (viewFindFocus == null || i13 > i14) {
                    zRequestFocus = viewFindNextFocus.requestFocus();
                }
            }
        }
        if (zRequestFocus) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(i10));
        }
        return zRequestFocus;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void addFocusables(ArrayList arrayList, int i10, int i11) {
        int size = arrayList.size();
        int descendantFocusability = getDescendantFocusability();
        if (descendantFocusability != 393216) {
            for (int i12 = 0; i12 < getChildCount(); i12++) {
                if (getChildAt(i12).getVisibility() == 0) {
                    e();
                }
            }
        }
        if ((descendantFocusability != 262144 || size == arrayList.size()) && isFocusable()) {
            if ((i11 & 1) == 1 && isInTouchMode() && !isFocusableInTouchMode()) {
                return;
            }
            arrayList.add(this);
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void addTouchables(ArrayList arrayList) {
        for (int i10 = 0; i10 < getChildCount(); i10++) {
            if (getChildAt(i10).getVisibility() == 0) {
                e();
            }
        }
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) {
        if (!checkLayoutParams(layoutParams)) {
            layoutParams = generateLayoutParams(layoutParams);
        }
        f fVar = (f) layoutParams;
        boolean z10 = fVar.f34175a | (view.getClass().getAnnotation(DecorView.class) != null);
        fVar.f34175a = z10;
        if (!this.f4381k) {
            super.addView(view, i10, layoutParams);
        } else {
            if (z10) {
                throw new IllegalStateException("Cannot add pager decor view during layout");
            }
            addViewInLayout(view, i10, layoutParams);
        }
    }

    public final void c(boolean z10) {
        int i10 = 0;
        boolean z11 = this.f4390q0 == 2;
        if (z11) {
            setScrollingCacheEnabled(false);
            if (!this.f4369e.isFinished()) {
                this.f4369e.abortAnimation();
                int scrollX = getScrollX();
                int scrollY = getScrollY();
                int currX = this.f4369e.getCurrX();
                int currY = this.f4369e.getCurrY();
                if (scrollX != currX || scrollY != currY) {
                    scrollTo(currX, currY);
                    if (currX != scrollX) {
                        i(currX);
                    }
                }
            }
        }
        while (true) {
            ArrayList arrayList = this.f4361a;
            if (i10 >= arrayList.size()) {
                break;
            }
            ((e) arrayList.get(i10)).getClass();
            i10++;
        }
        if (z11) {
            s0 s0Var = this.f4389p0;
            if (!z10) {
                s0Var.run();
            } else {
                WeakHashMap weakHashMap = s1.f1815a;
                postOnAnimation(s0Var);
            }
        }
    }

    @Override // android.view.View
    public final boolean canScrollHorizontally(int i10) {
        return false;
    }

    @Override // android.view.ViewGroup
    public final boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return (layoutParams instanceof f) && super.checkLayoutParams(layoutParams);
    }

    @Override // android.view.View
    public final void computeScroll() {
        if (this.f4369e.isFinished() || !this.f4369e.computeScrollOffset()) {
            c(true);
            return;
        }
        int scrollX = getScrollX();
        int scrollY = getScrollY();
        int currX = this.f4369e.getCurrX();
        int currY = this.f4369e.getCurrY();
        if (scrollX != currX || scrollY != currY) {
            scrollTo(currX, currY);
            if (!i(currX)) {
                this.f4369e.abortAnimation();
                scrollTo(0, currY);
            }
        }
        WeakHashMap weakHashMap = s1.f1815a;
        postInvalidateOnAnimation();
    }

    public final Rect d(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;
    }

    /* JADX WARN: Removed duplicated region for block: B:32:? A[RETURN, SYNTHETIC] */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        boolean zA;
        if (super.dispatchKeyEvent(keyEvent)) {
            return true;
        }
        if (keyEvent.getAction() == 0) {
            int keyCode = keyEvent.getKeyCode();
            if (keyCode != 21) {
                if (keyCode != 22) {
                    if (keyCode == 61) {
                        if (keyEvent.hasNoModifiers()) {
                            zA = a(2);
                        } else if (keyEvent.hasModifiers(1)) {
                            zA = a(1);
                        }
                        if (zA) {
                            return true;
                        }
                    }
                } else if (!keyEvent.hasModifiers(2)) {
                    zA = a(66);
                    if (zA) {
                    }
                }
            } else if (!keyEvent.hasModifiers(2)) {
                zA = a(17);
                if (zA) {
                }
            }
        }
        return false;
    }

    @Override // android.view.View
    public final boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        if (accessibilityEvent.getEventType() == 4096) {
            return super.dispatchPopulateAccessibilityEvent(accessibilityEvent);
        }
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            if (getChildAt(i10).getVisibility() == 0) {
                e();
            }
        }
        return false;
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        boolean zDraw;
        super.draw(canvas);
        if (getOverScrollMode() != 0) {
            this.f4370e0.finish();
            this.f4372f0.finish();
            return;
        }
        if (this.f4370e0.isFinished()) {
            zDraw = false;
        } else {
            int iSave = canvas.save();
            int height = (getHeight() - getPaddingTop()) - getPaddingBottom();
            int width = getWidth();
            canvas.rotate(270.0f);
            canvas.translate(getPaddingTop() + (-height), this.f4375h * width);
            this.f4370e0.setSize(height, width);
            zDraw = this.f4370e0.draw(canvas);
            canvas.restoreToCount(iSave);
        }
        if (!this.f4372f0.isFinished()) {
            int iSave2 = canvas.save();
            int width2 = getWidth();
            int height2 = (getHeight() - getPaddingTop()) - getPaddingBottom();
            canvas.rotate(90.0f);
            canvas.translate(-getPaddingTop(), (-(this.f4377i + 1.0f)) * width2);
            this.f4372f0.setSize(height2, width2);
            zDraw |= this.f4372f0.draw(canvas);
            canvas.restoreToCount(iSave2);
        }
        if (zDraw) {
            WeakHashMap weakHashMap = s1.f1815a;
            postInvalidateOnAnimation();
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void drawableStateChanged() {
        super.drawableStateChanged();
        Drawable drawable = this.f4373g;
        if (drawable == null || !drawable.isStateful()) {
            return;
        }
        drawable.setState(getDrawableState());
    }

    public final void e() {
        ArrayList arrayList = this.f4361a;
        if (arrayList.size() <= 0) {
            return;
        }
        ((e) arrayList.get(0)).getClass();
        throw null;
    }

    public final e f(int i10) {
        int i11 = 0;
        while (true) {
            ArrayList arrayList = this.f4361a;
            if (i11 >= arrayList.size()) {
                return null;
            }
            e eVar = (e) arrayList.get(i11);
            if (eVar.f34173a == i10) {
                return eVar;
            }
            i11++;
        }
    }

    public final void g() {
        setWillNotDraw(false);
        setDescendantFocusability(262144);
        setFocusable(true);
        Context context = getContext();
        this.f4369e = new Scroller(context, f4359s0);
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        float f10 = context.getResources().getDisplayMetrics().density;
        this.U = viewConfiguration.getScaledPagingTouchSlop();
        viewConfiguration.getScaledMaximumFlingVelocity();
        this.f4370e0 = new EdgeEffect(context);
        this.f4372f0 = new EdgeEffect(context);
        this.f4368d0 = (int) (2.0f * f10);
        this.S = (int) (f10 * 16.0f);
        s1.setAccessibilityDelegate(this, new g0(this, 1));
        if (getImportantForAccessibility() == 0) {
            setImportantForAccessibility(1);
        }
        s1.setOnApplyWindowInsetsListener(this, new xyz.stream.utils.f(this));
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return new f(-1, -1);
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return generateDefaultLayoutParams();
    }

    @Nullable
    public a getAdapter() {
        return null;
    }

    @Override // android.view.ViewGroup
    public final int getChildDrawingOrder(int i10, int i11) {
        if (this.f4387n0 == 2) {
            i11 = (i10 - 1) - i11;
        }
        ((f) ((View) this.f4388o0.get(i11)).getLayoutParams()).getClass();
        return 0;
    }

    public int getCurrentItem() {
        return 0;
    }

    public int getOffscreenPageLimit() {
        return this.f4385m;
    }

    public int getPageMargin() {
        return this.f4371f;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0065  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void h(int i10, float f10, int i11) {
        int iMax;
        int width;
        int left;
        if (this.f4378i0 > 0) {
            int scrollX = getScrollX();
            int paddingLeft = getPaddingLeft();
            int paddingRight = getPaddingRight();
            int width2 = getWidth();
            int childCount = getChildCount();
            for (int i12 = 0; i12 < childCount; i12++) {
                View childAt = getChildAt(i12);
                f fVar = (f) childAt.getLayoutParams();
                if (fVar.f34175a) {
                    int i13 = fVar.f34176b & 7;
                    if (i13 != 1) {
                        if (i13 == 3) {
                            width = childAt.getWidth() + paddingLeft;
                        } else if (i13 != 5) {
                            width = paddingLeft;
                        } else {
                            iMax = (width2 - paddingRight) - childAt.getMeasuredWidth();
                            paddingRight += childAt.getMeasuredWidth();
                        }
                        left = (paddingLeft + scrollX) - childAt.getLeft();
                        if (left != 0) {
                            childAt.offsetLeftAndRight(left);
                        }
                        paddingLeft = width;
                    } else {
                        iMax = Math.max((width2 - childAt.getMeasuredWidth()) / 2, paddingLeft);
                    }
                    int i14 = iMax;
                    width = paddingLeft;
                    paddingLeft = i14;
                    left = (paddingLeft + scrollX) - childAt.getLeft();
                    if (left != 0) {
                    }
                    paddingLeft = width;
                }
            }
        }
        h hVar = this.f4382k0;
        if (hVar != null) {
            hVar.b(i10, f10);
        }
        ArrayList arrayList = this.f4380j0;
        if (arrayList != null) {
            int size = arrayList.size();
            for (int i15 = 0; i15 < size; i15++) {
                h hVar2 = (h) this.f4380j0.get(i15);
                if (hVar2 != null) {
                    hVar2.b(i10, f10);
                }
            }
        }
        h hVar3 = this.f4384l0;
        if (hVar3 != null) {
            hVar3.b(i10, f10);
        }
        this.f4376h0 = true;
    }

    public final boolean i(int i10) {
        int i11;
        ArrayList arrayList = this.f4361a;
        if (arrayList.size() == 0) {
            if (this.f4374g0) {
                return false;
            }
            this.f4376h0 = false;
            h(0, 0.0f, 0);
            if (this.f4376h0) {
                return false;
            }
            throw new IllegalStateException("onPageScrolled did not call superclass implementation");
        }
        int clientWidth = getClientWidth();
        float scrollX = clientWidth > 0 ? getScrollX() / clientWidth : 0.0f;
        float f10 = clientWidth > 0 ? this.f4371f / clientWidth : 0.0f;
        int i12 = -1;
        boolean z10 = true;
        float f11 = 0.0f;
        int i13 = 0;
        e eVar = null;
        while (i13 < arrayList.size()) {
            e eVar2 = (e) arrayList.get(i13);
            if (!z10 && eVar2.f34173a != (i11 = i12 + 1)) {
                e eVar3 = this.f4363b;
                eVar3.f34174b = f11 + 0.0f + f10;
                eVar3.f34173a = i11;
                throw null;
            }
            f11 = eVar2.f34174b;
            float f12 = f11 + 0.0f + f10;
            if (!z10 && scrollX < f11) {
                break;
            }
            if (scrollX < f12 || i13 == arrayList.size() - 1) {
                eVar = eVar2;
                break;
            }
            i12 = eVar2.f34173a;
            i13++;
            z10 = false;
            eVar = eVar2;
        }
        int clientWidth2 = getClientWidth();
        int i14 = this.f4371f;
        int i15 = clientWidth2 + i14;
        float f13 = clientWidth2;
        int i16 = eVar.f34173a;
        float f14 = ((i10 / f13) - eVar.f34174b) / (0.0f + (i14 / f13));
        this.f4376h0 = false;
        h(i16, f14, (int) (i15 * f14));
        if (this.f4376h0) {
            return true;
        }
        throw new IllegalStateException("onPageScrolled did not call superclass implementation");
    }

    public final void j() {
        if (this.f4387n0 != 0) {
            ArrayList arrayList = this.f4388o0;
            if (arrayList == null) {
                this.f4388o0 = new ArrayList();
            } else {
                arrayList.clear();
            }
            int childCount = getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                this.f4388o0.add(getChildAt(i10));
            }
            Collections.sort(this.f4388o0, f4360t0);
        }
    }

    public final void k(int i10, int i11, int i12, int i13) {
        if (i11 > 0 && !this.f4361a.isEmpty()) {
            if (!this.f4369e.isFinished()) {
                this.f4369e.setFinalX(getCurrentItem() * getClientWidth());
                return;
            } else {
                scrollTo((int) ((getScrollX() / (((i11 - getPaddingLeft()) - getPaddingRight()) + i13)) * (((i10 - getPaddingLeft()) - getPaddingRight()) + i12)), getScrollY());
                return;
            }
        }
        e eVarF = f(0);
        int iMin = (int) ((eVarF != null ? Math.min(eVarF.f34174b, this.f4377i) : 0.0f) * ((i10 - getPaddingLeft()) - getPaddingRight()));
        if (iMin != getScrollX()) {
            c(false);
            scrollTo(iMin, getScrollY());
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.f4374g0 = true;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        removeCallbacks(this.f4389p0);
        Scroller scroller = this.f4369e;
        if (scroller != null && !scroller.isFinished()) {
            this.f4369e.abortAnimation();
        }
        super.onDetachedFromWindow();
    }

    @Override // android.view.View
    public final void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.f4371f <= 0 || this.f4373g == null) {
            return;
        }
        this.f4361a.size();
    }

    @Override // android.view.ViewGroup
    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        int action = motionEvent.getAction() & 255;
        if (action == 3 || action == 1) {
            this.f4364b0 = -1;
            this.Q = false;
            this.R = false;
            VelocityTracker velocityTracker = this.f4366c0;
            if (velocityTracker != null) {
                velocityTracker.recycle();
                this.f4366c0 = null;
            }
            this.f4370e0.onRelease();
            this.f4372f0.onRelease();
            if (!this.f4370e0.isFinished()) {
                this.f4372f0.isFinished();
            }
            return false;
        }
        if (action != 0) {
            if (this.Q) {
                return true;
            }
            if (this.R) {
                return false;
            }
        }
        if (action == 0) {
            float x10 = motionEvent.getX();
            this.W = x10;
            this.V = x10;
            this.f4362a0 = motionEvent.getY();
            this.f4364b0 = motionEvent.getPointerId(0);
            this.R = false;
            this.f4369e.computeScrollOffset();
            if (this.f4390q0 != 2 || Math.abs(this.f4369e.getFinalX() - this.f4369e.getCurrX()) <= this.f4368d0) {
                c(false);
                this.Q = false;
            } else {
                this.f4369e.abortAnimation();
                j();
                this.Q = true;
                ViewParent parent = getParent();
                if (parent != null) {
                    parent.requestDisallowInterceptTouchEvent(true);
                }
                setScrollState(1);
            }
        } else if (action == 2) {
            int i10 = this.f4364b0;
            if (i10 != -1) {
                int iFindPointerIndex = motionEvent.findPointerIndex(i10);
                float x11 = motionEvent.getX(iFindPointerIndex);
                float f10 = x11 - this.V;
                float fAbs = Math.abs(f10);
                float y10 = motionEvent.getY(iFindPointerIndex);
                float fAbs2 = Math.abs(y10 - this.f4362a0);
                if (f10 != 0.0f) {
                    float f11 = this.V;
                    if ((f11 >= this.T || f10 <= 0.0f) && ((f11 <= getWidth() - this.T || f10 >= 0.0f) && b(this, false, (int) f10, (int) x11, (int) y10))) {
                        this.V = x11;
                        this.R = true;
                        return false;
                    }
                }
                float f12 = this.U;
                if (fAbs > f12 && fAbs * 0.5f > fAbs2) {
                    this.Q = true;
                    ViewParent parent2 = getParent();
                    if (parent2 != null) {
                        parent2.requestDisallowInterceptTouchEvent(true);
                    }
                    setScrollState(1);
                    float f13 = this.W;
                    float f14 = this.U;
                    this.V = f10 > 0.0f ? f13 + f14 : f13 - f14;
                    setScrollingCacheEnabled(true);
                } else if (fAbs2 > f12) {
                    this.R = true;
                }
                if (this.Q) {
                    this.V = x11;
                    getScrollX();
                    getClientWidth();
                    ArrayList arrayList = this.f4361a;
                    e eVar = (e) arrayList.get(0);
                    e eVar2 = (e) u1.e(arrayList, 1);
                    int i11 = eVar.f34173a;
                    int i12 = eVar2.f34173a;
                    throw null;
                }
            }
        } else if (action == 6) {
            int actionIndex = motionEvent.getActionIndex();
            if (motionEvent.getPointerId(actionIndex) == this.f4364b0) {
                int i13 = actionIndex == 0 ? 1 : 0;
                this.V = motionEvent.getX(i13);
                this.f4364b0 = motionEvent.getPointerId(i13);
                VelocityTracker velocityTracker2 = this.f4366c0;
                if (velocityTracker2 != null) {
                    velocityTracker2.clear();
                }
            }
        }
        if (this.f4366c0 == null) {
            this.f4366c0 = VelocityTracker.obtain();
        }
        this.f4366c0.addMovement(motionEvent);
        return this.Q;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0072  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0094  */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        boolean z11;
        int iMax;
        int measuredWidth;
        int iMax2;
        int measuredHeight;
        int childCount = getChildCount();
        int i14 = i12 - i10;
        int i15 = i13 - i11;
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        int paddingRight = getPaddingRight();
        int paddingBottom = getPaddingBottom();
        int scrollX = getScrollX();
        int i16 = 0;
        for (int i17 = 0; i17 < childCount; i17++) {
            View childAt = getChildAt(i17);
            if (childAt.getVisibility() != 8) {
                f fVar = (f) childAt.getLayoutParams();
                if (fVar.f34175a) {
                    int i18 = fVar.f34176b;
                    int i19 = i18 & 7;
                    int i20 = i18 & 112;
                    if (i19 != 1) {
                        if (i19 == 3) {
                            measuredWidth = childAt.getMeasuredWidth() + paddingLeft;
                        } else if (i19 != 5) {
                            measuredWidth = paddingLeft;
                        } else {
                            iMax = (i14 - paddingRight) - childAt.getMeasuredWidth();
                            paddingRight += childAt.getMeasuredWidth();
                        }
                        if (i20 == 16) {
                            if (i20 == 48) {
                                measuredHeight = childAt.getMeasuredHeight() + paddingTop;
                            } else if (i20 != 80) {
                                measuredHeight = paddingTop;
                            } else {
                                iMax2 = (i15 - paddingBottom) - childAt.getMeasuredHeight();
                                paddingBottom += childAt.getMeasuredHeight();
                            }
                            int i21 = paddingLeft + scrollX;
                            childAt.layout(i21, paddingTop, childAt.getMeasuredWidth() + i21, childAt.getMeasuredHeight() + paddingTop);
                            i16++;
                            paddingTop = measuredHeight;
                            paddingLeft = measuredWidth;
                        } else {
                            iMax2 = Math.max((i15 - childAt.getMeasuredHeight()) / 2, paddingTop);
                        }
                        int i22 = iMax2;
                        measuredHeight = paddingTop;
                        paddingTop = i22;
                        int i212 = paddingLeft + scrollX;
                        childAt.layout(i212, paddingTop, childAt.getMeasuredWidth() + i212, childAt.getMeasuredHeight() + paddingTop);
                        i16++;
                        paddingTop = measuredHeight;
                        paddingLeft = measuredWidth;
                    } else {
                        iMax = Math.max((i14 - childAt.getMeasuredWidth()) / 2, paddingLeft);
                    }
                    int i23 = iMax;
                    measuredWidth = paddingLeft;
                    paddingLeft = i23;
                    if (i20 == 16) {
                    }
                    int i222 = iMax2;
                    measuredHeight = paddingTop;
                    paddingTop = i222;
                    int i2122 = paddingLeft + scrollX;
                    childAt.layout(i2122, paddingTop, childAt.getMeasuredWidth() + i2122, childAt.getMeasuredHeight() + paddingTop);
                    i16++;
                    paddingTop = measuredHeight;
                    paddingLeft = measuredWidth;
                }
            }
        }
        for (int i24 = 0; i24 < childCount; i24++) {
            View childAt2 = getChildAt(i24);
            if (childAt2.getVisibility() != 8 && !((f) childAt2.getLayoutParams()).f34175a) {
                e();
            }
        }
        this.f4378i0 = i16;
        if (this.f4374g0) {
            e eVarF = f(0);
            int iMax3 = eVarF != null ? (int) (Math.max(this.f4375h, Math.min(eVarF.f34174b, this.f4377i)) * getClientWidth()) : 0;
            z11 = false;
            c(false);
            scrollTo(iMax3, 0);
            i(iMax3);
        } else {
            z11 = false;
        }
        this.f4374g0 = z11;
    }

    @Override // android.view.View
    public final void onMeasure(int i10, int i11) {
        f fVar;
        f fVar2;
        int i12;
        setMeasuredDimension(View.getDefaultSize(0, i10), View.getDefaultSize(0, i11));
        int measuredWidth = getMeasuredWidth();
        this.T = Math.min(measuredWidth / 10, this.S);
        int paddingLeft = (measuredWidth - getPaddingLeft()) - getPaddingRight();
        int measuredHeight = (getMeasuredHeight() - getPaddingTop()) - getPaddingBottom();
        int childCount = getChildCount();
        int i13 = 0;
        while (true) {
            boolean z10 = true;
            int i14 = 1073741824;
            if (i13 >= childCount) {
                break;
            }
            View childAt = getChildAt(i13);
            if (childAt.getVisibility() != 8 && (fVar2 = (f) childAt.getLayoutParams()) != null && fVar2.f34175a) {
                int i15 = fVar2.f34176b;
                int i16 = i15 & 7;
                int i17 = i15 & 112;
                boolean z11 = i17 == 48 || i17 == 80;
                if (i16 != 3 && i16 != 5) {
                    z10 = false;
                }
                int i18 = Integer.MIN_VALUE;
                if (z11) {
                    i12 = Integer.MIN_VALUE;
                    i18 = 1073741824;
                } else {
                    i12 = z10 ? 1073741824 : Integer.MIN_VALUE;
                }
                int i19 = ((ViewGroup.LayoutParams) fVar2).width;
                if (i19 != -2) {
                    if (i19 == -1) {
                        i19 = paddingLeft;
                    }
                    i18 = 1073741824;
                } else {
                    i19 = paddingLeft;
                }
                int i20 = ((ViewGroup.LayoutParams) fVar2).height;
                if (i20 == -2) {
                    i20 = measuredHeight;
                    i14 = i12;
                } else if (i20 == -1) {
                    i20 = measuredHeight;
                }
                childAt.measure(View.MeasureSpec.makeMeasureSpec(i19, i18), View.MeasureSpec.makeMeasureSpec(i20, i14));
                if (z11) {
                    measuredHeight -= childAt.getMeasuredHeight();
                } else if (z10) {
                    paddingLeft -= childAt.getMeasuredWidth();
                }
            }
            i13++;
        }
        View.MeasureSpec.makeMeasureSpec(paddingLeft, 1073741824);
        this.f4379j = View.MeasureSpec.makeMeasureSpec(measuredHeight, 1073741824);
        this.f4381k = true;
        j();
        this.f4381k = false;
        int childCount2 = getChildCount();
        for (int i21 = 0; i21 < childCount2; i21++) {
            View childAt2 = getChildAt(i21);
            if (childAt2.getVisibility() != 8 && ((fVar = (f) childAt2.getLayoutParams()) == null || !fVar.f34175a)) {
                fVar.getClass();
                childAt2.measure(View.MeasureSpec.makeMeasureSpec((int) (paddingLeft * 0.0f), 1073741824), this.f4379j);
            }
        }
    }

    @Override // android.view.ViewGroup
    public final boolean onRequestFocusInDescendants(int i10, Rect rect) {
        int i11;
        int i12;
        int i13;
        int childCount = getChildCount();
        if ((i10 & 2) != 0) {
            i12 = 1;
            i13 = childCount;
            i11 = 0;
        } else {
            i11 = childCount - 1;
            i12 = -1;
            i13 = -1;
        }
        while (i11 != i13) {
            if (getChildAt(i11).getVisibility() == 0) {
                e();
            }
            i11 += i12;
        }
        return false;
    }

    @Override // android.view.View
    public final void onRestoreInstanceState(Parcelable parcelable) {
        if (!(parcelable instanceof j)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        j jVar = (j) parcelable;
        super.onRestoreInstanceState(jVar.getSuperState());
        this.f4367d = jVar.f34178d;
    }

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        j jVar = new j(super.onSaveInstanceState());
        jVar.f34177c = 0;
        return jVar;
    }

    @Override // android.view.View
    public final void onSizeChanged(int i10, int i11, int i12, int i13) {
        super.onSizeChanged(i10, i11, i12, i13);
        if (i10 != i12) {
            int i14 = this.f4371f;
            k(i10, i12, i14, i14);
        }
    }

    @Override // android.view.View
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            motionEvent.getEdgeFlags();
        }
        return false;
    }

    @Override // android.view.ViewGroup, android.view.ViewManager
    public final void removeView(View view) {
        if (this.f4381k) {
            removeViewInLayout(view);
        } else {
            super.removeView(view);
        }
    }

    public void setAdapter(@Nullable a aVar) {
        ArrayList arrayList = this.f4386m0;
        if (arrayList == null || arrayList.isEmpty()) {
            return;
        }
        int size = this.f4386m0.size();
        for (int i10 = 0; i10 < size; i10++) {
            ((w3.g) this.f4386m0.get(i10)).onAdapterChanged(this, null, aVar);
        }
    }

    public void setCurrentItem(int i10) {
        setScrollingCacheEnabled(false);
    }

    public void setOffscreenPageLimit(int i10) {
        if (i10 < 1) {
            i10 = 1;
        }
        if (i10 != this.f4385m) {
            this.f4385m = i10;
            j();
        }
    }

    @Deprecated
    public void setOnPageChangeListener(h hVar) {
        this.f4382k0 = hVar;
    }

    public void setPageMargin(int i10) {
        int i11 = this.f4371f;
        this.f4371f = i10;
        int width = getWidth();
        k(width, width, i10, i11);
        requestLayout();
    }

    public void setPageMarginDrawable(@Nullable Drawable drawable) {
        this.f4373g = drawable;
        if (drawable != null) {
            refreshDrawableState();
        }
        setWillNotDraw(drawable == null);
        invalidate();
    }

    public void setPageTransformer(boolean z10, @Nullable i iVar) {
        setPageTransformer(z10, iVar, 2);
    }

    public void setScrollState(int i10) {
        if (this.f4390q0 == i10) {
            return;
        }
        this.f4390q0 = i10;
        h hVar = this.f4382k0;
        if (hVar != null) {
            hVar.a(i10);
        }
        ArrayList arrayList = this.f4380j0;
        if (arrayList != null) {
            int size = arrayList.size();
            for (int i11 = 0; i11 < size; i11++) {
                h hVar2 = (h) this.f4380j0.get(i11);
                if (hVar2 != null) {
                    hVar2.a(i10);
                }
            }
        }
        h hVar3 = this.f4384l0;
        if (hVar3 != null) {
            hVar3.a(i10);
        }
    }

    @Override // android.view.View
    public final boolean verifyDrawable(Drawable drawable) {
        return super.verifyDrawable(drawable) || drawable == this.f4373g;
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        Context context = getContext();
        f fVar = new f(context, attributeSet);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f4358r0);
        fVar.f34176b = typedArrayObtainStyledAttributes.getInteger(0, 48);
        typedArrayObtainStyledAttributes.recycle();
        return fVar;
    }

    public void setCurrentItem(int i10, boolean z10) {
        setScrollingCacheEnabled(false);
    }

    public void setPageTransformer(boolean z10, @Nullable i iVar, int i10) {
        boolean z11 = iVar != null;
        setChildrenDrawingOrderEnabled(z11);
        if (z11) {
            this.f4387n0 = z10 ? 2 : 1;
        } else {
            this.f4387n0 = 0;
        }
        if (z11) {
            j();
        }
    }

    public void setPageMarginDrawable(@DrawableRes int i10) {
        setPageMarginDrawable(d.getDrawable(getContext(), i10));
    }

    public ViewPager(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f4361a = new ArrayList();
        this.f4363b = new e();
        this.f4365c = new Rect();
        this.f4375h = -3.4028235E38f;
        this.f4377i = Float.MAX_VALUE;
        this.f4385m = 1;
        this.f4364b0 = -1;
        this.f4374g0 = true;
        this.f4389p0 = new s0(this, 14);
        this.f4390q0 = 0;
        g();
    }
}
