package com.google.android.material.appbar;

import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.h0;
import androidx.core.view.h1;
import androidx.core.view.s0;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.internal.o;
import com.google.firebase.perf.util.Constants;
import h.i;
import vi.f;
import vi.k;
import vi.l;

/* loaded from: classes3.dex */
public class CollapsingToolbarLayout extends FrameLayout {
    private static final int S = k.f39896k;
    final ej.a A;
    private boolean B;
    private boolean C;
    private Drawable D;
    Drawable E;
    private int F;
    private boolean G;
    private ValueAnimator H;
    private long I;
    private int J;
    private AppBarLayout.g K;
    int L;
    private int M;
    h1 N;
    private int O;
    private boolean P;
    private int Q;
    private boolean R;

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

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

    /* renamed from: r, reason: collision with root package name */
    private ViewGroup f12818r;

    /* renamed from: s, reason: collision with root package name */
    private View f12819s;

    /* renamed from: t, reason: collision with root package name */
    private View f12820t;

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

    /* renamed from: v, reason: collision with root package name */
    private int f12822v;

    /* renamed from: w, reason: collision with root package name */
    private int f12823w;

    /* renamed from: x, reason: collision with root package name */
    private int f12824x;

    /* renamed from: y, reason: collision with root package name */
    private final Rect f12825y;

    /* renamed from: z, reason: collision with root package name */
    final com.google.android.material.internal.b f12826z;

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

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

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

        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            CollapsingToolbarLayout.this.setScrimAlpha(((Integer) valueAnimator.getAnimatedValue()).intValue());
        }
    }

    /* loaded from: classes3.dex */
    private class d implements AppBarLayout.g {
        d() {
        }

        @Override // com.google.android.material.appbar.AppBarLayout.c
        public void a(AppBarLayout appBarLayout, int i10) {
            CollapsingToolbarLayout collapsingToolbarLayout = CollapsingToolbarLayout.this;
            collapsingToolbarLayout.L = i10;
            h1 h1Var = collapsingToolbarLayout.N;
            int l10 = h1Var != null ? h1Var.l() : 0;
            int childCount = CollapsingToolbarLayout.this.getChildCount();
            for (int i11 = 0; i11 < childCount; i11++) {
                View childAt = CollapsingToolbarLayout.this.getChildAt(i11);
                c cVar = (c) childAt.getLayoutParams();
                com.google.android.material.appbar.d j10 = CollapsingToolbarLayout.j(childAt);
                int i12 = cVar.f12829a;
                if (i12 == 1) {
                    j10.f(o3.a.b(-i10, 0, CollapsingToolbarLayout.this.h(childAt)));
                } else if (i12 == 2) {
                    j10.f(Math.round((-i10) * cVar.f12830b));
                }
            }
            CollapsingToolbarLayout.this.u();
            CollapsingToolbarLayout collapsingToolbarLayout2 = CollapsingToolbarLayout.this;
            if (collapsingToolbarLayout2.E != null && l10 > 0) {
                s0.d0(collapsingToolbarLayout2);
            }
            int height = (CollapsingToolbarLayout.this.getHeight() - s0.A(CollapsingToolbarLayout.this)) - l10;
            float f10 = height;
            CollapsingToolbarLayout.this.f12826z.w0(Math.min(1.0f, (r0 - CollapsingToolbarLayout.this.getScrimVisibleHeightTrigger()) / f10));
            CollapsingToolbarLayout collapsingToolbarLayout3 = CollapsingToolbarLayout.this;
            collapsingToolbarLayout3.f12826z.j0(collapsingToolbarLayout3.L + height);
            CollapsingToolbarLayout.this.f12826z.u0(Math.abs(i10) / f10);
        }
    }

    public CollapsingToolbarLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, vi.b.f39729k);
    }

    private void a(int i10) {
        c();
        ValueAnimator valueAnimator = this.H;
        if (valueAnimator == null) {
            ValueAnimator valueAnimator2 = new ValueAnimator();
            this.H = valueAnimator2;
            valueAnimator2.setInterpolator(i10 > this.F ? wi.a.f49479c : wi.a.f49480d);
            this.H.addUpdateListener(new b());
        } else if (valueAnimator.isRunning()) {
            this.H.cancel();
        }
        this.H.setDuration(this.I);
        this.H.setIntValues(this.F, i10);
        this.H.start();
    }

    private void b(AppBarLayout appBarLayout) {
        if (k()) {
            appBarLayout.setLiftOnScroll(false);
        }
    }

    private void c() {
        if (this.f12816p) {
            ViewGroup viewGroup = null;
            this.f12818r = null;
            this.f12819s = null;
            int i10 = this.f12817q;
            if (i10 != -1) {
                ViewGroup viewGroup2 = (ViewGroup) findViewById(i10);
                this.f12818r = viewGroup2;
                if (viewGroup2 != null) {
                    this.f12819s = d(viewGroup2);
                }
            }
            if (this.f12818r == null) {
                int childCount = getChildCount();
                int i11 = 0;
                while (true) {
                    if (i11 >= childCount) {
                        break;
                    }
                    View childAt = getChildAt(i11);
                    if (l(childAt)) {
                        viewGroup = (ViewGroup) childAt;
                        break;
                    }
                    i11++;
                }
                this.f12818r = viewGroup;
            }
            t();
            this.f12816p = false;
        }
    }

    private View d(View view) {
        for (ViewParent parent = view.getParent(); parent != this && parent != null; parent = parent.getParent()) {
            if (parent instanceof View) {
                view = parent;
            }
        }
        return view;
    }

    private static int g(View view) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
            return view.getMeasuredHeight();
        }
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        return view.getMeasuredHeight() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
    }

    private static CharSequence i(View view) {
        if (view instanceof Toolbar) {
            return ((Toolbar) view).getTitle();
        }
        if (view instanceof android.widget.Toolbar) {
            return ((android.widget.Toolbar) view).getTitle();
        }
        return null;
    }

    static com.google.android.material.appbar.d j(View view) {
        int i10 = f.f39804a0;
        com.google.android.material.appbar.d dVar = (com.google.android.material.appbar.d) view.getTag(i10);
        if (dVar != null) {
            return dVar;
        }
        com.google.android.material.appbar.d dVar2 = new com.google.android.material.appbar.d(view);
        view.setTag(i10, dVar2);
        return dVar2;
    }

    private boolean k() {
        return this.M == 1;
    }

    private static boolean l(View view) {
        return (view instanceof Toolbar) || (view instanceof android.widget.Toolbar);
    }

    private boolean m(View view) {
        View view2 = this.f12819s;
        if (view2 == null || view2 == this) {
            if (view == this.f12818r) {
                return true;
            }
        } else if (view == view2) {
            return true;
        }
        return false;
    }

    private void p(boolean z10) {
        int i10;
        int i11;
        int i12;
        int i13;
        View view = this.f12819s;
        if (view == null) {
            view = this.f12818r;
        }
        int h10 = h(view);
        com.google.android.material.internal.c.a(this, this.f12820t, this.f12825y);
        ViewGroup viewGroup = this.f12818r;
        if (viewGroup instanceof Toolbar) {
            Toolbar toolbar = (Toolbar) viewGroup;
            i10 = toolbar.getTitleMarginStart();
            i12 = toolbar.getTitleMarginEnd();
            i13 = toolbar.getTitleMarginTop();
            i11 = toolbar.getTitleMarginBottom();
        } else if (viewGroup instanceof android.widget.Toolbar) {
            android.widget.Toolbar toolbar2 = (android.widget.Toolbar) viewGroup;
            i10 = toolbar2.getTitleMarginStart();
            i12 = toolbar2.getTitleMarginEnd();
            i13 = toolbar2.getTitleMarginTop();
            i11 = toolbar2.getTitleMarginBottom();
        } else {
            i10 = 0;
            i11 = 0;
            i12 = 0;
            i13 = 0;
        }
        com.google.android.material.internal.b bVar = this.f12826z;
        Rect rect = this.f12825y;
        int i14 = rect.left + (z10 ? i12 : i10);
        int i15 = rect.top + h10 + i13;
        int i16 = rect.right;
        if (!z10) {
            i10 = i12;
        }
        bVar.b0(i14, i15, i16 - i10, (rect.bottom + h10) - i11);
    }

    private void q() {
        setContentDescription(getTitle());
    }

    private void r(Drawable drawable, int i10, int i11) {
        s(drawable, this.f12818r, i10, i11);
    }

    private void s(Drawable drawable, View view, int i10, int i11) {
        if (k() && view != null && this.B) {
            i11 = view.getBottom();
        }
        drawable.setBounds(0, 0, i10, i11);
    }

    private void t() {
        View view;
        if (!this.B && (view = this.f12820t) != null) {
            ViewParent parent = view.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(this.f12820t);
            }
        }
        if (!this.B || this.f12818r == null) {
            return;
        }
        if (this.f12820t == null) {
            this.f12820t = new View(getContext());
        }
        if (this.f12820t.getParent() == null) {
            this.f12818r.addView(this.f12820t, -1, -1);
        }
    }

    private void v(int i10, int i11, int i12, int i13, boolean z10) {
        View view;
        if (!this.B || (view = this.f12820t) == null) {
            return;
        }
        boolean z11 = s0.P(view) && this.f12820t.getVisibility() == 0;
        this.C = z11;
        if (z11 || z10) {
            boolean z12 = s0.z(this) == 1;
            p(z12);
            this.f12826z.k0(z12 ? this.f12823w : this.f12821u, this.f12825y.top + this.f12822v, (i12 - i10) - (z12 ? this.f12821u : this.f12823w), (i13 - i11) - this.f12824x);
            this.f12826z.Z(z10);
        }
    }

    private void w() {
        if (this.f12818r != null && this.B && TextUtils.isEmpty(this.f12826z.M())) {
            setTitle(i(this.f12818r));
        }
    }

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

    @Override // android.view.View
    public void draw(Canvas canvas) {
        Drawable drawable;
        super.draw(canvas);
        c();
        if (this.f12818r == null && (drawable = this.D) != null && this.F > 0) {
            drawable.mutate().setAlpha(this.F);
            this.D.draw(canvas);
        }
        if (this.B && this.C) {
            if (this.f12818r == null || this.D == null || this.F <= 0 || !k() || this.f12826z.D() >= this.f12826z.E()) {
                this.f12826z.l(canvas);
            } else {
                int save = canvas.save();
                canvas.clipRect(this.D.getBounds(), Region.Op.DIFFERENCE);
                this.f12826z.l(canvas);
                canvas.restoreToCount(save);
            }
        }
        if (this.E == null || this.F <= 0) {
            return;
        }
        h1 h1Var = this.N;
        int l10 = h1Var != null ? h1Var.l() : 0;
        if (l10 > 0) {
            this.E.setBounds(0, -this.L, getWidth(), l10 - this.L);
            this.E.mutate().setAlpha(this.F);
            this.E.draw(canvas);
        }
    }

    @Override // android.view.ViewGroup
    protected boolean drawChild(Canvas canvas, View view, long j10) {
        boolean z10;
        if (this.D == null || this.F <= 0 || !m(view)) {
            z10 = false;
        } else {
            s(this.D, view, getWidth(), getHeight());
            this.D.mutate().setAlpha(this.F);
            this.D.draw(canvas);
            z10 = true;
        }
        return super.drawChild(canvas, view, j10) || z10;
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void drawableStateChanged() {
        super.drawableStateChanged();
        int[] drawableState = getDrawableState();
        Drawable drawable = this.E;
        boolean z10 = false;
        if (drawable != null && drawable.isStateful()) {
            z10 = false | drawable.setState(drawableState);
        }
        Drawable drawable2 = this.D;
        if (drawable2 != null && drawable2.isStateful()) {
            z10 |= drawable2.setState(drawableState);
        }
        com.google.android.material.internal.b bVar = this.f12826z;
        if (bVar != null) {
            z10 |= bVar.E0(drawableState);
        }
        if (z10) {
            invalidate();
        }
    }

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

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

    public int getCollapsedTitleGravity() {
        return this.f12826z.q();
    }

    public Typeface getCollapsedTitleTypeface() {
        return this.f12826z.u();
    }

    public Drawable getContentScrim() {
        return this.D;
    }

    public int getExpandedTitleGravity() {
        return this.f12826z.A();
    }

    public int getExpandedTitleMarginBottom() {
        return this.f12824x;
    }

    public int getExpandedTitleMarginEnd() {
        return this.f12823w;
    }

    public int getExpandedTitleMarginStart() {
        return this.f12821u;
    }

    public int getExpandedTitleMarginTop() {
        return this.f12822v;
    }

    public Typeface getExpandedTitleTypeface() {
        return this.f12826z.C();
    }

    public int getHyphenationFrequency() {
        return this.f12826z.F();
    }

    public int getLineCount() {
        return this.f12826z.G();
    }

    public float getLineSpacingAdd() {
        return this.f12826z.H();
    }

    public float getLineSpacingMultiplier() {
        return this.f12826z.I();
    }

    public int getMaxLines() {
        return this.f12826z.J();
    }

    int getScrimAlpha() {
        return this.F;
    }

    public long getScrimAnimationDuration() {
        return this.I;
    }

    public int getScrimVisibleHeightTrigger() {
        int i10 = this.J;
        if (i10 >= 0) {
            return i10 + this.O + this.Q;
        }
        h1 h1Var = this.N;
        int l10 = h1Var != null ? h1Var.l() : 0;
        int A = s0.A(this);
        return A > 0 ? Math.min((A * 2) + l10, getHeight()) : getHeight() / 3;
    }

    public Drawable getStatusBarScrim() {
        return this.E;
    }

    public CharSequence getTitle() {
        if (this.B) {
            return this.f12826z.M();
        }
        return null;
    }

    public int getTitleCollapseMode() {
        return this.M;
    }

    public TimeInterpolator getTitlePositionInterpolator() {
        return this.f12826z.L();
    }

    final int h(View view) {
        return ((getHeight() - j(view).b()) - view.getHeight()) - ((FrameLayout.LayoutParams) ((c) view.getLayoutParams())).bottomMargin;
    }

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

    public void o(boolean z10, boolean z11) {
        if (this.G != z10) {
            int i10 = Constants.MAX_HOST_LENGTH;
            if (z11) {
                if (!z10) {
                    i10 = 0;
                }
                a(i10);
            } else {
                if (!z10) {
                    i10 = 0;
                }
                setScrimAlpha(i10);
            }
            this.G = z10;
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        ViewParent parent = getParent();
        if (parent instanceof AppBarLayout) {
            AppBarLayout appBarLayout = (AppBarLayout) parent;
            b(appBarLayout);
            s0.v0(this, s0.w(appBarLayout));
            if (this.K == null) {
                this.K = new d();
            }
            appBarLayout.d(this.K);
            s0.j0(this);
        }
    }

    @Override // android.view.View
    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        this.f12826z.V(configuration);
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onDetachedFromWindow() {
        ViewParent parent = getParent();
        AppBarLayout.g gVar = this.K;
        if (gVar != null && (parent instanceof AppBarLayout)) {
            ((AppBarLayout) parent).r(gVar);
        }
        super.onDetachedFromWindow();
    }

    @Override // android.widget.FrameLayout, 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);
        h1 h1Var = this.N;
        if (h1Var != null) {
            int l10 = h1Var.l();
            int childCount = getChildCount();
            for (int i14 = 0; i14 < childCount; i14++) {
                View childAt = getChildAt(i14);
                if (!s0.w(childAt) && childAt.getTop() < l10) {
                    s0.X(childAt, l10);
                }
            }
        }
        int childCount2 = getChildCount();
        for (int i15 = 0; i15 < childCount2; i15++) {
            j(getChildAt(i15)).d();
        }
        v(i10, i11, i12, i13, false);
        w();
        u();
        int childCount3 = getChildCount();
        for (int i16 = 0; i16 < childCount3; i16++) {
            j(getChildAt(i16)).a();
        }
    }

    @Override // android.widget.FrameLayout, android.view.View
    protected void onMeasure(int i10, int i11) {
        c();
        super.onMeasure(i10, i11);
        int mode = View.MeasureSpec.getMode(i11);
        h1 h1Var = this.N;
        int l10 = h1Var != null ? h1Var.l() : 0;
        if ((mode == 0 || this.P) && l10 > 0) {
            this.O = l10;
            super.onMeasure(i10, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + l10, 1073741824));
        }
        if (this.R && this.f12826z.J() > 1) {
            w();
            v(0, 0, getMeasuredWidth(), getMeasuredHeight(), true);
            int y10 = this.f12826z.y();
            if (y10 > 1) {
                this.Q = Math.round(this.f12826z.z()) * (y10 - 1);
                super.onMeasure(i10, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + this.Q, 1073741824));
            }
        }
        ViewGroup viewGroup = this.f12818r;
        if (viewGroup != null) {
            View view = this.f12819s;
            if (view == null || view == this) {
                setMinimumHeight(g(viewGroup));
            } else {
                setMinimumHeight(g(view));
            }
        }
    }

    @Override // android.view.View
    protected void onSizeChanged(int i10, int i11, int i12, int i13) {
        super.onSizeChanged(i10, i11, i12, i13);
        Drawable drawable = this.D;
        if (drawable != null) {
            r(drawable, i10, i11);
        }
    }

    public void setCollapsedTitleGravity(int i10) {
        this.f12826z.g0(i10);
    }

    public void setCollapsedTitleTextAppearance(int i10) {
        this.f12826z.d0(i10);
    }

    public void setCollapsedTitleTextColor(int i10) {
        setCollapsedTitleTextColor(ColorStateList.valueOf(i10));
    }

    public void setCollapsedTitleTypeface(Typeface typeface) {
        this.f12826z.h0(typeface);
    }

    public void setContentScrim(Drawable drawable) {
        Drawable drawable2 = this.D;
        if (drawable2 != drawable) {
            if (drawable2 != null) {
                drawable2.setCallback(null);
            }
            Drawable mutate = drawable != null ? drawable.mutate() : null;
            this.D = mutate;
            if (mutate != null) {
                r(mutate, getWidth(), getHeight());
                this.D.setCallback(this);
                this.D.setAlpha(this.F);
            }
            s0.d0(this);
        }
    }

    public void setContentScrimColor(int i10) {
        setContentScrim(new ColorDrawable(i10));
    }

    public void setContentScrimResource(int i10) {
        setContentScrim(androidx.core.content.a.getDrawable(getContext(), i10));
    }

    public void setExpandedTitleColor(int i10) {
        setExpandedTitleTextColor(ColorStateList.valueOf(i10));
    }

    public void setExpandedTitleGravity(int i10) {
        this.f12826z.q0(i10);
    }

    public void setExpandedTitleMarginBottom(int i10) {
        this.f12824x = i10;
        requestLayout();
    }

    public void setExpandedTitleMarginEnd(int i10) {
        this.f12823w = i10;
        requestLayout();
    }

    public void setExpandedTitleMarginStart(int i10) {
        this.f12821u = i10;
        requestLayout();
    }

    public void setExpandedTitleMarginTop(int i10) {
        this.f12822v = i10;
        requestLayout();
    }

    public void setExpandedTitleTextAppearance(int i10) {
        this.f12826z.n0(i10);
    }

    public void setExpandedTitleTextColor(ColorStateList colorStateList) {
        this.f12826z.p0(colorStateList);
    }

    public void setExpandedTitleTypeface(Typeface typeface) {
        this.f12826z.s0(typeface);
    }

    public void setExtraMultilineHeightEnabled(boolean z10) {
        this.R = z10;
    }

    public void setForceApplySystemWindowInsetTop(boolean z10) {
        this.P = z10;
    }

    public void setHyphenationFrequency(int i10) {
        this.f12826z.x0(i10);
    }

    public void setLineSpacingAdd(float f10) {
        this.f12826z.z0(f10);
    }

    public void setLineSpacingMultiplier(float f10) {
        this.f12826z.A0(f10);
    }

    public void setMaxLines(int i10) {
        this.f12826z.B0(i10);
    }

    public void setRtlTextDirectionHeuristicsEnabled(boolean z10) {
        this.f12826z.D0(z10);
    }

    void setScrimAlpha(int i10) {
        ViewGroup viewGroup;
        if (i10 != this.F) {
            if (this.D != null && (viewGroup = this.f12818r) != null) {
                s0.d0(viewGroup);
            }
            this.F = i10;
            s0.d0(this);
        }
    }

    public void setScrimAnimationDuration(long j10) {
        this.I = j10;
    }

    public void setScrimVisibleHeightTrigger(int i10) {
        if (this.J != i10) {
            this.J = i10;
            u();
        }
    }

    public void setScrimsShown(boolean z10) {
        o(z10, s0.Q(this) && !isInEditMode());
    }

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

    public void setStatusBarScrimColor(int i10) {
        setStatusBarScrim(new ColorDrawable(i10));
    }

    public void setStatusBarScrimResource(int i10) {
        setStatusBarScrim(androidx.core.content.a.getDrawable(getContext(), i10));
    }

    public void setTitle(CharSequence charSequence) {
        this.f12826z.F0(charSequence);
        q();
    }

    public void setTitleCollapseMode(int i10) {
        this.M = i10;
        boolean k10 = k();
        this.f12826z.v0(k10);
        ViewParent parent = getParent();
        if (parent instanceof AppBarLayout) {
            b((AppBarLayout) parent);
        }
        if (k10 && this.D == null) {
            setContentScrimColor(this.A.d(getResources().getDimension(vi.d.f39756a)));
        }
    }

    public void setTitleEnabled(boolean z10) {
        if (z10 != this.B) {
            this.B = z10;
            q();
            t();
            requestLayout();
        }
    }

    public void setTitlePositionInterpolator(TimeInterpolator timeInterpolator) {
        this.f12826z.C0(timeInterpolator);
    }

    @Override // android.view.View
    public void setVisibility(int i10) {
        super.setVisibility(i10);
        boolean z10 = i10 == 0;
        Drawable drawable = this.E;
        if (drawable != null && drawable.isVisible() != z10) {
            this.E.setVisible(z10, false);
        }
        Drawable drawable2 = this.D;
        if (drawable2 == null || drawable2.isVisible() == z10) {
            return;
        }
        this.D.setVisible(z10, false);
    }

    final void u() {
        if (this.D == null && this.E == null) {
            return;
        }
        setScrimsShown(getHeight() + this.L < getScrimVisibleHeightTrigger());
    }

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

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public CollapsingToolbarLayout(Context context, AttributeSet attributeSet, int i10) {
        super(nj.a.c(context, attributeSet, i10, r4), attributeSet, i10);
        int i11 = S;
        this.f12816p = true;
        this.f12825y = new Rect();
        this.J = -1;
        this.O = 0;
        this.Q = 0;
        Context context2 = getContext();
        com.google.android.material.internal.b bVar = new com.google.android.material.internal.b(this);
        this.f12826z = bVar;
        bVar.G0(wi.a.f49481e);
        bVar.D0(false);
        this.A = new ej.a(context2);
        TypedArray h10 = o.h(context2, attributeSet, l.f40154y1, i10, i11, new int[0]);
        bVar.q0(h10.getInt(l.D1, 8388691));
        bVar.g0(h10.getInt(l.f40164z1, 8388627));
        int dimensionPixelSize = h10.getDimensionPixelSize(l.E1, 0);
        this.f12824x = dimensionPixelSize;
        this.f12823w = dimensionPixelSize;
        this.f12822v = dimensionPixelSize;
        this.f12821u = dimensionPixelSize;
        int i12 = l.H1;
        if (h10.hasValue(i12)) {
            this.f12821u = h10.getDimensionPixelSize(i12, 0);
        }
        int i13 = l.G1;
        if (h10.hasValue(i13)) {
            this.f12823w = h10.getDimensionPixelSize(i13, 0);
        }
        int i14 = l.I1;
        if (h10.hasValue(i14)) {
            this.f12822v = h10.getDimensionPixelSize(i14, 0);
        }
        int i15 = l.F1;
        if (h10.hasValue(i15)) {
            this.f12824x = h10.getDimensionPixelSize(i15, 0);
        }
        this.B = h10.getBoolean(l.T1, true);
        setTitle(h10.getText(l.R1));
        bVar.n0(k.f39888c);
        bVar.d0(i.f20277b);
        int i16 = l.J1;
        if (h10.hasValue(i16)) {
            bVar.n0(h10.getResourceId(i16, 0));
        }
        int i17 = l.A1;
        if (h10.hasValue(i17)) {
            bVar.d0(h10.getResourceId(i17, 0));
        }
        int i18 = l.K1;
        if (h10.hasValue(i18)) {
            bVar.p0(ij.c.a(context2, h10, i18));
        }
        int i19 = l.B1;
        if (h10.hasValue(i19)) {
            bVar.f0(ij.c.a(context2, h10, i19));
        }
        this.J = h10.getDimensionPixelSize(l.P1, -1);
        int i20 = l.N1;
        if (h10.hasValue(i20)) {
            bVar.B0(h10.getInt(i20, 1));
        }
        int i21 = l.U1;
        if (h10.hasValue(i21)) {
            bVar.C0(AnimationUtils.loadInterpolator(context2, h10.getResourceId(i21, 0)));
        }
        this.I = h10.getInt(l.O1, 600);
        setContentScrim(h10.getDrawable(l.C1));
        setStatusBarScrim(h10.getDrawable(l.Q1));
        setTitleCollapseMode(h10.getInt(l.S1, 0));
        this.f12817q = h10.getResourceId(l.V1, -1);
        this.P = h10.getBoolean(l.M1, false);
        this.R = h10.getBoolean(l.L1, false);
        h10.recycle();
        setWillNotDraw(false);
        s0.A0(this, new a());
    }

    public void setCollapsedTitleTextColor(ColorStateList colorStateList) {
        this.f12826z.f0(colorStateList);
    }

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

    /* loaded from: classes3.dex */
    public static class c extends FrameLayout.LayoutParams {

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

        /* renamed from: b, reason: collision with root package name */
        float f12830b;

        public c(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f12829a = 0;
            this.f12830b = 0.5f;
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, l.W1);
            this.f12829a = obtainStyledAttributes.getInt(l.X1, 0);
            a(obtainStyledAttributes.getFloat(l.Y1, 0.5f));
            obtainStyledAttributes.recycle();
        }

        public void a(float f10) {
            this.f12830b = f10;
        }

        public c(int i10, int i11) {
            super(i10, i11);
            this.f12829a = 0;
            this.f12830b = 0.5f;
        }

        public c(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f12829a = 0;
            this.f12830b = 0.5f;
        }
    }
}
