package com.google.android.material.appbar;

import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.c0;
import androidx.core.view.h0;
import androidx.core.view.h1;
import androidx.core.view.s0;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.material.internal.o;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import t3.h;
import t3.k;
import vi.k;
import vi.l;

/* loaded from: classes3.dex */
public class AppBarLayout extends LinearLayout implements CoordinatorLayout.b {
    private static final int I = k.f39893h;
    private boolean A;
    private int B;
    private WeakReference C;
    private ValueAnimator D;
    private final List E;
    private int[] F;
    private Drawable G;
    private Behavior H;

    /* renamed from: p, reason: collision with root package name */
    private int f12774p;

    /* renamed from: q, reason: collision with root package name */
    private int f12775q;

    /* renamed from: r, reason: collision with root package name */
    private int f12776r;

    /* renamed from: s, reason: collision with root package name */
    private int f12777s;

    /* renamed from: t, reason: collision with root package name */
    private boolean f12778t;

    /* renamed from: u, reason: collision with root package name */
    private int f12779u;

    /* renamed from: v, reason: collision with root package name */
    private h1 f12780v;

    /* renamed from: w, reason: collision with root package name */
    private List f12781w;

    /* renamed from: x, reason: collision with root package name */
    private boolean f12782x;

    /* renamed from: y, reason: collision with root package name */
    private boolean f12783y;

    /* renamed from: z, reason: collision with root package name */
    private boolean f12784z;

    /* JADX INFO: Access modifiers changed from: protected */
    /* loaded from: classes3.dex */
    public static class BaseBehavior<T extends AppBarLayout> extends com.google.android.material.appbar.a {

        /* renamed from: k, reason: collision with root package name */
        private int f12785k;

        /* renamed from: l, reason: collision with root package name */
        private int f12786l;

        /* renamed from: m, reason: collision with root package name */
        private ValueAnimator f12787m;

        /* renamed from: n, reason: collision with root package name */
        private e f12788n;

        /* renamed from: o, reason: collision with root package name */
        private WeakReference f12789o;

        /* renamed from: p, reason: collision with root package name */
        private boolean f12790p;

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes3.dex */
        public class a implements ValueAnimator.AnimatorUpdateListener {

            /* renamed from: a, reason: collision with root package name */
            final /* synthetic */ CoordinatorLayout f12791a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ AppBarLayout f12792b;

            a(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
                this.f12791a = coordinatorLayout;
                this.f12792b = appBarLayout;
            }

            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                BaseBehavior.this.P(this.f12791a, this.f12792b, ((Integer) valueAnimator.getAnimatedValue()).intValue());
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes3.dex */
        public class b extends androidx.core.view.a {
            b() {
            }

            @Override // androidx.core.view.a
            public void g(View view, h hVar) {
                super.g(view, hVar);
                hVar.H0(BaseBehavior.this.f12790p);
                hVar.g0(ScrollView.class.getName());
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes3.dex */
        public class c implements t3.k {

            /* renamed from: a, reason: collision with root package name */
            final /* synthetic */ CoordinatorLayout f12795a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ AppBarLayout f12796b;

            /* renamed from: c, reason: collision with root package name */
            final /* synthetic */ View f12797c;

            /* renamed from: d, reason: collision with root package name */
            final /* synthetic */ int f12798d;

            c(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10) {
                this.f12795a = coordinatorLayout;
                this.f12796b = appBarLayout;
                this.f12797c = view;
                this.f12798d = i10;
            }

            @Override // t3.k
            public boolean a(View view, k.a aVar) {
                BaseBehavior.this.q(this.f12795a, this.f12796b, this.f12797c, 0, this.f12798d, new int[]{0, 0}, 1);
                return true;
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes3.dex */
        public class d implements t3.k {

            /* renamed from: a, reason: collision with root package name */
            final /* synthetic */ AppBarLayout f12800a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ boolean f12801b;

            d(AppBarLayout appBarLayout, boolean z10) {
                this.f12800a = appBarLayout;
                this.f12801b = z10;
            }

            @Override // t3.k
            public boolean a(View view, k.a aVar) {
                this.f12800a.setExpanded(this.f12801b);
                return true;
            }
        }

        public BaseBehavior() {
        }

        private boolean T(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view) {
            boolean z10 = false;
            if (M() != (-appBarLayout.getTotalScrollRange())) {
                U(coordinatorLayout, appBarLayout, h.a.f36142q, false);
                z10 = true;
            }
            if (M() != 0) {
                if (!view.canScrollVertically(-1)) {
                    U(coordinatorLayout, appBarLayout, h.a.f36143r, true);
                    return true;
                }
                int i10 = -appBarLayout.getDownNestedPreScrollRange();
                if (i10 != 0) {
                    s0.i0(coordinatorLayout, h.a.f36143r, null, new c(coordinatorLayout, appBarLayout, view, i10));
                    return true;
                }
            }
            return z10;
        }

        private void U(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, h.a aVar, boolean z10) {
            s0.i0(coordinatorLayout, aVar, null, new d(appBarLayout, z10));
        }

        private void V(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, float f10) {
            int abs = Math.abs(M() - i10);
            float abs2 = Math.abs(f10);
            W(coordinatorLayout, appBarLayout, i10, abs2 > BitmapDescriptorFactory.HUE_RED ? Math.round((abs / abs2) * 1000.0f) * 3 : (int) (((abs / appBarLayout.getHeight()) + 1.0f) * 150.0f));
        }

        private void W(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, int i11) {
            int M = M();
            if (M == i10) {
                ValueAnimator valueAnimator = this.f12787m;
                if (valueAnimator == null || !valueAnimator.isRunning()) {
                    return;
                }
                this.f12787m.cancel();
                return;
            }
            ValueAnimator valueAnimator2 = this.f12787m;
            if (valueAnimator2 == null) {
                ValueAnimator valueAnimator3 = new ValueAnimator();
                this.f12787m = valueAnimator3;
                valueAnimator3.setInterpolator(wi.a.f49481e);
                this.f12787m.addUpdateListener(new a(coordinatorLayout, appBarLayout));
            } else {
                valueAnimator2.cancel();
            }
            this.f12787m.setDuration(Math.min(i11, 600));
            this.f12787m.setIntValues(M, i10);
            this.f12787m.start();
        }

        private int X(int i10, int i11, int i12) {
            return i10 < (i11 + i12) / 2 ? i11 : i12;
        }

        private boolean Z(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view) {
            return appBarLayout.l() && coordinatorLayout.getHeight() - view.getHeight() <= appBarLayout.getHeight();
        }

        private static boolean a0(int i10, int i11) {
            return (i10 & i11) == i11;
        }

        private boolean b0(AppBarLayout appBarLayout) {
            int childCount = appBarLayout.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                if (((f) appBarLayout.getChildAt(i10).getLayoutParams()).f12813a != 0) {
                    return true;
                }
            }
            return false;
        }

        private View c0(CoordinatorLayout coordinatorLayout) {
            int childCount = coordinatorLayout.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = coordinatorLayout.getChildAt(i10);
                if ((childAt instanceof c0) || (childAt instanceof ListView) || (childAt instanceof ScrollView)) {
                    return childAt;
                }
            }
            return null;
        }

        private static View d0(AppBarLayout appBarLayout, int i10) {
            int abs = Math.abs(i10);
            int childCount = appBarLayout.getChildCount();
            for (int i11 = 0; i11 < childCount; i11++) {
                View childAt = appBarLayout.getChildAt(i11);
                if (abs >= childAt.getTop() && abs <= childAt.getBottom()) {
                    return childAt;
                }
            }
            return null;
        }

        private int e0(AppBarLayout appBarLayout, int i10) {
            int childCount = appBarLayout.getChildCount();
            for (int i11 = 0; i11 < childCount; i11++) {
                View childAt = appBarLayout.getChildAt(i11);
                int top = childAt.getTop();
                int bottom = childAt.getBottom();
                f fVar = (f) childAt.getLayoutParams();
                if (a0(fVar.c(), 32)) {
                    top -= ((LinearLayout.LayoutParams) fVar).topMargin;
                    bottom += ((LinearLayout.LayoutParams) fVar).bottomMargin;
                }
                int i12 = -i10;
                if (top <= i12 && bottom >= i12) {
                    return i11;
                }
            }
            return -1;
        }

        private View f0(CoordinatorLayout coordinatorLayout) {
            int childCount = coordinatorLayout.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = coordinatorLayout.getChildAt(i10);
                if (((CoordinatorLayout.f) childAt.getLayoutParams()).f() instanceof ScrollingViewBehavior) {
                    return childAt;
                }
            }
            return null;
        }

        private int i0(AppBarLayout appBarLayout, int i10) {
            int abs = Math.abs(i10);
            int childCount = appBarLayout.getChildCount();
            int i11 = 0;
            int i12 = 0;
            while (true) {
                if (i12 >= childCount) {
                    break;
                }
                View childAt = appBarLayout.getChildAt(i12);
                f fVar = (f) childAt.getLayoutParams();
                Interpolator d10 = fVar.d();
                if (abs < childAt.getTop() || abs > childAt.getBottom()) {
                    i12++;
                } else if (d10 != null) {
                    int c10 = fVar.c();
                    if ((c10 & 1) != 0) {
                        i11 = 0 + childAt.getHeight() + ((LinearLayout.LayoutParams) fVar).topMargin + ((LinearLayout.LayoutParams) fVar).bottomMargin;
                        if ((c10 & 2) != 0) {
                            i11 -= s0.A(childAt);
                        }
                    }
                    if (s0.w(childAt)) {
                        i11 -= appBarLayout.getTopInset();
                    }
                    if (i11 > 0) {
                        float f10 = i11;
                        return Integer.signum(i10) * (childAt.getTop() + Math.round(f10 * d10.getInterpolation((abs - childAt.getTop()) / f10)));
                    }
                }
            }
            return i10;
        }

        private boolean v0(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            List s10 = coordinatorLayout.s(appBarLayout);
            int size = s10.size();
            for (int i10 = 0; i10 < size; i10++) {
                CoordinatorLayout.c f10 = ((CoordinatorLayout.f) ((View) s10.get(i10)).getLayoutParams()).f();
                if (f10 instanceof ScrollingViewBehavior) {
                    return ((ScrollingViewBehavior) f10).K() != 0;
                }
            }
            return false;
        }

        private void w0(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            int topInset = appBarLayout.getTopInset() + appBarLayout.getPaddingTop();
            int M = M() - topInset;
            int e02 = e0(appBarLayout, M);
            if (e02 >= 0) {
                View childAt = appBarLayout.getChildAt(e02);
                f fVar = (f) childAt.getLayoutParams();
                int c10 = fVar.c();
                if ((c10 & 17) == 17) {
                    int i10 = -childAt.getTop();
                    int i11 = -childAt.getBottom();
                    if (e02 == 0 && s0.w(appBarLayout) && s0.w(childAt)) {
                        i10 -= appBarLayout.getTopInset();
                    }
                    if (a0(c10, 2)) {
                        i11 += s0.A(childAt);
                    } else if (a0(c10, 5)) {
                        int A = s0.A(childAt) + i11;
                        if (M < A) {
                            i10 = A;
                        } else {
                            i11 = A;
                        }
                    }
                    if (a0(c10, 32)) {
                        i10 += ((LinearLayout.LayoutParams) fVar).topMargin;
                        i11 -= ((LinearLayout.LayoutParams) fVar).bottomMargin;
                    }
                    V(coordinatorLayout, appBarLayout, o3.a.b(X(M, i11, i10) + topInset, -appBarLayout.getTotalScrollRange(), 0), BitmapDescriptorFactory.HUE_RED);
                }
            }
        }

        private void x0(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            View f02;
            s0.g0(coordinatorLayout, h.a.f36142q.b());
            s0.g0(coordinatorLayout, h.a.f36143r.b());
            if (appBarLayout.getTotalScrollRange() == 0 || (f02 = f0(coordinatorLayout)) == null || !b0(appBarLayout)) {
                return;
            }
            if (!s0.K(coordinatorLayout)) {
                s0.m0(coordinatorLayout, new b());
            }
            this.f12790p = T(coordinatorLayout, appBarLayout, f02);
        }

        private void y0(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, int i11, boolean z10) {
            View d02 = d0(appBarLayout, i10);
            boolean z11 = false;
            if (d02 != null) {
                int c10 = ((f) d02.getLayoutParams()).c();
                if ((c10 & 1) != 0) {
                    int A = s0.A(d02);
                    if (i11 <= 0 || (c10 & 12) == 0 ? !((c10 & 2) == 0 || (-i10) < (d02.getBottom() - A) - appBarLayout.getTopInset()) : (-i10) >= (d02.getBottom() - A) - appBarLayout.getTopInset()) {
                        z11 = true;
                    }
                }
            }
            if (appBarLayout.n()) {
                z11 = appBarLayout.z(c0(coordinatorLayout));
            }
            boolean w10 = appBarLayout.w(z11);
            if (z10 || (w10 && v0(coordinatorLayout, appBarLayout))) {
                appBarLayout.jumpDrawablesToCurrentState();
            }
        }

        @Override // com.google.android.material.appbar.a
        int M() {
            return E() + this.f12785k;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.android.material.appbar.a
        /* renamed from: Y, reason: merged with bridge method [inline-methods] */
        public boolean H(AppBarLayout appBarLayout) {
            WeakReference weakReference = this.f12789o;
            if (weakReference == null) {
                return true;
            }
            View view = (View) weakReference.get();
            return (view == null || !view.isShown() || view.canScrollVertically(-1)) ? false : true;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.android.material.appbar.a
        /* renamed from: g0, reason: merged with bridge method [inline-methods] */
        public int K(AppBarLayout appBarLayout) {
            return -appBarLayout.getDownNestedScrollRange();
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.android.material.appbar.a
        /* renamed from: h0, reason: merged with bridge method [inline-methods] */
        public int L(AppBarLayout appBarLayout) {
            return appBarLayout.getTotalScrollRange();
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.android.material.appbar.a
        /* renamed from: j0, reason: merged with bridge method [inline-methods] */
        public void N(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            w0(coordinatorLayout, appBarLayout);
            if (appBarLayout.n()) {
                appBarLayout.w(appBarLayout.z(c0(coordinatorLayout)));
            }
        }

        @Override // com.google.android.material.appbar.c, androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: k0, reason: merged with bridge method [inline-methods] */
        public boolean l(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10) {
            boolean l10 = super.l(coordinatorLayout, appBarLayout, i10);
            int pendingAction = appBarLayout.getPendingAction();
            e eVar = this.f12788n;
            if (eVar == null || (pendingAction & 8) != 0) {
                if (pendingAction != 0) {
                    boolean z10 = (pendingAction & 4) != 0;
                    if ((pendingAction & 2) != 0) {
                        int i11 = -appBarLayout.getUpNestedPreScrollRange();
                        if (z10) {
                            V(coordinatorLayout, appBarLayout, i11, BitmapDescriptorFactory.HUE_RED);
                        } else {
                            P(coordinatorLayout, appBarLayout, i11);
                        }
                    } else if ((pendingAction & 1) != 0) {
                        if (z10) {
                            V(coordinatorLayout, appBarLayout, 0, BitmapDescriptorFactory.HUE_RED);
                        } else {
                            P(coordinatorLayout, appBarLayout, 0);
                        }
                    }
                }
            } else if (eVar.f12803r) {
                P(coordinatorLayout, appBarLayout, -appBarLayout.getTotalScrollRange());
            } else if (eVar.f12804s) {
                P(coordinatorLayout, appBarLayout, 0);
            } else {
                View childAt = appBarLayout.getChildAt(eVar.f12805t);
                P(coordinatorLayout, appBarLayout, (-childAt.getBottom()) + (this.f12788n.f12807v ? s0.A(childAt) + appBarLayout.getTopInset() : Math.round(childAt.getHeight() * this.f12788n.f12806u)));
            }
            appBarLayout.s();
            this.f12788n = null;
            G(o3.a.b(E(), -appBarLayout.getTotalScrollRange(), 0));
            y0(coordinatorLayout, appBarLayout, E(), 0, true);
            appBarLayout.o(E());
            x0(coordinatorLayout, appBarLayout);
            return l10;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: l0, reason: merged with bridge method [inline-methods] */
        public boolean m(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, int i11, int i12, int i13) {
            if (((ViewGroup.MarginLayoutParams) ((CoordinatorLayout.f) appBarLayout.getLayoutParams())).height != -2) {
                return super.m(coordinatorLayout, appBarLayout, i10, i11, i12, i13);
            }
            coordinatorLayout.J(appBarLayout, i10, i11, View.MeasureSpec.makeMeasureSpec(0, 0), i13);
            return true;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: m0, reason: merged with bridge method [inline-methods] */
        public void q(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10, int i11, int[] iArr, int i12) {
            int i13;
            int i14;
            if (i11 != 0) {
                if (i11 < 0) {
                    i13 = -appBarLayout.getTotalScrollRange();
                    i14 = appBarLayout.getDownNestedPreScrollRange() + i13;
                } else {
                    i13 = -appBarLayout.getUpNestedPreScrollRange();
                    i14 = 0;
                }
                int i15 = i13;
                int i16 = i14;
                if (i15 != i16) {
                    iArr[1] = O(coordinatorLayout, appBarLayout, i11, i15, i16);
                }
            }
            if (appBarLayout.n()) {
                appBarLayout.w(appBarLayout.z(view));
            }
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: n0, reason: merged with bridge method [inline-methods] */
        public void t(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10, int i11, int i12, int i13, int i14, int[] iArr) {
            if (i13 < 0) {
                iArr[1] = O(coordinatorLayout, appBarLayout, i13, -appBarLayout.getDownNestedScrollRange(), 0);
            }
            if (i13 == 0) {
                x0(coordinatorLayout, appBarLayout);
            }
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: o0, reason: merged with bridge method [inline-methods] */
        public void x(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, Parcelable parcelable) {
            if (parcelable instanceof e) {
                s0((e) parcelable, true);
                super.x(coordinatorLayout, appBarLayout, this.f12788n.a());
            } else {
                super.x(coordinatorLayout, appBarLayout, parcelable);
                this.f12788n = null;
            }
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: p0, reason: merged with bridge method [inline-methods] */
        public Parcelable y(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            Parcelable y10 = super.y(coordinatorLayout, appBarLayout);
            e t02 = t0(y10, appBarLayout);
            return t02 == null ? y10 : t02;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: q0, reason: merged with bridge method [inline-methods] */
        public boolean A(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, View view2, int i10, int i11) {
            ValueAnimator valueAnimator;
            boolean z10 = (i10 & 2) != 0 && (appBarLayout.n() || Z(coordinatorLayout, appBarLayout, view));
            if (z10 && (valueAnimator = this.f12787m) != null) {
                valueAnimator.cancel();
            }
            this.f12789o = null;
            this.f12786l = i11;
            return z10;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        /* renamed from: r0, reason: merged with bridge method [inline-methods] */
        public void C(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10) {
            if (this.f12786l == 0 || i10 == 1) {
                w0(coordinatorLayout, appBarLayout);
                if (appBarLayout.n()) {
                    appBarLayout.w(appBarLayout.z(view));
                }
            }
            this.f12789o = new WeakReference(view);
        }

        void s0(e eVar, boolean z10) {
            if (this.f12788n == null || z10) {
                this.f12788n = eVar;
            }
        }

        e t0(Parcelable parcelable, AppBarLayout appBarLayout) {
            int E = E();
            int childCount = appBarLayout.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = appBarLayout.getChildAt(i10);
                int bottom = childAt.getBottom() + E;
                if (childAt.getTop() + E <= 0 && bottom >= 0) {
                    if (parcelable == null) {
                        parcelable = z3.a.f53152q;
                    }
                    e eVar = new e(parcelable);
                    boolean z10 = E == 0;
                    eVar.f12804s = z10;
                    eVar.f12803r = !z10 && (-E) >= appBarLayout.getTotalScrollRange();
                    eVar.f12805t = i10;
                    eVar.f12807v = bottom == s0.A(childAt) + appBarLayout.getTopInset();
                    eVar.f12806u = bottom / childAt.getHeight();
                    return eVar;
                }
            }
            return null;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.android.material.appbar.a
        /* renamed from: u0, reason: merged with bridge method [inline-methods] */
        public int Q(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, int i11, int i12) {
            int M = M();
            int i13 = 0;
            if (i11 == 0 || M < i11 || M > i12) {
                this.f12785k = 0;
            } else {
                int b10 = o3.a.b(i10, i11, i12);
                if (M != b10) {
                    int i02 = appBarLayout.j() ? i0(appBarLayout, b10) : b10;
                    boolean G = G(i02);
                    int i14 = M - b10;
                    this.f12785k = b10 - i02;
                    if (G) {
                        while (i13 < appBarLayout.getChildCount()) {
                            f fVar = (f) appBarLayout.getChildAt(i13).getLayoutParams();
                            d b11 = fVar.b();
                            if (b11 != null && (fVar.c() & 1) != 0) {
                                b11.a(appBarLayout, appBarLayout.getChildAt(i13), E());
                            }
                            i13++;
                        }
                    }
                    if (!G && appBarLayout.j()) {
                        coordinatorLayout.g(appBarLayout);
                    }
                    appBarLayout.o(E());
                    y0(coordinatorLayout, appBarLayout, b10, b10 < M ? -1 : 1, false);
                    i13 = i14;
                }
            }
            x0(coordinatorLayout, appBarLayout);
            return i13;
        }

        public BaseBehavior(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        /* JADX INFO: Access modifiers changed from: protected */
        /* loaded from: classes3.dex */
        public static class e extends z3.a {
            public static final Parcelable.Creator<e> CREATOR = new a();

            /* renamed from: r, reason: collision with root package name */
            boolean f12803r;

            /* renamed from: s, reason: collision with root package name */
            boolean f12804s;

            /* renamed from: t, reason: collision with root package name */
            int f12805t;

            /* renamed from: u, reason: collision with root package name */
            float f12806u;

            /* renamed from: v, reason: collision with root package name */
            boolean f12807v;

            /* loaded from: classes3.dex */
            class a implements Parcelable.ClassLoaderCreator {
                a() {
                }

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

                @Override // android.os.Parcelable.ClassLoaderCreator
                /* renamed from: b, reason: merged with bridge method [inline-methods] */
                public e createFromParcel(Parcel parcel, ClassLoader classLoader) {
                    return new e(parcel, classLoader);
                }

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

            public e(Parcel parcel, ClassLoader classLoader) {
                super(parcel, classLoader);
                this.f12803r = parcel.readByte() != 0;
                this.f12804s = parcel.readByte() != 0;
                this.f12805t = parcel.readInt();
                this.f12806u = parcel.readFloat();
                this.f12807v = parcel.readByte() != 0;
            }

            @Override // z3.a, android.os.Parcelable
            public void writeToParcel(Parcel parcel, int i10) {
                super.writeToParcel(parcel, i10);
                parcel.writeByte(this.f12803r ? (byte) 1 : (byte) 0);
                parcel.writeByte(this.f12804s ? (byte) 1 : (byte) 0);
                parcel.writeInt(this.f12805t);
                parcel.writeFloat(this.f12806u);
                parcel.writeByte(this.f12807v ? (byte) 1 : (byte) 0);
            }

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

    /* loaded from: classes3.dex */
    public static class Behavior extends BaseBehavior<AppBarLayout> {
        public Behavior() {
        }

        @Override // com.google.android.material.appbar.a, androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ boolean D(CoordinatorLayout coordinatorLayout, View view, MotionEvent motionEvent) {
            return super.D(coordinatorLayout, view, motionEvent);
        }

        @Override // com.google.android.material.appbar.c
        public /* bridge */ /* synthetic */ int E() {
            return super.E();
        }

        @Override // com.google.android.material.appbar.c
        public /* bridge */ /* synthetic */ boolean G(int i10) {
            return super.G(i10);
        }

        @Override // com.google.android.material.appbar.a, androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ boolean k(CoordinatorLayout coordinatorLayout, View view, MotionEvent motionEvent) {
            return super.k(coordinatorLayout, view, motionEvent);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: k0 */
        public /* bridge */ /* synthetic */ boolean l(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10) {
            return super.l(coordinatorLayout, appBarLayout, i10);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: l0 */
        public /* bridge */ /* synthetic */ boolean m(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, int i11, int i12, int i13) {
            return super.m(coordinatorLayout, appBarLayout, i10, i11, i12, i13);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: m0 */
        public /* bridge */ /* synthetic */ void q(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10, int i11, int[] iArr, int i12) {
            super.q(coordinatorLayout, appBarLayout, view, i10, i11, iArr, i12);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: n0 */
        public /* bridge */ /* synthetic */ void t(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10, int i11, int i12, int i13, int i14, int[] iArr) {
            super.t(coordinatorLayout, appBarLayout, view, i10, i11, i12, i13, i14, iArr);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: o0 */
        public /* bridge */ /* synthetic */ void x(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, Parcelable parcelable) {
            super.x(coordinatorLayout, appBarLayout, parcelable);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: p0 */
        public /* bridge */ /* synthetic */ Parcelable y(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            return super.y(coordinatorLayout, appBarLayout);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: q0 */
        public /* bridge */ /* synthetic */ boolean A(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, View view2, int i10, int i11) {
            return super.A(coordinatorLayout, appBarLayout, view, view2, i10, i11);
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        /* renamed from: r0 */
        public /* bridge */ /* synthetic */ void C(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10) {
            super.C(coordinatorLayout, appBarLayout, view, i10);
        }

        public Behavior(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }
    }

    /* loaded from: classes3.dex */
    public static class ScrollingViewBehavior extends com.google.android.material.appbar.b {
        public ScrollingViewBehavior() {
        }

        private static int R(AppBarLayout appBarLayout) {
            CoordinatorLayout.c f10 = ((CoordinatorLayout.f) appBarLayout.getLayoutParams()).f();
            if (f10 instanceof BaseBehavior) {
                return ((BaseBehavior) f10).M();
            }
            return 0;
        }

        private void S(View view, View view2) {
            CoordinatorLayout.c f10 = ((CoordinatorLayout.f) view2.getLayoutParams()).f();
            if (f10 instanceof BaseBehavior) {
                s0.X(view, (((view2.getBottom() - view.getTop()) + ((BaseBehavior) f10).f12785k) + M()) - I(view2));
            }
        }

        private void T(View view, View view2) {
            if (view2 instanceof AppBarLayout) {
                AppBarLayout appBarLayout = (AppBarLayout) view2;
                if (appBarLayout.n()) {
                    appBarLayout.w(appBarLayout.z(view));
                }
            }
        }

        @Override // com.google.android.material.appbar.b
        float J(View view) {
            int i10;
            if (view instanceof AppBarLayout) {
                AppBarLayout appBarLayout = (AppBarLayout) view;
                int totalScrollRange = appBarLayout.getTotalScrollRange();
                int downNestedPreScrollRange = appBarLayout.getDownNestedPreScrollRange();
                int R = R(appBarLayout);
                if ((downNestedPreScrollRange == 0 || totalScrollRange + R > downNestedPreScrollRange) && (i10 = totalScrollRange - downNestedPreScrollRange) != 0) {
                    return (R / i10) + 1.0f;
                }
            }
            return BitmapDescriptorFactory.HUE_RED;
        }

        @Override // com.google.android.material.appbar.b
        int L(View view) {
            return view instanceof AppBarLayout ? ((AppBarLayout) view).getTotalScrollRange() : super.L(view);
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.android.material.appbar.b
        /* renamed from: Q, reason: merged with bridge method [inline-methods] */
        public AppBarLayout H(List list) {
            int size = list.size();
            for (int i10 = 0; i10 < size; i10++) {
                View view = (View) list.get(i10);
                if (view instanceof AppBarLayout) {
                    return (AppBarLayout) view;
                }
            }
            return null;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean e(CoordinatorLayout coordinatorLayout, View view, View view2) {
            return view2 instanceof AppBarLayout;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean h(CoordinatorLayout coordinatorLayout, View view, View view2) {
            S(view, view2);
            T(view, view2);
            return false;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public void i(CoordinatorLayout coordinatorLayout, View view, View view2) {
            if (view2 instanceof AppBarLayout) {
                s0.g0(coordinatorLayout, h.a.f36142q.b());
                s0.g0(coordinatorLayout, h.a.f36143r.b());
                s0.m0(coordinatorLayout, null);
            }
        }

        @Override // com.google.android.material.appbar.c, androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ boolean l(CoordinatorLayout coordinatorLayout, View view, int i10) {
            return super.l(coordinatorLayout, view, i10);
        }

        @Override // com.google.android.material.appbar.b, androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ boolean m(CoordinatorLayout coordinatorLayout, View view, int i10, int i11, int i12, int i13) {
            return super.m(coordinatorLayout, view, i10, i11, i12, i13);
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean w(CoordinatorLayout coordinatorLayout, View view, Rect rect, boolean z10) {
            AppBarLayout H = H(coordinatorLayout.r(view));
            if (H != null) {
                rect.offset(view.getLeft(), view.getTop());
                Rect rect2 = this.f12849d;
                rect2.set(0, 0, coordinatorLayout.getWidth(), coordinatorLayout.getHeight());
                if (!rect2.contains(rect)) {
                    H.t(false, !z10);
                    return true;
                }
            }
            return false;
        }

        public ScrollingViewBehavior(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, l.E5);
            O(obtainStyledAttributes.getDimensionPixelSize(l.F5, 0));
            obtainStyledAttributes.recycle();
        }
    }

    /* loaded from: classes3.dex */
    class a implements h0 {
        a() {
        }

        @Override // androidx.core.view.h0
        public h1 a(View view, h1 h1Var) {
            return AppBarLayout.this.p(h1Var);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public class b implements ValueAnimator.AnimatorUpdateListener {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ lj.g f12809a;

        b(lj.g gVar) {
            this.f12809a = gVar;
        }

        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f12809a.V(floatValue);
            if (AppBarLayout.this.G instanceof lj.g) {
                ((lj.g) AppBarLayout.this.G).V(floatValue);
            }
            Iterator it = AppBarLayout.this.E.iterator();
            if (it.hasNext()) {
                android.support.v4.media.session.b.a(it.next());
                this.f12809a.z();
                throw null;
            }
        }
    }

    /* loaded from: classes3.dex */
    public interface c {
        void a(AppBarLayout appBarLayout, int i10);
    }

    /* loaded from: classes3.dex */
    public static abstract class d {
        public abstract void a(AppBarLayout appBarLayout, View view, float f10);
    }

    /* loaded from: classes3.dex */
    public static class e extends d {

        /* renamed from: a, reason: collision with root package name */
        private final Rect f12811a = new Rect();

        /* renamed from: b, reason: collision with root package name */
        private final Rect f12812b = new Rect();

        private static void b(Rect rect, AppBarLayout appBarLayout, View view) {
            view.getDrawingRect(rect);
            appBarLayout.offsetDescendantRectToMyCoords(view, rect);
            rect.offset(0, -appBarLayout.getTopInset());
        }

        @Override // com.google.android.material.appbar.AppBarLayout.d
        public void a(AppBarLayout appBarLayout, View view, float f10) {
            b(this.f12811a, appBarLayout, view);
            float abs = this.f12811a.top - Math.abs(f10);
            if (abs > BitmapDescriptorFactory.HUE_RED) {
                s0.t0(view, null);
                view.setTranslationY(BitmapDescriptorFactory.HUE_RED);
                return;
            }
            float a10 = 1.0f - o3.a.a(Math.abs(abs / this.f12811a.height()), BitmapDescriptorFactory.HUE_RED, 1.0f);
            float height = (-abs) - ((this.f12811a.height() * 0.3f) * (1.0f - (a10 * a10)));
            view.setTranslationY(height);
            view.getDrawingRect(this.f12812b);
            this.f12812b.offset(0, (int) (-height));
            s0.t0(view, this.f12812b);
        }
    }

    /* loaded from: classes3.dex */
    public interface g extends c {
    }

    public AppBarLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, vi.b.f39720b);
    }

    private boolean A() {
        if (getChildCount() <= 0) {
            return false;
        }
        View childAt = getChildAt(0);
        return (childAt.getVisibility() == 8 || s0.w(childAt)) ? false : true;
    }

    private void B(lj.g gVar, boolean z10) {
        float dimension = getResources().getDimension(vi.d.f39756a);
        float f10 = z10 ? 0.0f : dimension;
        if (!z10) {
            dimension = 0.0f;
        }
        ValueAnimator valueAnimator = this.D;
        if (valueAnimator != null) {
            valueAnimator.cancel();
        }
        ValueAnimator ofFloat = ValueAnimator.ofFloat(f10, dimension);
        this.D = ofFloat;
        ofFloat.setDuration(getResources().getInteger(vi.g.f39830a));
        this.D.setInterpolator(wi.a.f49477a);
        this.D.addUpdateListener(new b(gVar));
        this.D.start();
    }

    private void C() {
        setWillNotDraw(!y());
    }

    private void e() {
        WeakReference weakReference = this.C;
        if (weakReference != null) {
            weakReference.clear();
        }
        this.C = null;
    }

    private View f(View view) {
        int i10;
        if (this.C == null && (i10 = this.B) != -1) {
            View findViewById = view != null ? view.findViewById(i10) : null;
            if (findViewById == null && (getParent() instanceof ViewGroup)) {
                findViewById = ((ViewGroup) getParent()).findViewById(this.B);
            }
            if (findViewById != null) {
                this.C = new WeakReference(findViewById);
            }
        }
        WeakReference weakReference = this.C;
        if (weakReference != null) {
            return (View) weakReference.get();
        }
        return null;
    }

    private boolean k() {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            if (((f) getChildAt(i10).getLayoutParams()).e()) {
                return true;
            }
        }
        return false;
    }

    private void m() {
        Behavior behavior = this.H;
        BaseBehavior.e t02 = (behavior == null || this.f12775q == -1 || this.f12779u != 0) ? null : behavior.t0(z3.a.f53152q, this);
        this.f12775q = -1;
        this.f12776r = -1;
        this.f12777s = -1;
        if (t02 != null) {
            this.H.s0(t02, false);
        }
    }

    private void u(boolean z10, boolean z11, boolean z12) {
        this.f12779u = (z10 ? 1 : 2) | (z11 ? 4 : 0) | (z12 ? 8 : 0);
        requestLayout();
    }

    private boolean v(boolean z10) {
        if (this.f12783y == z10) {
            return false;
        }
        this.f12783y = z10;
        refreshDrawableState();
        return true;
    }

    private boolean y() {
        return this.G != null && getTopInset() > 0;
    }

    public void c(c cVar) {
        if (this.f12781w == null) {
            this.f12781w = new ArrayList();
        }
        if (cVar == null || this.f12781w.contains(cVar)) {
            return;
        }
        this.f12781w.add(cVar);
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof f;
    }

    public void d(g gVar) {
        c(gVar);
    }

    @Override // android.view.View
    public void draw(Canvas canvas) {
        super.draw(canvas);
        if (y()) {
            int save = canvas.save();
            canvas.translate(BitmapDescriptorFactory.HUE_RED, -this.f12774p);
            this.G.draw(canvas);
            canvas.restoreToCount(save);
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void drawableStateChanged() {
        super.drawableStateChanged();
        int[] drawableState = getDrawableState();
        Drawable drawable = this.G;
        if (drawable != null && drawable.isStateful() && drawable.setState(drawableState)) {
            invalidateDrawable(drawable);
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.widget.LinearLayout, android.view.ViewGroup
    /* renamed from: g, reason: merged with bridge method [inline-methods] */
    public f generateDefaultLayoutParams() {
        return new f(-1, -2);
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.b
    public CoordinatorLayout.c getBehavior() {
        Behavior behavior = new Behavior();
        this.H = behavior;
        return behavior;
    }

    int getDownNestedPreScrollRange() {
        int i10;
        int A;
        int i11 = this.f12776r;
        if (i11 != -1) {
            return i11;
        }
        int i12 = 0;
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = getChildAt(childCount);
            f fVar = (f) childAt.getLayoutParams();
            int measuredHeight = childAt.getMeasuredHeight();
            int i13 = fVar.f12813a;
            if ((i13 & 5) != 5) {
                if (i12 > 0) {
                    break;
                }
            } else {
                int i14 = ((LinearLayout.LayoutParams) fVar).topMargin + ((LinearLayout.LayoutParams) fVar).bottomMargin;
                if ((i13 & 8) != 0) {
                    A = s0.A(childAt);
                } else if ((i13 & 2) != 0) {
                    A = measuredHeight - s0.A(childAt);
                } else {
                    i10 = i14 + measuredHeight;
                    if (childCount == 0 && s0.w(childAt)) {
                        i10 = Math.min(i10, measuredHeight - getTopInset());
                    }
                    i12 += i10;
                }
                i10 = i14 + A;
                if (childCount == 0) {
                    i10 = Math.min(i10, measuredHeight - getTopInset());
                }
                i12 += i10;
            }
        }
        int max = Math.max(0, i12);
        this.f12776r = max;
        return max;
    }

    int getDownNestedScrollRange() {
        int i10 = this.f12777s;
        if (i10 != -1) {
            return i10;
        }
        int childCount = getChildCount();
        int i11 = 0;
        int i12 = 0;
        while (true) {
            if (i11 >= childCount) {
                break;
            }
            View childAt = getChildAt(i11);
            f fVar = (f) childAt.getLayoutParams();
            int measuredHeight = childAt.getMeasuredHeight() + ((LinearLayout.LayoutParams) fVar).topMargin + ((LinearLayout.LayoutParams) fVar).bottomMargin;
            int i13 = fVar.f12813a;
            if ((i13 & 1) == 0) {
                break;
            }
            i12 += measuredHeight;
            if ((i13 & 2) != 0) {
                i12 -= s0.A(childAt);
                break;
            }
            i11++;
        }
        int max = Math.max(0, i12);
        this.f12777s = max;
        return max;
    }

    public int getLiftOnScrollTargetViewId() {
        return this.B;
    }

    public final int getMinimumHeightForVisibleOverlappingContent() {
        int topInset = getTopInset();
        int A = s0.A(this);
        if (A == 0) {
            int childCount = getChildCount();
            A = childCount >= 1 ? s0.A(getChildAt(childCount - 1)) : 0;
            if (A == 0) {
                return getHeight() / 3;
            }
        }
        return (A * 2) + topInset;
    }

    int getPendingAction() {
        return this.f12779u;
    }

    public Drawable getStatusBarForeground() {
        return this.G;
    }

    @Deprecated
    public float getTargetElevation() {
        return BitmapDescriptorFactory.HUE_RED;
    }

    final int getTopInset() {
        h1 h1Var = this.f12780v;
        if (h1Var != null) {
            return h1Var.l();
        }
        return 0;
    }

    public final int getTotalScrollRange() {
        int i10 = this.f12775q;
        if (i10 != -1) {
            return i10;
        }
        int childCount = getChildCount();
        int i11 = 0;
        int i12 = 0;
        while (true) {
            if (i11 >= childCount) {
                break;
            }
            View childAt = getChildAt(i11);
            f fVar = (f) childAt.getLayoutParams();
            int measuredHeight = childAt.getMeasuredHeight();
            int i13 = fVar.f12813a;
            if ((i13 & 1) == 0) {
                break;
            }
            i12 += measuredHeight + ((LinearLayout.LayoutParams) fVar).topMargin + ((LinearLayout.LayoutParams) fVar).bottomMargin;
            if (i11 == 0 && s0.w(childAt)) {
                i12 -= getTopInset();
            }
            if ((i13 & 2) != 0) {
                i12 -= s0.A(childAt);
                break;
            }
            i11++;
        }
        int max = Math.max(0, i12);
        this.f12775q = max;
        return max;
    }

    int getUpNestedPreScrollRange() {
        return getTotalScrollRange();
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    /* renamed from: h, reason: merged with bridge method [inline-methods] */
    public f generateLayoutParams(AttributeSet attributeSet) {
        return new f(getContext(), attributeSet);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.widget.LinearLayout, android.view.ViewGroup
    /* renamed from: i, reason: merged with bridge method [inline-methods] */
    public f generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof LinearLayout.LayoutParams ? new f((LinearLayout.LayoutParams) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new f((ViewGroup.MarginLayoutParams) layoutParams) : new f(layoutParams);
    }

    boolean j() {
        return this.f12778t;
    }

    boolean l() {
        return getTotalScrollRange() != 0;
    }

    public boolean n() {
        return this.A;
    }

    void o(int i10) {
        this.f12774p = i10;
        if (!willNotDraw()) {
            s0.d0(this);
        }
        List list = this.f12781w;
        if (list != null) {
            int size = list.size();
            for (int i11 = 0; i11 < size; i11++) {
                c cVar = (c) this.f12781w.get(i11);
                if (cVar != null) {
                    cVar.a(this, i10);
                }
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        lj.h.e(this);
    }

    @Override // android.view.ViewGroup, android.view.View
    protected int[] onCreateDrawableState(int i10) {
        if (this.F == null) {
            this.F = new int[4];
        }
        int[] iArr = this.F;
        int[] onCreateDrawableState = super.onCreateDrawableState(i10 + iArr.length);
        boolean z10 = this.f12783y;
        int i11 = vi.b.P;
        if (!z10) {
            i11 = -i11;
        }
        iArr[0] = i11;
        iArr[1] = (z10 && this.f12784z) ? vi.b.Q : -vi.b.Q;
        int i12 = vi.b.O;
        if (!z10) {
            i12 = -i12;
        }
        iArr[2] = i12;
        iArr[3] = (z10 && this.f12784z) ? vi.b.N : -vi.b.N;
        return View.mergeDrawableStates(onCreateDrawableState, iArr);
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        e();
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
    protected void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        super.onLayout(z10, i10, i11, i12, i13);
        boolean z11 = true;
        if (s0.w(this) && A()) {
            int topInset = getTopInset();
            for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
                s0.X(getChildAt(childCount), topInset);
            }
        }
        m();
        this.f12778t = false;
        int childCount2 = getChildCount();
        int i14 = 0;
        while (true) {
            if (i14 >= childCount2) {
                break;
            }
            if (((f) getChildAt(i14).getLayoutParams()).d() != null) {
                this.f12778t = true;
                break;
            }
            i14++;
        }
        Drawable drawable = this.G;
        if (drawable != null) {
            drawable.setBounds(0, 0, getWidth(), getTopInset());
        }
        if (this.f12782x) {
            return;
        }
        if (!this.A && !k()) {
            z11 = false;
        }
        v(z11);
    }

    @Override // android.widget.LinearLayout, android.view.View
    protected void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
        int mode = View.MeasureSpec.getMode(i11);
        if (mode != 1073741824 && s0.w(this) && A()) {
            int measuredHeight = getMeasuredHeight();
            if (mode == Integer.MIN_VALUE) {
                measuredHeight = o3.a.b(getMeasuredHeight() + getTopInset(), 0, View.MeasureSpec.getSize(i11));
            } else if (mode == 0) {
                measuredHeight += getTopInset();
            }
            setMeasuredDimension(getMeasuredWidth(), measuredHeight);
        }
        m();
    }

    h1 p(h1 h1Var) {
        h1 h1Var2 = s0.w(this) ? h1Var : null;
        if (!s3.d.a(this.f12780v, h1Var2)) {
            this.f12780v = h1Var2;
            C();
            requestLayout();
        }
        return h1Var;
    }

    public void q(c cVar) {
        List list = this.f12781w;
        if (list == null || cVar == null) {
            return;
        }
        list.remove(cVar);
    }

    public void r(g gVar) {
        q(gVar);
    }

    void s() {
        this.f12779u = 0;
    }

    @Override // android.view.View
    public void setElevation(float f10) {
        super.setElevation(f10);
        lj.h.d(this, f10);
    }

    public void setExpanded(boolean z10) {
        t(z10, s0.Q(this));
    }

    public void setLiftOnScroll(boolean z10) {
        this.A = z10;
    }

    public void setLiftOnScrollTargetViewId(int i10) {
        this.B = i10;
        e();
    }

    public void setLiftableOverrideEnabled(boolean z10) {
        this.f12782x = z10;
    }

    @Override // android.widget.LinearLayout
    public void setOrientation(int i10) {
        if (i10 != 1) {
            throw new IllegalArgumentException("AppBarLayout is always vertical and does not support horizontal orientation");
        }
        super.setOrientation(i10);
    }

    public void setStatusBarForeground(Drawable drawable) {
        Drawable drawable2 = this.G;
        if (drawable2 != drawable) {
            if (drawable2 != null) {
                drawable2.setCallback(null);
            }
            Drawable mutate = drawable != null ? drawable.mutate() : null;
            this.G = mutate;
            if (mutate != null) {
                if (mutate.isStateful()) {
                    this.G.setState(getDrawableState());
                }
                androidx.core.graphics.drawable.a.g(this.G, s0.z(this));
                this.G.setVisible(getVisibility() == 0, false);
                this.G.setCallback(this);
            }
            C();
            s0.d0(this);
        }
    }

    public void setStatusBarForegroundColor(int i10) {
        setStatusBarForeground(new ColorDrawable(i10));
    }

    public void setStatusBarForegroundResource(int i10) {
        setStatusBarForeground(j.a.b(getContext(), i10));
    }

    @Deprecated
    public void setTargetElevation(float f10) {
        com.google.android.material.appbar.e.b(this, f10);
    }

    @Override // android.view.View
    public void setVisibility(int i10) {
        super.setVisibility(i10);
        boolean z10 = i10 == 0;
        Drawable drawable = this.G;
        if (drawable != null) {
            drawable.setVisible(z10, false);
        }
    }

    public void t(boolean z10, boolean z11) {
        u(z10, z11, true);
    }

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

    boolean w(boolean z10) {
        return x(z10, !this.f12782x);
    }

    boolean x(boolean z10, boolean z11) {
        if (!z11 || this.f12784z == z10) {
            return false;
        }
        this.f12784z = z10;
        refreshDrawableState();
        if (!this.A || !(getBackground() instanceof lj.g)) {
            return true;
        }
        B((lj.g) getBackground(), z10);
        return true;
    }

    boolean z(View view) {
        View f10 = f(view);
        if (f10 != null) {
            view = f10;
        }
        return view != null && (view.canScrollVertically(-1) || view.getScrollY() > 0);
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public AppBarLayout(Context context, AttributeSet attributeSet, int i10) {
        super(nj.a.c(context, attributeSet, i10, r4), attributeSet, i10);
        int i11 = I;
        this.f12775q = -1;
        this.f12776r = -1;
        this.f12777s = -1;
        this.f12779u = 0;
        this.E = new ArrayList();
        Context context2 = getContext();
        setOrientation(1);
        if (getOutlineProvider() == ViewOutlineProvider.BACKGROUND) {
            com.google.android.material.appbar.e.a(this);
        }
        com.google.android.material.appbar.e.c(this, attributeSet, i10, i11);
        TypedArray h10 = o.h(context2, attributeSet, l.f40012k, i10, i11, new int[0]);
        s0.q0(this, h10.getDrawable(l.f40022l));
        if (getBackground() instanceof ColorDrawable) {
            ColorDrawable colorDrawable = (ColorDrawable) getBackground();
            lj.g gVar = new lj.g();
            gVar.W(ColorStateList.valueOf(colorDrawable.getColor()));
            gVar.L(context2);
            s0.q0(this, gVar);
        }
        int i12 = l.f40062p;
        if (h10.hasValue(i12)) {
            u(h10.getBoolean(i12, false), false, false);
        }
        if (h10.hasValue(l.f40052o)) {
            com.google.android.material.appbar.e.b(this, h10.getDimensionPixelSize(r11, 0));
        }
        int i13 = l.f40042n;
        if (h10.hasValue(i13)) {
            setKeyboardNavigationCluster(h10.getBoolean(i13, false));
        }
        int i14 = l.f40032m;
        if (h10.hasValue(i14)) {
            setTouchscreenBlocksFocus(h10.getBoolean(i14, false));
        }
        this.A = h10.getBoolean(l.f40072q, false);
        this.B = h10.getResourceId(l.f40082r, -1);
        setStatusBarForeground(h10.getDrawable(l.f40092s));
        h10.recycle();
        s0.A0(this, new a());
    }

    /* loaded from: classes3.dex */
    public static class f extends LinearLayout.LayoutParams {

        /* renamed from: a, reason: collision with root package name */
        int f12813a;

        /* renamed from: b, reason: collision with root package name */
        private d f12814b;

        /* renamed from: c, reason: collision with root package name */
        Interpolator f12815c;

        public f(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f12813a = 1;
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, l.f40112u);
            this.f12813a = obtainStyledAttributes.getInt(l.f40132w, 0);
            f(a(obtainStyledAttributes.getInt(l.f40122v, 0)));
            int i10 = l.f40142x;
            if (obtainStyledAttributes.hasValue(i10)) {
                this.f12815c = AnimationUtils.loadInterpolator(context, obtainStyledAttributes.getResourceId(i10, 0));
            }
            obtainStyledAttributes.recycle();
        }

        private d a(int i10) {
            if (i10 != 1) {
                return null;
            }
            return new e();
        }

        public d b() {
            return this.f12814b;
        }

        public int c() {
            return this.f12813a;
        }

        public Interpolator d() {
            return this.f12815c;
        }

        boolean e() {
            int i10 = this.f12813a;
            return (i10 & 1) == 1 && (i10 & 10) != 0;
        }

        public void f(d dVar) {
            this.f12814b = dVar;
        }

        public f(int i10, int i11) {
            super(i10, i11);
            this.f12813a = 1;
        }

        public f(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f12813a = 1;
        }

        public f(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
            this.f12813a = 1;
        }

        public f(LinearLayout.LayoutParams layoutParams) {
            super(layoutParams);
            this.f12813a = 1;
        }
    }
}
