package com.bytedance.adsdk.ugeno.wu;

import android.R;
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.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.EdgeEffect;
import android.widget.Scroller;
import com.google.android.gms.measurement.internal.u1;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import u.a;

/* JADX INFO: loaded from: classes.dex */
public class lb extends ViewGroup {
    private yz ado;
    private boolean ai;
    private ArrayList<View> aws;
    private boolean bkb;
    private List<Object> bwv;
    private VelocityTracker bx;
    private Scroller dsz;
    private ClassLoader duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private final Rect f6391ef;
    private ajl fhx;
    private int fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private float f6392gc;
    private int gof;
    private int gqi;
    private boolean gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private int f6393ha;
    private boolean hi;
    private boolean hlt;
    private float hxv;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    private EdgeEffect f6394ib;
    private int irt;
    private int jm;
    private Parcelable ku;
    private boolean kwx;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    com.bytedance.adsdk.ugeno.wu.ro f6395lb;
    private boolean lmk;
    private int lse;
    private int lz;
    private int maa;
    private yz mj;
    private int mon;
    private int mpp;
    private int mq;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    private EdgeEffect f6396ne;
    private boolean nt;
    private int ol;
    private boolean onz;
    private final Runnable pbk;
    private int pcm;
    private float pkk;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    private int f6397qf;
    private Drawable qhl;
    private float sds;
    private boolean si;
    private int so;
    private int tzk;
    private int vt;
    private List<yz> vvj;
    private int wbw;
    private float wey;
    private final ArrayList<ro> wsy;
    private final ro wu;
    private float xgn;
    private jnr ywr;
    int yz;
    private int zan;
    static final int[] ro = {R.attr.layout_gravity};
    private static final Comparator<ro> jnr = new Comparator<ro>() { // from class: com.bytedance.adsdk.ugeno.wu.lb.1
        @Override // java.util.Comparator
        /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
        public int compare(ro roVar, ro roVar2) {
            return roVar.ro - roVar2.ro;
        }
    };
    private static final Interpolator ajl = new Interpolator() { // from class: com.bytedance.adsdk.ugeno.wu.lb.2
        @Override // android.animation.TimeInterpolator
        public float getInterpolation(float f10) {
            float f11 = f10 - 1.0f;
            return (f11 * f11 * f11 * f11 * f11) + 1.0f;
        }
    };
    private static final wu rka = new wu();

    public class ajl extends DataSetObserver {
        public ajl() {
        }

        @Override // android.database.DataSetObserver
        public void onChanged() {
            lb.this.ro();
        }

        @Override // android.database.DataSetObserver
        public void onInvalidated() {
            lb.this.ro();
        }
    }

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

    public interface jnr {
        void fm(View view, float f10);
    }

    /* JADX INFO: renamed from: com.bytedance.adsdk.ugeno.wu.lb$lb, reason: collision with other inner class name */
    public static class C0021lb extends ViewGroup.LayoutParams {
        int ajl;
        public boolean fm;
        int jnr;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        float f6398lb;
        public int ro;
        boolean yz;

        public C0021lb() {
            super(-1, -1);
            this.f6398lb = 0.0f;
        }

        public C0021lb(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f6398lb = 0.0f;
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, lb.ro);
            this.ro = typedArrayObtainStyledAttributes.getInteger(0, 48);
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    public static class ro {
        Object fm;
        float jnr;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        boolean f6399lb;
        int ro;
        float yz;
    }

    public static class wsy extends com.bytedance.adsdk.ugeno.wu.fm {
        public static final Parcelable.Creator<wsy> CREATOR = new Parcelable.ClassLoaderCreator<wsy>() { // from class: com.bytedance.adsdk.ugeno.wu.lb.wsy.1
            @Override // android.os.Parcelable.ClassLoaderCreator
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public wsy createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new wsy(parcel, classLoader);
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public wsy createFromParcel(Parcel parcel) {
                return new wsy(parcel, null);
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public wsy[] newArray(int i10) {
                return new wsy[i10];
            }
        };

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        Parcelable f6400lb;
        int ro;
        ClassLoader yz;

        public wsy(Parcelable parcelable) {
            super(parcelable);
        }

        public String toString() {
            StringBuilder sb = new StringBuilder("FragmentPager.SavedState{");
            sb.append(Integer.toHexString(System.identityHashCode(this)));
            sb.append(" position=");
            return a.b(sb, this.ro, "}");
        }

        @Override // com.bytedance.adsdk.ugeno.wu.fm, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i10) {
            super.writeToParcel(parcel, i10);
            parcel.writeInt(this.ro);
            parcel.writeParcelable(this.f6400lb, i10);
        }

        public wsy(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            classLoader = classLoader == null ? getClass().getClassLoader() : classLoader;
            this.ro = parcel.readInt();
            this.f6400lb = parcel.readParcelable(classLoader);
            this.yz = classLoader;
        }
    }

    public static class wu implements Comparator<View> {
        @Override // java.util.Comparator
        /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
        public int compare(View view, View view2) {
            C0021lb c0021lb = (C0021lb) view.getLayoutParams();
            C0021lb c0021lb2 = (C0021lb) view2.getLayoutParams();
            boolean z10 = c0021lb.fm;
            return z10 != c0021lb2.fm ? z10 ? 1 : -1 : c0021lb.jnr - c0021lb2.jnr;
        }
    }

    public interface yz {
        void dsz(int i10);

        void duv(int i10);

        void fm(int i10, float f10, int i11);
    }

    public lb(Context context) {
        super(context);
        this.wsy = new ArrayList<>();
        this.wu = new ro();
        this.f6391ef = new Rect();
        this.vt = -1;
        this.ku = null;
        this.duv = null;
        this.wey = -3.4028235E38f;
        this.sds = Float.MAX_VALUE;
        this.mq = 1;
        this.mon = -1;
        this.kwx = true;
        this.bkb = false;
        this.pbk = new Runnable() { // from class: com.bytedance.adsdk.ugeno.wu.lb.3
            @Override // java.lang.Runnable
            public void run() {
                lb.this.setScrollState(0);
                lb.this.lb();
            }
        };
        this.jm = 0;
        fm();
    }

    private void ajl() {
        int i10 = 0;
        while (i10 < getChildCount()) {
            if (!((C0021lb) getChildAt(i10).getLayoutParams()).fm) {
                removeViewAt(i10);
                i10--;
            }
            i10++;
        }
    }

    private ro ef() {
        int i10;
        int clientWidth = getClientWidth();
        float f10 = 0.0f;
        float scrollX = clientWidth > 0 ? getScrollX() / clientWidth : 0.0f;
        float f11 = clientWidth > 0 ? this.irt / clientWidth : 0.0f;
        int i11 = 0;
        boolean z10 = true;
        ro roVar = null;
        int i12 = -1;
        float f12 = 0.0f;
        while (i11 < this.wsy.size()) {
            ro roVar2 = this.wsy.get(i11);
            if (!z10 && roVar2.ro != (i10 = i12 + 1)) {
                roVar2 = this.wu;
                roVar2.jnr = f10 + f12 + f11;
                roVar2.ro = i10;
                roVar2.yz = this.f6395lb.fm(i10);
                i11--;
            }
            ro roVar3 = roVar2;
            f10 = roVar3.jnr;
            float f13 = roVar3.yz + f10 + f11;
            if (!z10 && scrollX < f10) {
                return roVar;
            }
            if (scrollX < f13 || i11 == this.wsy.size() - 1) {
                return roVar3;
            }
            int i13 = roVar3.ro;
            float f14 = roVar3.yz;
            i11++;
            z10 = false;
            i12 = i13;
            f12 = f14;
            roVar = roVar3;
        }
        return roVar;
    }

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

    private void jnr(int i10) {
        yz yzVar = this.mj;
        if (yzVar != null) {
            yzVar.duv(i10);
        }
        List<yz> list = this.vvj;
        if (list != null) {
            int size = list.size();
            for (int i11 = 0; i11 < size; i11++) {
                yz yzVar2 = this.vvj.get(i11);
                if (yzVar2 != null) {
                    yzVar2.duv(i10);
                }
            }
        }
        yz yzVar3 = this.ado;
        if (yzVar3 != null) {
            yzVar3.duv(i10);
        }
    }

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

    private void vt() {
        this.gzf = false;
        this.ai = false;
        VelocityTracker velocityTracker = this.bx;
        if (velocityTracker != null) {
            velocityTracker.recycle();
            this.bx = null;
        }
    }

    private void wsy() {
        if (this.so != 0) {
            ArrayList<View> arrayList = this.aws;
            if (arrayList == null) {
                this.aws = new ArrayList<>();
            } else {
                arrayList.clear();
            }
            int childCount = getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                this.aws.add(getChildAt(i10));
            }
            Collections.sort(this.aws, rka);
        }
    }

    private boolean wu() {
        this.mon = -1;
        vt();
        this.f6394ib.onRelease();
        this.f6396ne.onRelease();
        return this.f6394ib.isFinished() || this.f6396ne.isFinished();
    }

    private boolean yz(int i10) {
        if (this.wsy.size() == 0) {
            if (this.kwx) {
                return false;
            }
            this.lmk = false;
            fm(0, 0.0f, 0);
            if (this.lmk) {
                return false;
            }
            throw new IllegalStateException("onPageScrolled did not call superclass implementation");
        }
        ro roVarEf = ef();
        int clientWidth = getClientWidth();
        int i11 = this.irt;
        int i12 = clientWidth + i11;
        float f10 = clientWidth;
        int i13 = roVarEf.ro;
        float f11 = ((i10 / f10) - roVarEf.jnr) / (roVarEf.yz + (i11 / f10));
        this.lmk = false;
        fm(i13, f11, (int) (i12 * f11));
        if (this.lmk) {
            return true;
        }
        throw new IllegalStateException("onPageScrolled did not call superclass implementation");
    }

    @Override // android.view.ViewGroup, android.view.View
    public void addFocusables(ArrayList<View> arrayList, int i10, int i11) {
        ro roVarFm;
        int size = arrayList.size();
        int descendantFocusability = getDescendantFocusability();
        if (descendantFocusability != 393216) {
            for (int i12 = 0; i12 < getChildCount(); i12++) {
                View childAt = getChildAt(i12);
                if (childAt.getVisibility() == 0 && (roVarFm = fm(childAt)) != null && roVarFm.ro == this.yz) {
                    childAt.addFocusables(arrayList, i10, i11);
                }
            }
        }
        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 void addTouchables(ArrayList<View> arrayList) {
        ro roVarFm;
        for (int i10 = 0; i10 < getChildCount(); i10++) {
            View childAt = getChildAt(i10);
            if (childAt.getVisibility() == 0 && (roVarFm = fm(childAt)) != null && roVarFm.ro == this.yz) {
                childAt.addTouchables(arrayList);
            }
        }
    }

    @Override // android.view.ViewGroup
    public void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) {
        if (!checkLayoutParams(layoutParams)) {
            layoutParams = generateLayoutParams(layoutParams);
        }
        C0021lb c0021lb = (C0021lb) layoutParams;
        boolean zLb = c0021lb.fm | lb(view);
        c0021lb.fm = zLb;
        if (!this.hlt) {
            super.addView(view, i10, layoutParams);
        } else {
            if (zLb) {
                throw new IllegalStateException("Cannot add pager decor view during layout");
            }
            c0021lb.yz = true;
            addViewInLayout(view, i10, layoutParams);
        }
    }

    @Override // android.view.View
    public boolean canScrollHorizontally(int i10) {
        if (this.f6395lb == null) {
            return false;
        }
        int clientWidth = getClientWidth();
        int scrollX = getScrollX();
        return i10 < 0 ? scrollX > ((int) (((float) clientWidth) * this.wey)) : i10 > 0 && scrollX < ((int) (((float) clientWidth) * this.sds));
    }

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

    @Override // android.view.View
    public void computeScroll() {
        this.onz = true;
        if (this.dsz.isFinished() || !this.dsz.computeScrollOffset()) {
            fm(true);
            return;
        }
        int scrollX = getScrollX();
        int scrollY = getScrollY();
        int currX = this.dsz.getCurrX();
        int currY = this.dsz.getCurrY();
        if (scrollX != currX || scrollY != currY) {
            scrollTo(currX, currY);
            if (!yz(currX)) {
                this.dsz.abortAnimation();
                scrollTo(0, currY);
            }
        }
        postInvalidateOnAnimation();
    }

    @Override // android.view.ViewGroup, android.view.View
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent) || fm(keyEvent);
    }

    @Override // android.view.View
    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        ro roVarFm;
        if (accessibilityEvent.getEventType() == 4096) {
            return super.dispatchPopulateAccessibilityEvent(accessibilityEvent);
        }
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if (childAt.getVisibility() == 0 && (roVarFm = fm(childAt)) != null && roVarFm.ro == this.yz && childAt.dispatchPopulateAccessibilityEvent(accessibilityEvent)) {
                return true;
            }
        }
        return false;
    }

    @Override // android.view.View
    public void draw(Canvas canvas) {
        boolean zDraw;
        com.bytedance.adsdk.ugeno.wu.ro roVar;
        super.draw(canvas);
        int overScrollMode = getOverScrollMode();
        if (overScrollMode != 0 && (overScrollMode != 1 || (roVar = this.f6395lb) == null || roVar.fm() <= 1)) {
            this.f6394ib.finish();
            this.f6396ne.finish();
            return;
        }
        if (this.f6394ib.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.wey * width);
            this.f6394ib.setSize(height, width);
            zDraw = this.f6394ib.draw(canvas);
            canvas.restoreToCount(iSave);
        }
        if (!this.f6396ne.isFinished()) {
            int iSave2 = canvas.save();
            int width2 = getWidth();
            int height2 = (getHeight() - getPaddingTop()) - getPaddingBottom();
            canvas.rotate(90.0f);
            canvas.translate(-getPaddingTop(), (-(this.sds + 1.0f)) * width2);
            this.f6396ne.setSize(height2, width2);
            zDraw |= this.f6396ne.draw(canvas);
            canvas.restoreToCount(iSave2);
        }
        if (zDraw) {
            postInvalidateOnAnimation();
        }
    }

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

    public void fm() {
        setWillNotDraw(false);
        setDescendantFocusability(262144);
        setFocusable(true);
        Context context = getContext();
        this.dsz = new Scroller(context, ajl);
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        float f10 = context.getResources().getDisplayMetrics().density;
        this.f6393ha = viewConfiguration.getScaledPagingTouchSlop();
        this.zan = (int) (400.0f * f10);
        this.tzk = viewConfiguration.getScaledMaximumFlingVelocity();
        this.f6394ib = new EdgeEffect(context);
        this.f6396ne = new EdgeEffect(context);
        this.lz = (int) (25.0f * f10);
        this.f6397qf = (int) (2.0f * f10);
        this.ol = (int) (f10 * 16.0f);
    }

    @Override // android.view.ViewGroup
    public ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return new C0021lb();
    }

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

    public com.bytedance.adsdk.ugeno.wu.ro getAdapter() {
        return this.f6395lb;
    }

    @Override // android.view.ViewGroup
    public int getChildDrawingOrder(int i10, int i11) {
        if (this.so == 2) {
            i11 = (i10 - 1) - i11;
        }
        return ((C0021lb) this.aws.get(i11).getLayoutParams()).ajl;
    }

    public int getCurrentItem() {
        return this.yz;
    }

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

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

    public void lb() {
        fm(this.yz);
    }

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

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

    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        int i10;
        float f10;
        float f11;
        super.onDraw(canvas);
        if (this.irt <= 0 || this.qhl == null || this.wsy.size() <= 0 || this.f6395lb == null) {
            return;
        }
        int scrollX = getScrollX();
        float width = getWidth();
        float f12 = this.irt / width;
        int i11 = 0;
        ro roVar = this.wsy.get(0);
        float f13 = roVar.jnr;
        int size = this.wsy.size();
        int i12 = roVar.ro;
        int i13 = this.wsy.get(size - 1).ro;
        while (i12 < i13) {
            while (true) {
                i10 = roVar.ro;
                if (i12 <= i10 || i11 >= size) {
                    break;
                }
                i11++;
                roVar = this.wsy.get(i11);
            }
            if (i12 == i10) {
                float f14 = roVar.jnr;
                float f15 = roVar.yz;
                f10 = (f14 + f15) * width;
                f13 = f14 + f15 + f12;
            } else {
                float fFm = this.f6395lb.fm(i12);
                f10 = (f13 + fFm) * width;
                f13 = fFm + f12 + f13;
            }
            if (this.irt + f10 > scrollX) {
                f11 = f12;
                this.qhl.setBounds(Math.round(f10), this.gof, Math.round(this.irt + f10), this.gqi);
                this.qhl.draw(canvas);
            } else {
                f11 = f12;
            }
            if (f10 > scrollX + r2) {
                return;
            }
            i12++;
            f12 = f11;
        }
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        int iFindPointerIndex;
        int action = motionEvent.getAction() & 255;
        if (action == 3 || action == 1) {
            wu();
            return false;
        }
        if (action != 0) {
            if (this.gzf) {
                return true;
            }
            if (this.ai) {
                return false;
            }
        }
        if (action == 0) {
            float x10 = motionEvent.getX();
            this.f6392gc = x10;
            this.pkk = x10;
            float y10 = motionEvent.getY();
            this.xgn = y10;
            this.hxv = y10;
            this.mon = motionEvent.getPointerId(0);
            this.ai = false;
            this.onz = true;
            this.dsz.computeScrollOffset();
            if (this.jm != 2 || Math.abs(this.dsz.getFinalX() - this.dsz.getCurrX()) <= this.f6397qf) {
                fm(false);
                this.gzf = false;
            } else {
                this.dsz.abortAnimation();
                this.nt = false;
                lb();
                this.gzf = true;
                lb(true);
                setScrollState(1);
            }
        } else if (action == 2) {
            int i10 = this.mon;
            if (i10 != -1 && (iFindPointerIndex = motionEvent.findPointerIndex(i10)) != -1) {
                float x11 = motionEvent.getX(iFindPointerIndex);
                float f10 = x11 - this.pkk;
                float fAbs = Math.abs(f10);
                float y11 = motionEvent.getY(iFindPointerIndex);
                float fAbs2 = Math.abs(y11 - this.xgn);
                if (f10 != 0.0f && !fm(this.pkk, f10) && fm(this, false, (int) f10, (int) x11, (int) y11)) {
                    this.pkk = x11;
                    this.hxv = y11;
                    this.ai = true;
                    return false;
                }
                int i11 = this.f6393ha;
                if (fAbs > i11 && fAbs * 0.5f > fAbs2) {
                    this.gzf = true;
                    lb(true);
                    setScrollState(1);
                    this.pkk = f10 > 0.0f ? this.f6392gc + this.f6393ha : this.f6392gc - this.f6393ha;
                    this.hxv = y11;
                    setScrollingCacheEnabled(true);
                } else if (fAbs2 > i11) {
                    this.ai = true;
                }
                if (this.gzf && ro(x11)) {
                    postInvalidateOnAnimation();
                }
            }
        } else if (action == 6) {
            fm(motionEvent);
        }
        if (this.bx == null) {
            this.bx = VelocityTracker.obtain();
        }
        this.bx.addMovement(motionEvent);
        return this.gzf;
    }

    /* 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 void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        boolean z11;
        ro roVarFm;
        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) {
                C0021lb c0021lb = (C0021lb) childAt.getLayoutParams();
                if (c0021lb.fm) {
                    int i18 = c0021lb.ro;
                    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;
                }
            }
        }
        int i24 = (i14 - paddingLeft) - paddingRight;
        for (int i25 = 0; i25 < childCount; i25++) {
            View childAt2 = getChildAt(i25);
            if (childAt2.getVisibility() != 8) {
                C0021lb c0021lb2 = (C0021lb) childAt2.getLayoutParams();
                if (!c0021lb2.fm && (roVarFm = fm(childAt2)) != null) {
                    float f10 = i24;
                    int i26 = ((int) (roVarFm.jnr * f10)) + paddingLeft;
                    if (c0021lb2.yz) {
                        c0021lb2.yz = false;
                        childAt2.measure(View.MeasureSpec.makeMeasureSpec((int) (f10 * c0021lb2.f6398lb), 1073741824), View.MeasureSpec.makeMeasureSpec((i15 - paddingTop) - paddingBottom, 1073741824));
                    }
                    childAt2.layout(i26, paddingTop, childAt2.getMeasuredWidth() + i26, childAt2.getMeasuredHeight() + paddingTop);
                }
            }
        }
        this.gof = paddingTop;
        this.gqi = i15 - paddingBottom;
        this.mpp = i16;
        if (this.kwx) {
            z11 = false;
            fm(this.yz, false, 0, false);
        } else {
            z11 = false;
        }
        this.kwx = z11;
    }

    @Override // android.view.View
    public void onMeasure(int i10, int i11) {
        C0021lb c0021lb;
        C0021lb c0021lb2;
        int i12;
        setMeasuredDimension(View.getDefaultSize(0, i10), View.getDefaultSize(0, i11));
        int measuredWidth = getMeasuredWidth();
        this.wbw = Math.min(measuredWidth / 10, this.ol);
        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 && (c0021lb2 = (C0021lb) childAt.getLayoutParams()) != null && c0021lb2.fm) {
                int i15 = c0021lb2.ro;
                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) c0021lb2).width;
                if (i19 != -2) {
                    if (i19 == -1) {
                        i19 = paddingLeft;
                    }
                    i18 = 1073741824;
                } else {
                    i19 = paddingLeft;
                }
                int i20 = ((ViewGroup.LayoutParams) c0021lb2).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++;
        }
        this.maa = View.MeasureSpec.makeMeasureSpec(paddingLeft, 1073741824);
        this.lse = View.MeasureSpec.makeMeasureSpec(measuredHeight, 1073741824);
        this.hlt = true;
        lb();
        this.hlt = false;
        int childCount2 = getChildCount();
        for (int i21 = 0; i21 < childCount2; i21++) {
            View childAt2 = getChildAt(i21);
            if (childAt2.getVisibility() != 8 && ((c0021lb = (C0021lb) childAt2.getLayoutParams()) == null || !c0021lb.fm)) {
                childAt2.measure(View.MeasureSpec.makeMeasureSpec((int) (paddingLeft * c0021lb.f6398lb), 1073741824), this.lse);
            }
        }
    }

    @Override // android.view.ViewGroup
    public boolean onRequestFocusInDescendants(int i10, Rect rect) {
        int i11;
        int i12;
        int i13;
        ro roVarFm;
        int childCount = getChildCount();
        if ((i10 & 2) != 0) {
            i12 = childCount;
            i11 = 0;
            i13 = 1;
        } else {
            i11 = childCount - 1;
            i12 = -1;
            i13 = -1;
        }
        while (i11 != i12) {
            View childAt = getChildAt(i11);
            if (childAt.getVisibility() == 0 && (roVarFm = fm(childAt)) != null && roVarFm.ro == this.yz && childAt.requestFocus(i10, rect)) {
                return true;
            }
            i11 += i13;
        }
        return false;
    }

    @Override // android.view.View
    public void onRestoreInstanceState(Parcelable parcelable) {
        if (!(parcelable instanceof wsy)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        wsy wsyVar = (wsy) parcelable;
        super.onRestoreInstanceState(wsyVar.fm());
        if (this.f6395lb != null) {
            fm(wsyVar.ro, false, true);
            return;
        }
        this.vt = wsyVar.ro;
        this.ku = wsyVar.f6400lb;
        this.duv = wsyVar.yz;
    }

    @Override // android.view.View
    public Parcelable onSaveInstanceState() {
        wsy wsyVar = new wsy(super.onSaveInstanceState());
        wsyVar.ro = this.yz;
        com.bytedance.adsdk.ugeno.wu.ro roVar = this.f6395lb;
        if (roVar != null) {
            wsyVar.f6400lb = roVar.ro();
        }
        return wsyVar;
    }

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

    /* JADX WARN: Removed duplicated region for block: B:67:0x0141  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean onTouchEvent(MotionEvent motionEvent) {
        com.bytedance.adsdk.ugeno.wu.ro roVar;
        boolean zWu;
        int iFindPointerIndex;
        if (this.si) {
            return true;
        }
        if ((motionEvent.getAction() == 0 && motionEvent.getEdgeFlags() != 0) || (roVar = this.f6395lb) == null || roVar.fm() == 0) {
            return false;
        }
        if (this.bx == null) {
            this.bx = VelocityTracker.obtain();
        }
        this.bx.addMovement(motionEvent);
        int action = motionEvent.getAction() & 255;
        if (action == 0) {
            this.dsz.abortAnimation();
            this.nt = false;
            lb();
            float x10 = motionEvent.getX();
            this.f6392gc = x10;
            this.pkk = x10;
            float y10 = motionEvent.getY();
            this.xgn = y10;
            this.hxv = y10;
            this.mon = motionEvent.getPointerId(0);
        } else if (action != 1) {
            if (action != 2) {
                if (action != 3) {
                    if (action == 5) {
                        int actionIndex = motionEvent.getActionIndex();
                        if (actionIndex != -1) {
                            this.pkk = motionEvent.getX(actionIndex);
                            this.mon = motionEvent.getPointerId(actionIndex);
                        }
                    } else if (action == 6) {
                        fm(motionEvent);
                        int iFindPointerIndex2 = motionEvent.findPointerIndex(this.mon);
                        if (iFindPointerIndex2 != -1) {
                            this.pkk = motionEvent.getX(iFindPointerIndex2);
                        }
                    }
                } else if (this.gzf) {
                    fm(this.yz, true, 0, false);
                    zWu = wu();
                    if (zWu) {
                        postInvalidateOnAnimation();
                    }
                }
            } else if (!this.gzf) {
                int iFindPointerIndex3 = motionEvent.findPointerIndex(this.mon);
                if (iFindPointerIndex3 == -1) {
                    zWu = wu();
                    if (zWu) {
                    }
                } else {
                    float x11 = motionEvent.getX(iFindPointerIndex3);
                    float fAbs = Math.abs(x11 - this.pkk);
                    float y11 = motionEvent.getY(iFindPointerIndex3);
                    float fAbs2 = Math.abs(y11 - this.hxv);
                    if (fAbs > this.f6393ha && fAbs > fAbs2) {
                        this.gzf = true;
                        lb(true);
                        float f10 = this.f6392gc;
                        this.pkk = x11 - f10 > 0.0f ? f10 + this.f6393ha : f10 - this.f6393ha;
                        this.hxv = y11;
                        setScrollState(1);
                        setScrollingCacheEnabled(true);
                        ViewParent parent = getParent();
                        if (parent != null) {
                            parent.requestDisallowInterceptTouchEvent(true);
                        }
                    }
                    if (this.gzf) {
                        zWu = ro(motionEvent.getX(iFindPointerIndex));
                        if (zWu) {
                        }
                    }
                }
            } else if (this.gzf && (iFindPointerIndex = motionEvent.findPointerIndex(this.mon)) != -1) {
                zWu = ro(motionEvent.getX(iFindPointerIndex));
                if (zWu) {
                }
            }
        } else if (this.gzf) {
            VelocityTracker velocityTracker = this.bx;
            velocityTracker.computeCurrentVelocity(1000, this.tzk);
            int xVelocity = (int) velocityTracker.getXVelocity(this.mon);
            this.nt = true;
            int clientWidth = getClientWidth();
            int scrollX = getScrollX();
            ro roVarEf = ef();
            float f11 = clientWidth;
            int i10 = roVarEf.ro;
            float f12 = ((scrollX / f11) - roVarEf.jnr) / (roVarEf.yz + (this.irt / f11));
            int iFindPointerIndex4 = motionEvent.findPointerIndex(this.mon);
            if (iFindPointerIndex4 != -1) {
                fm(fm(i10, f12, xVelocity, (int) (motionEvent.getX(iFindPointerIndex4) - this.f6392gc)), true, true, xVelocity);
                zWu = wu();
                if (zWu) {
                }
            }
        }
        return true;
    }

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

    public void ro(yz yzVar) {
        List<yz> list = this.vvj;
        if (list != null) {
            list.remove(yzVar);
        }
    }

    public void setAdapter(com.bytedance.adsdk.ugeno.wu.ro roVar) {
        com.bytedance.adsdk.ugeno.wu.ro roVar2 = this.f6395lb;
        if (roVar2 != null) {
            roVar2.fm((DataSetObserver) null);
            for (int i10 = 0; i10 < this.wsy.size(); i10++) {
                ro roVar3 = this.wsy.get(i10);
                this.f6395lb.fm((ViewGroup) this, roVar3.ro, roVar3.fm);
            }
            this.wsy.clear();
            ajl();
            this.yz = 0;
            scrollTo(0, 0);
        }
        this.f6395lb = roVar;
        this.fm = 0;
        if (roVar != null) {
            if (this.fhx == null) {
                this.fhx = new ajl();
            }
            this.f6395lb.fm((DataSetObserver) this.fhx);
            this.nt = false;
            boolean z10 = this.kwx;
            this.kwx = true;
            this.fm = this.f6395lb.fm();
            int i11 = this.vt;
            if (i11 >= 0) {
                fm(i11, false, true);
                this.vt = -1;
                this.ku = null;
                this.duv = null;
            } else if (z10) {
                requestLayout();
            } else {
                lb();
            }
        }
        List<Object> list = this.bwv;
        if (list == null || list.isEmpty()) {
            return;
        }
        int size = this.bwv.size();
        for (int i12 = 0; i12 < size; i12++) {
            this.bwv.get(i12);
        }
    }

    public void setCurrentItem(int i10) {
        this.nt = false;
        fm(i10, !this.kwx, false);
    }

    public void setOffscreenPageLimit(int i10) {
        if (i10 <= 0) {
            i10 = 1;
        }
        if (i10 != this.mq) {
            this.mq = i10;
            lb();
        }
    }

    @Deprecated
    public void setOnPageChangeListener(yz yzVar) {
        this.mj = yzVar;
    }

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

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

    public void setScrollState(int i10) {
        if (this.jm == i10) {
            return;
        }
        this.jm = i10;
        if (this.ywr != null) {
            ro(i10 != 0);
        }
        ajl(i10);
    }

    public void setScroller(Scroller scroller) {
        this.dsz = scroller;
    }

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

    private static boolean lb(View view) {
        return view.getClass().getAnnotation(fm.class) != null;
    }

    @Override // android.view.ViewGroup
    public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return new C0021lb(getContext(), attributeSet);
    }

    public void ro() {
        int iFm = this.f6395lb.fm();
        this.fm = iFm;
        boolean z10 = this.wsy.size() < (this.mq * 2) + 1 && this.wsy.size() < iFm;
        int iMax = this.yz;
        int i10 = 0;
        while (i10 < this.wsy.size()) {
            ro roVar = this.wsy.get(i10);
            int iFm2 = this.f6395lb.fm(roVar.fm);
            if (iFm2 != -1) {
                if (iFm2 == -2) {
                    this.wsy.remove(i10);
                    i10--;
                    this.f6395lb.fm((ViewGroup) this, roVar.ro, roVar.fm);
                    int i11 = this.yz;
                    if (i11 == roVar.ro) {
                        iMax = Math.max(0, Math.min(i11, iFm - 1));
                    }
                } else {
                    int i12 = roVar.ro;
                    if (i12 != iFm2) {
                        if (i12 == this.yz) {
                            iMax = iFm2;
                        }
                        roVar.ro = iFm2;
                    }
                }
                z10 = true;
            }
            i10++;
        }
        Collections.sort(this.wsy, jnr);
        if (z10) {
            int childCount = getChildCount();
            for (int i13 = 0; i13 < childCount; i13++) {
                C0021lb c0021lb = (C0021lb) getChildAt(i13).getLayoutParams();
                if (!c0021lb.fm) {
                    c0021lb.f6398lb = 0.0f;
                }
            }
            fm(iMax, false, true);
            requestLayout();
        }
    }

    private void lb(boolean z10) {
        ViewParent parent = getParent();
        if (parent != null) {
            parent.requestDisallowInterceptTouchEvent(z10);
        }
    }

    public void setPageMarginDrawable(int i10) {
        setPageMarginDrawable(getContext().getResources().getDrawable(i10));
    }

    private void ajl(int i10) {
        yz yzVar = this.mj;
        if (yzVar != null) {
            yzVar.dsz(i10);
        }
        List<yz> list = this.vvj;
        if (list != null) {
            int size = list.size();
            for (int i11 = 0; i11 < size; i11++) {
                yz yzVar2 = this.vvj.get(i11);
                if (yzVar2 != null) {
                    yzVar2.dsz(i10);
                }
            }
        }
        yz yzVar3 = this.ado;
        if (yzVar3 != null) {
            yzVar3.dsz(i10);
        }
    }

    public boolean jnr() {
        com.bytedance.adsdk.ugeno.wu.ro roVar = this.f6395lb;
        if (roVar == null || this.yz >= roVar.fm() - 1) {
            return false;
        }
        fm(this.yz + 1, true);
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00a1  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean lb(int i10) {
        boolean zYz;
        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;
                }
            }
            StringBuilder sb = new StringBuilder();
            sb.append(viewFindFocus.getClass().getSimpleName());
            for (ViewParent parent2 = viewFindFocus.getParent(); parent2 instanceof ViewGroup; parent2 = parent2.getParent()) {
                sb.append(" => ");
                sb.append(parent2.getClass().getSimpleName());
            }
            viewFindFocus = null;
        }
        View viewFindNextFocus = FocusFinder.getInstance().findNextFocus(this, viewFindFocus, i10);
        if (viewFindNextFocus == null || viewFindNextFocus == viewFindFocus) {
            if (i10 != 17 && i10 != 1) {
                zYz = (i10 == 66 || i10 == 2) ? jnr() : false;
            } else {
                zYz = yz();
            }
        } else if (i10 == 17) {
            int i11 = fm(this.f6391ef, viewFindNextFocus).left;
            int i12 = fm(this.f6391ef, viewFindFocus).left;
            if (viewFindFocus != null && i11 >= i12) {
                zYz = yz();
            } else {
                zYz = viewFindNextFocus.requestFocus();
            }
        } else if (i10 == 66) {
            int i13 = fm(this.f6391ef, viewFindNextFocus).left;
            int i14 = fm(this.f6391ef, viewFindFocus).left;
            if (viewFindFocus == null || i13 > i14) {
                zYz = viewFindNextFocus.requestFocus();
            }
        }
        if (zYz) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(i10));
        }
        return zYz;
    }

    public boolean yz() {
        int i10 = this.yz;
        if (i10 <= 0) {
            return false;
        }
        fm(i10 - 1, true);
        return true;
    }

    public void fm(int i10, boolean z10) {
        this.nt = false;
        fm(i10, z10, false);
    }

    public void fm(int i10, boolean z10, boolean z11) {
        fm(i10, z10, z11, 0);
    }

    public void fm(int i10, boolean z10, boolean z11, int i11) {
        com.bytedance.adsdk.ugeno.wu.ro roVar = this.f6395lb;
        if (roVar != null && roVar.fm() > 0) {
            if (!z11 && this.yz == i10 && this.wsy.size() != 0) {
                setScrollingCacheEnabled(false);
                return;
            }
            if (i10 < 0) {
                i10 = 0;
            } else if (i10 >= this.f6395lb.fm()) {
                i10 = this.f6395lb.fm() - 1;
            }
            int i12 = this.mq;
            int i13 = this.yz;
            if (i10 > i13 + i12 || i10 < i13 - i12) {
                for (int i14 = 0; i14 < this.wsy.size(); i14++) {
                    this.wsy.get(i14).f6399lb = true;
                }
            }
            boolean z12 = this.yz != i10;
            if (this.kwx) {
                this.yz = i10;
                if (z12) {
                    jnr(i10);
                }
                requestLayout();
                return;
            }
            fm(i10);
            fm(i10, z10, i11, z12);
            return;
        }
        setScrollingCacheEnabled(false);
    }

    public ro ro(View view) {
        while (true) {
            Object parent = view.getParent();
            if (parent != this) {
                if (parent == null || !(parent instanceof View)) {
                    return null;
                }
                view = (View) parent;
            } else {
                return fm(view);
            }
        }
    }

    private void fm(int i10, boolean z10, int i11, boolean z11) {
        int iMax;
        ro roVarRo = ro(i10);
        if (roVarRo != null) {
            iMax = (int) (Math.max(this.wey, Math.min(roVarRo.jnr, this.sds)) * getClientWidth());
        } else {
            iMax = 0;
        }
        if (z10) {
            fm(iMax, 0, i11);
            if (z11) {
                jnr(i10);
                return;
            }
            return;
        }
        if (z11) {
            jnr(i10);
        }
        fm(false);
        scrollTo(iMax, 0);
        yz(iMax);
    }

    public ro ro(int i10) {
        for (int i11 = 0; i11 < this.wsy.size(); i11++) {
            ro roVar = this.wsy.get(i11);
            if (roVar.ro == i10) {
                return roVar;
            }
        }
        return null;
    }

    private void ro(int i10, float f10, int i11) {
        yz yzVar = this.mj;
        if (yzVar != null) {
            yzVar.fm(i10, f10, i11);
        }
        List<yz> list = this.vvj;
        if (list != null) {
            int size = list.size();
            for (int i12 = 0; i12 < size; i12++) {
                yz yzVar2 = this.vvj.get(i12);
                if (yzVar2 != null) {
                    yzVar2.fm(i10, f10, i11);
                }
            }
        }
        yz yzVar3 = this.ado;
        if (yzVar3 != null) {
            yzVar3.fm(i10, f10, i11);
        }
    }

    private void ro(boolean z10) {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            getChildAt(i10).setLayerType(z10 ? this.pcm : 0, null);
        }
    }

    private boolean ro(float f10) {
        boolean z10;
        boolean z11;
        float f11 = this.pkk - f10;
        this.pkk = f10;
        float scrollX = getScrollX() + f11;
        float clientWidth = getClientWidth();
        float f12 = this.wey * clientWidth;
        float f13 = this.sds * clientWidth;
        boolean z12 = false;
        ro roVar = this.wsy.get(0);
        ro roVar2 = (ro) u1.e(this.wsy, 1);
        if (roVar.ro != 0) {
            f12 = roVar.jnr * clientWidth;
            z10 = false;
        } else {
            z10 = true;
        }
        if (roVar2.ro != this.f6395lb.fm() - 1) {
            f13 = roVar2.jnr * clientWidth;
            z11 = false;
        } else {
            z11 = true;
        }
        if (scrollX < f12) {
            if (z10) {
                this.f6394ib.onPull(Math.abs(f12 - scrollX) / clientWidth);
                z12 = true;
            }
            scrollX = f12;
        } else if (scrollX > f13) {
            if (z11) {
                this.f6396ne.onPull(Math.abs(scrollX - f13) / clientWidth);
                z12 = true;
            }
            scrollX = f13;
        }
        int i10 = (int) scrollX;
        this.pkk = (scrollX - i10) + this.pkk;
        scrollTo(i10, getScrollY());
        yz(i10);
        return z12;
    }

    public void fm(yz yzVar) {
        if (this.vvj == null) {
            this.vvj = new ArrayList();
        }
        this.vvj.add(yzVar);
    }

    public void fm(boolean z10, jnr jnrVar) {
        fm(z10, jnrVar, 2);
    }

    public void fm(boolean z10, jnr jnrVar, int i10) {
        boolean z11 = jnrVar != null;
        boolean z12 = z11 != (this.ywr != null);
        this.ywr = jnrVar;
        setChildrenDrawingOrderEnabled(z11);
        if (z11) {
            this.so = z10 ? 2 : 1;
            this.pcm = i10;
        } else {
            this.so = 0;
        }
        if (z12) {
            lb();
        }
    }

    public float fm(float f10) {
        return (float) Math.sin((f10 - 0.5f) * 0.47123894f);
    }

    public void fm(int i10, int i11, int i12) {
        int scrollX;
        int iAbs;
        if (getChildCount() == 0) {
            setScrollingCacheEnabled(false);
            return;
        }
        Scroller scroller = this.dsz;
        if (scroller != null && !scroller.isFinished()) {
            scrollX = this.onz ? this.dsz.getCurrX() : this.dsz.getStartX();
            this.dsz.abortAnimation();
            setScrollingCacheEnabled(false);
        } else {
            scrollX = getScrollX();
        }
        int i13 = scrollX;
        int scrollY = getScrollY();
        int i14 = i10 - i13;
        int i15 = i11 - scrollY;
        if (i14 == 0 && i15 == 0) {
            fm(false);
            lb();
            setScrollState(0);
            return;
        }
        setScrollingCacheEnabled(true);
        setScrollState(2);
        int clientWidth = getClientWidth();
        int i16 = clientWidth / 2;
        float f10 = clientWidth;
        float f11 = i16;
        float fFm = (fm(Math.min(1.0f, (Math.abs(i14) * 1.0f) / f10)) * f11) + f11;
        int iAbs2 = Math.abs(i12);
        if (iAbs2 > 0) {
            iAbs = Math.round(Math.abs(fFm / iAbs2) * 1000.0f) * 4;
        } else {
            iAbs = (int) (((Math.abs(i14) / ((this.f6395lb.fm(this.yz) * f10) + this.irt)) + 1.0f) * 100.0f);
        }
        int iMin = Math.min(iAbs, 600);
        this.onz = false;
        this.dsz.startScroll(i13, scrollY, i14, i15, iMin);
        postInvalidateOnAnimation();
    }

    public ro fm(int i10, int i11) {
        ro roVar = new ro();
        roVar.ro = i10;
        roVar.fm = this.f6395lb.fm((ViewGroup) this, i10);
        roVar.yz = this.f6395lb.fm(i10);
        if (i11 >= 0 && i11 < this.wsy.size()) {
            this.wsy.add(i11, roVar);
        } else {
            this.wsy.add(roVar);
        }
        return roVar;
    }

    /* JADX WARN: Code restructure failed: missing block: B:27:0x0061, code lost:
    
        r8 = null;
     */
    /* JADX WARN: Removed duplicated region for block: B:54:0x00c5 A[PHI: r7 r10 r14
      0x00c5: PHI (r7v6 int) = (r7v5 int), (r7v4 int), (r7v9 int) binds: [B:63:0x00e9, B:60:0x00d3, B:52:0x00ba] A[DONT_GENERATE, DONT_INLINE]
      0x00c5: PHI (r10v9 int) = (r10v1 int), (r10v8 int), (r10v12 int) binds: [B:63:0x00e9, B:60:0x00d3, B:52:0x00ba] A[DONT_GENERATE, DONT_INLINE]
      0x00c5: PHI (r14v6 float) = (r14v4 float), (r14v5 float), (r14v3 float) binds: [B:63:0x00e9, B:60:0x00d3, B:52:0x00ba] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void fm(int i10) {
        ro roVarRo;
        String hexString;
        ro roVarFm;
        ro roVarFm2;
        ro roVar;
        int i11 = this.yz;
        if (i11 != i10) {
            roVarRo = ro(i11);
            this.yz = i10;
        } else {
            roVarRo = null;
        }
        if (this.f6395lb == null) {
            wsy();
            return;
        }
        if (this.nt) {
            wsy();
            return;
        }
        if (getWindowToken() == null) {
            return;
        }
        int i12 = this.mq;
        int iMax = Math.max(0, this.yz - i12);
        int iFm = this.f6395lb.fm();
        int iMin = Math.min(iFm - 1, this.yz + i12);
        if (iFm == this.fm) {
            int i13 = 0;
            while (true) {
                if (i13 >= this.wsy.size()) {
                    break;
                }
                roVarFm = this.wsy.get(i13);
                int i14 = roVarFm.ro;
                int i15 = this.yz;
                if (i14 >= i15) {
                    if (i14 != i15) {
                        break;
                    }
                } else {
                    i13++;
                }
            }
            if (roVarFm == null && iFm > 0) {
                roVarFm = fm(this.yz, i13);
            }
            if (roVarFm != null) {
                int i16 = i13 - 1;
                ro roVar2 = i16 >= 0 ? this.wsy.get(i16) : null;
                int clientWidth = getClientWidth();
                float paddingLeft = clientWidth <= 0 ? 0.0f : (getPaddingLeft() / clientWidth) + (2.0f - roVarFm.yz);
                float f10 = 0.0f;
                for (int i17 = this.yz - 1; i17 >= 0; i17--) {
                    if (f10 >= paddingLeft && i17 < iMax) {
                        if (roVar2 == null) {
                            break;
                        }
                        if (i17 == roVar2.ro && !roVar2.f6399lb) {
                            this.wsy.remove(i16);
                            this.f6395lb.fm((ViewGroup) this, i17, roVar2.fm);
                            i16--;
                            i13--;
                            if (i16 >= 0) {
                                roVar = this.wsy.get(i16);
                            }
                            roVar2 = roVar;
                        }
                    } else if (roVar2 != null && i17 == roVar2.ro) {
                        f10 += roVar2.yz;
                        i16--;
                        if (i16 >= 0) {
                            roVar = this.wsy.get(i16);
                        }
                        roVar2 = roVar;
                    } else {
                        f10 += fm(i17, i16 + 1).yz;
                        i13++;
                        roVar = i16 >= 0 ? this.wsy.get(i16) : null;
                        roVar2 = roVar;
                    }
                }
                float f11 = roVarFm.yz;
                int i18 = i13 + 1;
                if (f11 < 2.0f) {
                    ro roVar3 = i18 < this.wsy.size() ? this.wsy.get(i18) : null;
                    float paddingRight = clientWidth <= 0 ? 0.0f : (getPaddingRight() / clientWidth) + 2.0f;
                    int i19 = this.yz;
                    while (true) {
                        i19++;
                        if (i19 >= iFm) {
                            break;
                        }
                        if (f11 >= paddingRight && i19 > iMin) {
                            if (roVar3 == null) {
                                break;
                            }
                            if (i19 == roVar3.ro && !roVar3.f6399lb) {
                                this.wsy.remove(i18);
                                this.f6395lb.fm((ViewGroup) this, i19, roVar3.fm);
                                if (i18 < this.wsy.size()) {
                                    roVar3 = this.wsy.get(i18);
                                }
                            }
                        } else if (roVar3 != null && i19 == roVar3.ro) {
                            f11 += roVar3.yz;
                            i18++;
                            if (i18 < this.wsy.size()) {
                                roVar3 = this.wsy.get(i18);
                            }
                        } else {
                            ro roVarFm3 = fm(i19, i18);
                            i18++;
                            f11 += roVarFm3.yz;
                            roVar3 = i18 < this.wsy.size() ? this.wsy.get(i18) : null;
                        }
                    }
                }
                fm(roVarFm, i13, roVarRo);
            }
            int childCount = getChildCount();
            for (int i20 = 0; i20 < childCount; i20++) {
                View childAt = getChildAt(i20);
                C0021lb c0021lb = (C0021lb) childAt.getLayoutParams();
                c0021lb.ajl = i20;
                if (!c0021lb.fm && c0021lb.f6398lb == 0.0f && (roVarFm2 = fm(childAt)) != null) {
                    c0021lb.f6398lb = roVarFm2.yz;
                    c0021lb.jnr = roVarFm2.ro;
                }
            }
            wsy();
            if (hasFocus()) {
                View viewFindFocus = findFocus();
                ro roVarRo2 = viewFindFocus != null ? ro(viewFindFocus) : null;
                if (roVarRo2 == null || roVarRo2.ro != this.yz) {
                    for (int i21 = 0; i21 < getChildCount(); i21++) {
                        View childAt2 = getChildAt(i21);
                        ro roVarFm4 = fm(childAt2);
                        if (roVarFm4 != null && roVarFm4.ro == this.yz && childAt2.requestFocus(2)) {
                            return;
                        }
                    }
                    return;
                }
                return;
            }
            return;
        }
        try {
            hexString = getResources().getResourceName(getId());
        } catch (Resources.NotFoundException unused) {
            hexString = Integer.toHexString(getId());
        }
        throw new IllegalStateException("The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: " + this.fm + ", found: " + iFm + " Pager id: " + hexString + " Pager class: " + getClass() + " Problematic adapter: " + this.f6395lb.getClass());
    }

    private void fm(ro roVar, int i10, ro roVar2) {
        int i11;
        int i12;
        ro roVar3;
        ro roVar4;
        int iFm = this.f6395lb.fm();
        int clientWidth = getClientWidth();
        float f10 = clientWidth > 0 ? this.irt / clientWidth : 0.0f;
        if (roVar2 != null) {
            int i13 = roVar2.ro;
            int i14 = roVar.ro;
            if (i13 < i14) {
                float fFm = roVar2.jnr + roVar2.yz + f10;
                int i15 = i13 + 1;
                int i16 = 0;
                while (i15 <= roVar.ro && i16 < this.wsy.size()) {
                    ro roVar5 = this.wsy.get(i16);
                    while (true) {
                        roVar4 = roVar5;
                        if (i15 <= roVar4.ro || i16 >= this.wsy.size() - 1) {
                            break;
                        }
                        i16++;
                        roVar5 = this.wsy.get(i16);
                    }
                    while (i15 < roVar4.ro) {
                        fFm += this.f6395lb.fm(i15) + f10;
                        i15++;
                    }
                    roVar4.jnr = fFm;
                    fFm += roVar4.yz + f10;
                    i15++;
                }
            } else if (i13 > i14) {
                int size = this.wsy.size() - 1;
                float fFm2 = roVar2.jnr;
                while (true) {
                    i13--;
                    if (i13 < roVar.ro || size < 0) {
                        break;
                    }
                    ro roVar6 = this.wsy.get(size);
                    while (true) {
                        roVar3 = roVar6;
                        if (i13 >= roVar3.ro || size <= 0) {
                            break;
                        }
                        size--;
                        roVar6 = this.wsy.get(size);
                    }
                    while (i13 > roVar3.ro) {
                        fFm2 -= this.f6395lb.fm(i13) + f10;
                        i13--;
                    }
                    fFm2 -= roVar3.yz + f10;
                    roVar3.jnr = fFm2;
                }
            }
        }
        int size2 = this.wsy.size();
        float fFm3 = roVar.jnr;
        int i17 = roVar.ro;
        int i18 = i17 - 1;
        this.wey = i17 == 0 ? fFm3 : -3.4028235E38f;
        int i19 = iFm - 1;
        this.sds = i17 == i19 ? (roVar.yz + fFm3) - 1.0f : Float.MAX_VALUE;
        int i20 = i10 - 1;
        while (i20 >= 0) {
            ro roVar7 = this.wsy.get(i20);
            while (true) {
                i12 = roVar7.ro;
                if (i18 <= i12) {
                    break;
                }
                fFm3 -= this.f6395lb.fm(i18) + f10;
                i18--;
            }
            fFm3 -= roVar7.yz + f10;
            roVar7.jnr = fFm3;
            if (i12 == 0) {
                this.wey = fFm3;
            }
            i20--;
            i18--;
        }
        float fFm4 = roVar.jnr + roVar.yz + f10;
        int i21 = roVar.ro + 1;
        int i22 = i10 + 1;
        while (i22 < size2) {
            ro roVar8 = this.wsy.get(i22);
            while (true) {
                i11 = roVar8.ro;
                if (i21 >= i11) {
                    break;
                }
                fFm4 += this.f6395lb.fm(i21) + f10;
                i21++;
            }
            if (i11 == i19) {
                this.sds = (roVar8.yz + fFm4) - 1.0f;
            }
            roVar8.jnr = fFm4;
            fFm4 += roVar8.yz + f10;
            i22++;
            i21++;
        }
        this.bkb = false;
    }

    public ro fm(View view) {
        for (int i10 = 0; i10 < this.wsy.size(); i10++) {
            ro roVar = this.wsy.get(i10);
            if (this.f6395lb.fm(view, roVar.fm)) {
                return roVar;
            }
        }
        return null;
    }

    private void fm(int i10, int i11, int i12, int i13) {
        if (i11 > 0 && !this.wsy.isEmpty()) {
            if (!this.dsz.isFinished()) {
                this.dsz.setFinalX(getCurrentItem() * getClientWidth());
                return;
            } else {
                scrollTo((int) ((getScrollX() / (((i11 - getPaddingLeft()) - getPaddingRight()) + i13)) * (((i10 - getPaddingLeft()) - getPaddingRight()) + i12)), getScrollY());
                return;
            }
        }
        ro roVarRo = ro(this.yz);
        int iMin = (int) ((roVarRo != null ? Math.min(roVarRo.jnr, this.sds) : 0.0f) * ((i10 - getPaddingLeft()) - getPaddingRight()));
        if (iMin != getScrollX()) {
            fm(false);
            scrollTo(iMin, getScrollY());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0064  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void fm(int i10, float f10, int i11) {
        int iMax;
        int width;
        int left;
        if (this.mpp > 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);
                C0021lb c0021lb = (C0021lb) childAt.getLayoutParams();
                if (c0021lb.fm) {
                    int i13 = c0021lb.ro & 7;
                    if (i13 == 1) {
                        iMax = Math.max((width2 - childAt.getMeasuredWidth()) / 2, paddingLeft);
                    } else {
                        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;
                    }
                    int i14 = iMax;
                    width = paddingLeft;
                    paddingLeft = i14;
                    left = (paddingLeft + scrollX) - childAt.getLeft();
                    if (left != 0) {
                    }
                    paddingLeft = width;
                }
            }
        }
        ro(i10, f10, i11);
        if (this.ywr != null) {
            int scrollX2 = getScrollX();
            int childCount2 = getChildCount();
            for (int i15 = 0; i15 < childCount2; i15++) {
                View childAt2 = getChildAt(i15);
                if (!((C0021lb) childAt2.getLayoutParams()).fm) {
                    this.ywr.fm(childAt2, (childAt2.getLeft() - scrollX2) / getClientWidth());
                }
            }
        }
        this.lmk = true;
    }

    private void fm(boolean z10) {
        boolean z11 = this.jm == 2;
        if (z11) {
            setScrollingCacheEnabled(false);
            if (!this.dsz.isFinished()) {
                this.dsz.abortAnimation();
                int scrollX = getScrollX();
                int scrollY = getScrollY();
                int currX = this.dsz.getCurrX();
                int currY = this.dsz.getCurrY();
                if (scrollX != currX || scrollY != currY) {
                    scrollTo(currX, currY);
                    if (currX != scrollX) {
                        yz(currX);
                    }
                }
            }
        }
        this.nt = false;
        for (int i10 = 0; i10 < this.wsy.size(); i10++) {
            ro roVar = this.wsy.get(i10);
            if (roVar.f6399lb) {
                roVar.f6399lb = false;
                z11 = true;
            }
        }
        if (z11) {
            if (z10) {
                postOnAnimation(this.pbk);
            } else {
                this.pbk.run();
            }
        }
    }

    private boolean fm(float f10, float f11) {
        if (f10 >= this.wbw || f11 <= 0.0f) {
            return f10 > ((float) (getWidth() - this.wbw)) && f11 < 0.0f;
        }
        return true;
    }

    private int fm(int i10, float f10, int i11, int i12) {
        if (Math.abs(i12) <= this.lz || Math.abs(i11) <= this.zan) {
            i10 += (int) (f10 + (i10 >= this.yz ? 0.4f : 0.6f));
        } else if (i11 <= 0) {
            i10++;
        }
        if (this.wsy.size() > 0) {
            return Math.max(this.wsy.get(0).ro, Math.min(i10, ((ro) u1.e(this.wsy, 1)).ro));
        }
        return i10;
    }

    private void fm(MotionEvent motionEvent) {
        int actionIndex = motionEvent.getActionIndex();
        if (motionEvent.getPointerId(actionIndex) == this.mon) {
            int i10 = actionIndex == 0 ? 1 : 0;
            this.pkk = motionEvent.getX(i10);
            this.mon = motionEvent.getPointerId(i10);
            VelocityTracker velocityTracker = this.bx;
            if (velocityTracker != null) {
                velocityTracker.clear();
            }
        }
    }

    public boolean fm(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() && fm(childAt, true, i10, i14 - childAt.getLeft(), i13 - childAt.getTop())) {
                    return true;
                }
            }
        }
        return z10 && view.canScrollHorizontally(-i10);
    }

    public boolean fm(KeyEvent keyEvent) {
        if (keyEvent.getAction() == 0) {
            int keyCode = keyEvent.getKeyCode();
            if (keyCode == 21) {
                if (keyEvent.hasModifiers(2)) {
                    return yz();
                }
                return lb(17);
            }
            if (keyCode == 22) {
                if (keyEvent.hasModifiers(2)) {
                    return jnr();
                }
                return lb(66);
            }
            if (keyCode == 61) {
                if (keyEvent.hasNoModifiers()) {
                    return lb(2);
                }
                if (keyEvent.hasModifiers(1)) {
                    return lb(1);
                }
            }
        }
        return false;
    }

    private Rect fm(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;
    }
}
