package com.google.android.material.appbar;

import android.animation.ObjectAnimator;
import android.animation.StateListAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
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.AbsSavedState;
import android.view.View;
import android.view.ViewGroup;
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 com.ifpdos.udi.service.core.pc.R;
import d.h.b.h;
import d.h.j.i0.c;
import d.h.j.l;
import d.h.j.y;
import g.e.a.a.d.b;
import g.e.a.a.d.d;
import g.e.a.a.d.e;
import g.e.a.a.d.f;
import g.e.a.a.w.g;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public class AppBarLayout extends LinearLayout implements CoordinatorLayout.b {

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public WeakReference<View> f989v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public ValueAnimator f990w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public int[] f991x;

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

    public static class BaseBehavior<T extends AppBarLayout> extends e<T> {

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

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

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

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

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

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

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public WeakReference<View> f999p;

        public static class a extends d.j.a.a {
            public static final Parcelable.Creator<a> CREATOR = new C0010a();

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

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

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

            /* JADX INFO: renamed from: com.google.android.material.appbar.AppBarLayout$BaseBehavior$a$a, reason: collision with other inner class name */
            public static class C0010a implements Parcelable.ClassLoaderCreator<a> {
                @Override // android.os.Parcelable.Creator
                public Object createFromParcel(Parcel parcel) {
                    return new a(parcel, null);
                }

                @Override // android.os.Parcelable.Creator
                public Object[] newArray(int i2) {
                    return new a[i2];
                }

                @Override // android.os.Parcelable.ClassLoaderCreator
                public a createFromParcel(Parcel parcel, ClassLoader classLoader) {
                    return new a(parcel, classLoader);
                }
            }

            public a(Parcel parcel, ClassLoader classLoader) {
                super(parcel, classLoader);
                this.f1000n = parcel.readInt();
                this.f1001o = parcel.readFloat();
                this.f1002p = parcel.readByte() != 0;
            }

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

            @Override // d.j.a.a, android.os.Parcelable
            public void writeToParcel(Parcel parcel, int i2) {
                parcel.writeParcelable(this.f2846m, i2);
                parcel.writeInt(this.f1000n);
                parcel.writeFloat(this.f1001o);
                parcel.writeByte(this.f1002p ? (byte) 1 : (byte) 0);
            }
        }

        public BaseBehavior() {
            this.f996m = -1;
        }

        public BaseBehavior(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f996m = -1;
        }

        public static boolean J(int i2, int i3) {
            return (i2 & i3) == i3;
        }

        @Override // g.e.a.a.d.e
        public int E() {
            return B() + this.f993j;
        }

        /* JADX WARN: Removed duplicated region for block: B:40:0x00b2  */
        /* JADX WARN: Removed duplicated region for block: B:46:0x00d4  */
        /* JADX WARN: Removed duplicated region for block: B:48:0x00db  */
        /* JADX WARN: Removed duplicated region for block: B:49:0x00dd  */
        @Override // g.e.a.a.d.e
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public int H(androidx.coordinatorlayout.widget.CoordinatorLayout r8, android.view.View r9, int r10, int r11, int r12) {
            /*
                Method dump skipped, instruction units count: 238
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.AppBarLayout.BaseBehavior.H(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, int, int, int):int");
        }

        public final void I(CoordinatorLayout coordinatorLayout, T t2, int i2, float f2) {
            int iAbs = Math.abs(E() - i2);
            float fAbs = Math.abs(f2);
            int iRound = fAbs > 0.0f ? Math.round((iAbs / fAbs) * 1000.0f) * 3 : (int) (((iAbs / t2.getHeight()) + 1.0f) * 150.0f);
            int iE = E();
            if (iE == i2) {
                ValueAnimator valueAnimator = this.f995l;
                if (valueAnimator == null || !valueAnimator.isRunning()) {
                    return;
                }
                this.f995l.cancel();
                return;
            }
            ValueAnimator valueAnimator2 = this.f995l;
            if (valueAnimator2 == null) {
                ValueAnimator valueAnimator3 = new ValueAnimator();
                this.f995l = valueAnimator3;
                valueAnimator3.setInterpolator(g.e.a.a.c.a.f3569e);
                this.f995l.addUpdateListener(new b(this, coordinatorLayout, t2));
            } else {
                valueAnimator2.cancel();
            }
            this.f995l.setDuration(Math.min(iRound, 600));
            this.f995l.setIntValues(iE, i2);
            this.f995l.start();
        }

        public final View K(CoordinatorLayout coordinatorLayout) {
            int childCount = coordinatorLayout.getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = coordinatorLayout.getChildAt(i2);
                if ((childAt instanceof l) || (childAt instanceof ListView) || (childAt instanceof ScrollView)) {
                    return childAt;
                }
            }
            return null;
        }

        public void L(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i2, int[] iArr) {
            int i3;
            int downNestedPreScrollRange;
            if (i2 != 0) {
                if (i2 < 0) {
                    i3 = -appBarLayout.getTotalScrollRange();
                    downNestedPreScrollRange = appBarLayout.getDownNestedPreScrollRange() + i3;
                } else {
                    i3 = -appBarLayout.getUpNestedPreScrollRange();
                    downNestedPreScrollRange = 0;
                }
                int i4 = i3;
                int i5 = downNestedPreScrollRange;
                if (i4 != i5) {
                    iArr[1] = F(coordinatorLayout, appBarLayout, i2, i4, i5);
                }
            }
            if (appBarLayout.f987t) {
                appBarLayout.c(appBarLayout.d(view));
            }
        }

        public void M(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i2, int[] iArr) {
            if (i2 < 0) {
                iArr[1] = F(coordinatorLayout, appBarLayout, i2, -appBarLayout.getDownNestedScrollRange(), 0);
            }
            if (i2 == 0) {
                P(coordinatorLayout, appBarLayout);
            }
        }

        /* JADX WARN: Removed duplicated region for block: B:17:0x002a  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public boolean N(androidx.coordinatorlayout.widget.CoordinatorLayout r3, com.google.android.material.appbar.AppBarLayout r4, android.view.View r5, int r6, int r7) {
            /*
                r2 = this;
                r6 = r6 & 2
                r0 = 1
                r1 = 0
                if (r6 == 0) goto L2a
                boolean r6 = r4.f987t
                if (r6 != 0) goto L2b
                int r6 = r4.getTotalScrollRange()
                if (r6 == 0) goto L12
                r6 = r0
                goto L13
            L12:
                r6 = r1
            L13:
                if (r6 == 0) goto L26
                int r3 = r3.getHeight()
                int r5 = r5.getHeight()
                int r3 = r3 - r5
                int r4 = r4.getHeight()
                if (r3 > r4) goto L26
                r3 = r0
                goto L27
            L26:
                r3 = r1
            L27:
                if (r3 == 0) goto L2a
                goto L2b
            L2a:
                r0 = r1
            L2b:
                if (r0 == 0) goto L34
                android.animation.ValueAnimator r3 = r2.f995l
                if (r3 == 0) goto L34
                r3.cancel()
            L34:
                r3 = 0
                r2.f999p = r3
                r2.f994k = r7
                return r0
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.AppBarLayout.BaseBehavior.N(androidx.coordinatorlayout.widget.CoordinatorLayout, com.google.android.material.appbar.AppBarLayout, android.view.View, int, int):boolean");
        }

        public final void O(CoordinatorLayout coordinatorLayout, T t2) {
            int iE = E();
            int childCount = t2.getChildCount();
            int i2 = 0;
            while (true) {
                if (i2 >= childCount) {
                    i2 = -1;
                    break;
                }
                View childAt = t2.getChildAt(i2);
                int top = childAt.getTop();
                int bottom = childAt.getBottom();
                a aVar = (a) childAt.getLayoutParams();
                if (J(aVar.a, 32)) {
                    top -= ((LinearLayout.LayoutParams) aVar).topMargin;
                    bottom += ((LinearLayout.LayoutParams) aVar).bottomMargin;
                }
                int i3 = -iE;
                if (top <= i3 && bottom >= i3) {
                    break;
                } else {
                    i2++;
                }
            }
            if (i2 >= 0) {
                View childAt2 = t2.getChildAt(i2);
                a aVar2 = (a) childAt2.getLayoutParams();
                int i4 = aVar2.a;
                if ((i4 & 17) == 17) {
                    int i5 = -childAt2.getTop();
                    int iD = -childAt2.getBottom();
                    if (i2 == t2.getChildCount() - 1) {
                        iD += t2.getTopInset();
                    }
                    if (J(i4, 2)) {
                        AtomicInteger atomicInteger = y.a;
                        iD += y.c.d(childAt2);
                    } else if (J(i4, 5)) {
                        AtomicInteger atomicInteger2 = y.a;
                        int iD2 = y.c.d(childAt2) + iD;
                        if (iE < iD2) {
                            i5 = iD2;
                        } else {
                            iD = iD2;
                        }
                    }
                    if (J(i4, 32)) {
                        i5 += ((LinearLayout.LayoutParams) aVar2).topMargin;
                        iD -= ((LinearLayout.LayoutParams) aVar2).bottomMargin;
                    }
                    if (iE < (iD + i5) / 2) {
                        i5 = iD;
                    }
                    I(coordinatorLayout, t2, h.g(i5, -t2.getTotalScrollRange(), 0), 0.0f);
                }
            }
        }

        public final void P(CoordinatorLayout coordinatorLayout, T t2) {
            c.a aVar = c.a.f2771b;
            y.m(aVar.a(), coordinatorLayout);
            y.j(coordinatorLayout, 0);
            c.a aVar2 = c.a.f2772c;
            y.m(aVar2.a(), coordinatorLayout);
            y.j(coordinatorLayout, 0);
            View viewK = K(coordinatorLayout);
            if (viewK == null || t2.getTotalScrollRange() == 0 || !(((CoordinatorLayout.f) viewK.getLayoutParams()).a instanceof ScrollingViewBehavior)) {
                return;
            }
            if (E() != (-t2.getTotalScrollRange()) && viewK.canScrollVertically(1)) {
                y.n(coordinatorLayout, aVar, null, new d(this, t2, false));
            }
            if (E() != 0) {
                if (!viewK.canScrollVertically(-1)) {
                    y.n(coordinatorLayout, aVar2, null, new d(this, t2, true));
                    return;
                }
                int i2 = -t2.getDownNestedPreScrollRange();
                if (i2 != 0) {
                    y.n(coordinatorLayout, aVar2, null, new g.e.a.a.d.c(this, coordinatorLayout, t2, viewK, i2));
                }
            }
        }

        /* JADX WARN: Removed duplicated region for block: B:26:0x005d  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public final void Q(androidx.coordinatorlayout.widget.CoordinatorLayout r7, T r8, int r9, int r10, boolean r11) {
            /*
                r6 = this;
                int r0 = java.lang.Math.abs(r9)
                int r1 = r8.getChildCount()
                r2 = 0
                r3 = r2
            La:
                if (r3 >= r1) goto L20
                android.view.View r4 = r8.getChildAt(r3)
                int r5 = r4.getTop()
                if (r0 < r5) goto L1d
                int r5 = r4.getBottom()
                if (r0 > r5) goto L1d
                goto L21
            L1d:
                int r3 = r3 + 1
                goto La
            L20:
                r4 = 0
            L21:
                if (r4 == 0) goto L9f
                android.view.ViewGroup$LayoutParams r0 = r4.getLayoutParams()
                com.google.android.material.appbar.AppBarLayout$a r0 = (com.google.android.material.appbar.AppBarLayout.a) r0
                int r0 = r0.a
                r1 = r0 & 1
                r3 = 1
                if (r1 == 0) goto L5d
                java.util.concurrent.atomic.AtomicInteger r1 = d.h.j.y.a
                int r1 = d.h.j.y.c.d(r4)
                if (r10 <= 0) goto L4a
                r10 = r0 & 12
                if (r10 == 0) goto L4a
                int r9 = -r9
                int r10 = r4.getBottom()
                int r10 = r10 - r1
                int r0 = r8.getTopInset()
                int r10 = r10 - r0
                if (r9 < r10) goto L5d
                goto L5b
            L4a:
                r10 = r0 & 2
                if (r10 == 0) goto L5d
                int r9 = -r9
                int r10 = r4.getBottom()
                int r10 = r10 - r1
                int r0 = r8.getTopInset()
                int r10 = r10 - r0
                if (r9 < r10) goto L5d
            L5b:
                r9 = r3
                goto L5e
            L5d:
                r9 = r2
            L5e:
                boolean r10 = r8.f987t
                if (r10 == 0) goto L6a
                android.view.View r9 = r6.K(r7)
                boolean r9 = r8.d(r9)
            L6a:
                boolean r9 = r8.c(r9)
                if (r11 != 0) goto L9c
                if (r9 == 0) goto L9f
                java.util.List r7 = r7.e(r8)
                int r9 = r7.size()
                r10 = r2
            L7b:
                if (r10 >= r9) goto L9a
                java.lang.Object r11 = r7.get(r10)
                android.view.View r11 = (android.view.View) r11
                android.view.ViewGroup$LayoutParams r11 = r11.getLayoutParams()
                androidx.coordinatorlayout.widget.CoordinatorLayout$f r11 = (androidx.coordinatorlayout.widget.CoordinatorLayout.f) r11
                androidx.coordinatorlayout.widget.CoordinatorLayout$c r11 = r11.a
                boolean r0 = r11 instanceof com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior
                if (r0 == 0) goto L97
                com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior r11 = (com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior) r11
                int r7 = r11.f3599f
                if (r7 == 0) goto L9a
                r2 = r3
                goto L9a
            L97:
                int r10 = r10 + 1
                goto L7b
            L9a:
                if (r2 == 0) goto L9f
            L9c:
                r8.jumpDrawablesToCurrentState()
            L9f:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.AppBarLayout.BaseBehavior.Q(androidx.coordinatorlayout.widget.CoordinatorLayout, com.google.android.material.appbar.AppBarLayout, int, int, boolean):void");
        }

        @Override // g.e.a.a.d.g, androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean k(CoordinatorLayout coordinatorLayout, View view, int i2) {
            int iRound;
            AppBarLayout appBarLayout = (AppBarLayout) view;
            super.k(coordinatorLayout, appBarLayout, i2);
            int pendingAction = appBarLayout.getPendingAction();
            int i3 = this.f996m;
            if (i3 >= 0 && (pendingAction & 8) == 0) {
                View childAt = appBarLayout.getChildAt(i3);
                int i4 = -childAt.getBottom();
                if (this.f997n) {
                    AtomicInteger atomicInteger = y.a;
                    iRound = appBarLayout.getTopInset() + y.c.d(childAt) + i4;
                } else {
                    iRound = Math.round(childAt.getHeight() * this.f998o) + i4;
                }
                G(coordinatorLayout, appBarLayout, iRound);
            } else if (pendingAction != 0) {
                boolean z2 = (pendingAction & 4) != 0;
                if ((pendingAction & 2) != 0) {
                    int i5 = -appBarLayout.getUpNestedPreScrollRange();
                    if (z2) {
                        I(coordinatorLayout, appBarLayout, i5, 0.0f);
                    } else {
                        G(coordinatorLayout, appBarLayout, i5);
                    }
                } else if ((pendingAction & 1) != 0) {
                    if (z2) {
                        I(coordinatorLayout, appBarLayout, 0, 0.0f);
                    } else {
                        G(coordinatorLayout, appBarLayout, 0);
                    }
                }
            }
            appBarLayout.f984q = 0;
            this.f996m = -1;
            D(h.g(B(), -appBarLayout.getTotalScrollRange(), 0));
            Q(coordinatorLayout, appBarLayout, B(), 0, true);
            appBarLayout.f979f = B();
            if (!appBarLayout.willNotDraw()) {
                AtomicInteger atomicInteger2 = y.a;
                y.c.k(appBarLayout);
            }
            P(coordinatorLayout, appBarLayout);
            return true;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean l(CoordinatorLayout coordinatorLayout, View view, int i2, int i3, int i4, int i5) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            if (((ViewGroup.MarginLayoutParams) ((CoordinatorLayout.f) appBarLayout.getLayoutParams())).height != -2) {
                return false;
            }
            coordinatorLayout.s(appBarLayout, i2, i3, View.MeasureSpec.makeMeasureSpec(0, 0), i5);
            return true;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ void p(CoordinatorLayout coordinatorLayout, View view, View view2, int i2, int i3, int[] iArr, int i4) {
            L(coordinatorLayout, (AppBarLayout) view, view2, i3, iArr);
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ void r(CoordinatorLayout coordinatorLayout, View view, View view2, int i2, int i3, int i4, int i5, int i6, int[] iArr) {
            M(coordinatorLayout, (AppBarLayout) view, i5, iArr);
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public void u(CoordinatorLayout coordinatorLayout, View view, Parcelable parcelable) {
            if (!(parcelable instanceof a)) {
                this.f996m = -1;
                return;
            }
            a aVar = (a) parcelable;
            this.f996m = aVar.f1000n;
            this.f998o = aVar.f1001o;
            this.f997n = aVar.f1002p;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public Parcelable v(CoordinatorLayout coordinatorLayout, View view) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            AbsSavedState absSavedState = View.BaseSavedState.EMPTY_STATE;
            int iB = B();
            int childCount = appBarLayout.getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = appBarLayout.getChildAt(i2);
                int bottom = childAt.getBottom() + iB;
                if (childAt.getTop() + iB <= 0 && bottom >= 0) {
                    a aVar = new a(absSavedState);
                    aVar.f1000n = i2;
                    AtomicInteger atomicInteger = y.a;
                    aVar.f1002p = bottom == appBarLayout.getTopInset() + y.c.d(childAt);
                    aVar.f1001o = bottom / childAt.getHeight();
                    return aVar;
                }
            }
            return absSavedState;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public /* bridge */ /* synthetic */ boolean x(CoordinatorLayout coordinatorLayout, View view, View view2, View view3, int i2, int i3) {
            return N(coordinatorLayout, (AppBarLayout) view, view2, i2, i3);
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public void z(CoordinatorLayout coordinatorLayout, View view, View view2, int i2) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            if (this.f994k == 0 || i2 == 1) {
                O(coordinatorLayout, appBarLayout);
                if (appBarLayout.f987t) {
                    appBarLayout.c(appBarLayout.d(view2));
                }
            }
            this.f999p = new WeakReference<>(view2);
        }
    }

    public static class Behavior extends BaseBehavior<AppBarLayout> {
        public Behavior() {
        }

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

    public static class ScrollingViewBehavior extends f {
        public ScrollingViewBehavior() {
        }

        public ScrollingViewBehavior(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, g.e.a.a.b.f3558w);
            this.f3599f = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, 0);
            typedArrayObtainStyledAttributes.recycle();
        }

        public AppBarLayout F(List<View> list) {
            int size = list.size();
            for (int i2 = 0; i2 < size; i2++) {
                View view = list.get(i2);
                if (view instanceof AppBarLayout) {
                    return (AppBarLayout) view;
                }
            }
            return null;
        }

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

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean g(CoordinatorLayout coordinatorLayout, View view, View view2) {
            CoordinatorLayout.c cVar = ((CoordinatorLayout.f) view2.getLayoutParams()).a;
            if (cVar instanceof BaseBehavior) {
                int bottom = (((view2.getBottom() - view.getTop()) + ((BaseBehavior) cVar).f993j) + this.f3598e) - E(view2);
                AtomicInteger atomicInteger = y.a;
                view.offsetTopAndBottom(bottom);
            }
            if (!(view2 instanceof AppBarLayout)) {
                return false;
            }
            AppBarLayout appBarLayout = (AppBarLayout) view2;
            if (!appBarLayout.f987t) {
                return false;
            }
            appBarLayout.c(appBarLayout.d(view));
            return false;
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public void h(CoordinatorLayout coordinatorLayout, View view, View view2) {
            if (view2 instanceof AppBarLayout) {
                y.m(c.a.f2771b.a(), coordinatorLayout);
                y.j(coordinatorLayout, 0);
                y.m(c.a.f2772c.a(), coordinatorLayout);
                y.j(coordinatorLayout, 0);
            }
        }

        @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
        public boolean t(CoordinatorLayout coordinatorLayout, View view, Rect rect, boolean z2) {
            AppBarLayout appBarLayoutF = F(coordinatorLayout.d(view));
            if (appBarLayoutF != null) {
                rect.offset(view.getLeft(), view.getTop());
                Rect rect2 = this.f3596c;
                rect2.set(0, 0, coordinatorLayout.getWidth(), coordinatorLayout.getHeight());
                if (!rect2.contains(rect)) {
                    appBarLayoutF.b(false, !z2);
                    return true;
                }
            }
            return false;
        }
    }

    public static class a extends LinearLayout.LayoutParams {
        public int a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public Interpolator f1003b;

        public a(int i2, int i3) {
            super(i2, i3);
            this.a = 1;
        }

        public a(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.a = 1;
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, g.e.a.a.b.a);
            this.a = typedArrayObtainStyledAttributes.getInt(0, 0);
            if (typedArrayObtainStyledAttributes.hasValue(1)) {
                this.f1003b = AnimationUtils.loadInterpolator(context, typedArrayObtainStyledAttributes.getResourceId(1, 0));
            }
            typedArrayObtainStyledAttributes.recycle();
        }

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

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

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

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

    public void b(boolean z2, boolean z3) {
        this.f984q = (z2 ? 1 : 2) | (z3 ? 4 : 0) | 8;
        requestLayout();
    }

    public boolean c(boolean z2) {
        if (this.f986s == z2) {
            return false;
        }
        this.f986s = z2;
        refreshDrawableState();
        if (this.f987t && (getBackground() instanceof g)) {
            g gVar = (g) getBackground();
            float dimension = getResources().getDimension(R.dimen.design_appbar_elevation);
            float f2 = z2 ? 0.0f : dimension;
            if (!z2) {
                dimension = 0.0f;
            }
            ValueAnimator valueAnimator = this.f990w;
            if (valueAnimator != null) {
                valueAnimator.cancel();
            }
            ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(f2, dimension);
            this.f990w = valueAnimatorOfFloat;
            valueAnimatorOfFloat.setDuration(getResources().getInteger(R.integer.app_bar_elevation_anim_duration));
            this.f990w.setInterpolator(g.e.a.a.c.a.a);
            this.f990w.addUpdateListener(new g.e.a.a.d.a(this, gVar));
            this.f990w.start();
        }
        return true;
    }

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

    public boolean d(View view) {
        int i2;
        if (this.f989v == null && (i2 = this.f988u) != -1) {
            View viewFindViewById = view != null ? view.findViewById(i2) : null;
            if (viewFindViewById == null && (getParent() instanceof ViewGroup)) {
                viewFindViewById = ((ViewGroup) getParent()).findViewById(this.f988u);
            }
            if (viewFindViewById != null) {
                this.f989v = new WeakReference<>(viewFindViewById);
            }
        }
        WeakReference<View> weakReference = this.f989v;
        View view2 = weakReference != null ? weakReference.get() : null;
        if (view2 != null) {
            view = view2;
        }
        return view != null && (view.canScrollVertically(-1) || view.getScrollY() > 0);
    }

    @Override // android.view.View
    public void draw(Canvas canvas) {
        super.draw(canvas);
        if (this.f992y != null && getTopInset() > 0) {
            int iSave = canvas.save();
            canvas.translate(0.0f, -this.f979f);
            this.f992y.draw(canvas);
            canvas.restoreToCount(iSave);
        }
    }

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

    public final boolean e() {
        if (getChildCount() <= 0) {
            return false;
        }
        View childAt = getChildAt(0);
        if (childAt.getVisibility() == 8) {
            return false;
        }
        AtomicInteger atomicInteger = y.a;
        return !y.c.b(childAt);
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return new a(-1, -2);
    }

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

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.b
    public CoordinatorLayout.c<AppBarLayout> getBehavior() {
        return new Behavior();
    }

    public int getDownNestedPreScrollRange() {
        int iD;
        int i2 = this.f981n;
        if (i2 != -1) {
            return i2;
        }
        int i3 = 0;
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = getChildAt(childCount);
            a aVar = (a) childAt.getLayoutParams();
            int measuredHeight = childAt.getMeasuredHeight();
            int i4 = aVar.a;
            if ((i4 & 5) != 5) {
                if (i3 > 0) {
                    break;
                }
            } else {
                int i5 = ((LinearLayout.LayoutParams) aVar).topMargin + ((LinearLayout.LayoutParams) aVar).bottomMargin;
                if ((i4 & 8) != 0) {
                    AtomicInteger atomicInteger = y.a;
                    iD = i5 + y.c.d(childAt);
                } else if ((i4 & 2) != 0) {
                    AtomicInteger atomicInteger2 = y.a;
                    iD = i5 + (measuredHeight - y.c.d(childAt));
                } else {
                    iD = i5 + measuredHeight;
                }
                if (childCount == 0) {
                    AtomicInteger atomicInteger3 = y.a;
                    if (y.c.b(childAt)) {
                        iD = Math.min(iD, measuredHeight - getTopInset());
                    }
                }
                i3 += iD;
            }
        }
        int iMax = Math.max(0, i3);
        this.f981n = iMax;
        return iMax;
    }

    public int getDownNestedScrollRange() {
        int i2 = this.f982o;
        if (i2 != -1) {
            return i2;
        }
        int childCount = getChildCount();
        int i3 = 0;
        int iD = 0;
        while (true) {
            if (i3 >= childCount) {
                break;
            }
            View childAt = getChildAt(i3);
            a aVar = (a) childAt.getLayoutParams();
            int measuredHeight = ((LinearLayout.LayoutParams) aVar).topMargin + ((LinearLayout.LayoutParams) aVar).bottomMargin + childAt.getMeasuredHeight();
            int i4 = aVar.a;
            if ((i4 & 1) == 0) {
                break;
            }
            iD += measuredHeight;
            if ((i4 & 2) != 0) {
                AtomicInteger atomicInteger = y.a;
                iD -= y.c.d(childAt);
                break;
            }
            i3++;
        }
        int iMax = Math.max(0, iD);
        this.f982o = iMax;
        return iMax;
    }

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

    public final int getMinimumHeightForVisibleOverlappingContent() {
        int topInset = getTopInset();
        AtomicInteger atomicInteger = y.a;
        int iD = y.c.d(this);
        if (iD == 0) {
            int childCount = getChildCount();
            iD = childCount >= 1 ? y.c.d(getChildAt(childCount - 1)) : 0;
            if (iD == 0) {
                return getHeight() / 3;
            }
        }
        return (iD * 2) + topInset;
    }

    public int getPendingAction() {
        return this.f984q;
    }

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

    @Deprecated
    public float getTargetElevation() {
        return 0.0f;
    }

    public final int getTopInset() {
        return 0;
    }

    public final int getTotalScrollRange() {
        int i2 = this.f980m;
        if (i2 != -1) {
            return i2;
        }
        int childCount = getChildCount();
        int i3 = 0;
        int iD = 0;
        while (true) {
            if (i3 >= childCount) {
                break;
            }
            View childAt = getChildAt(i3);
            a aVar = (a) childAt.getLayoutParams();
            int measuredHeight = childAt.getMeasuredHeight();
            int i4 = aVar.a;
            if ((i4 & 1) == 0) {
                break;
            }
            int topInset = measuredHeight + ((LinearLayout.LayoutParams) aVar).topMargin + ((LinearLayout.LayoutParams) aVar).bottomMargin + iD;
            if (i3 == 0) {
                AtomicInteger atomicInteger = y.a;
                if (y.c.b(childAt)) {
                    topInset -= getTopInset();
                }
            }
            iD = topInset;
            if ((i4 & 2) != 0) {
                AtomicInteger atomicInteger2 = y.a;
                iD -= y.c.d(childAt);
                break;
            }
            i3++;
        }
        int iMax = Math.max(0, iD);
        this.f980m = iMax;
        return iMax;
    }

    public int getUpNestedPreScrollRange() {
        return getTotalScrollRange();
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Drawable background = getBackground();
        if (background instanceof g) {
            g.e.a.a.a.I(this, (g) background);
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public int[] onCreateDrawableState(int i2) {
        if (this.f991x == null) {
            this.f991x = new int[4];
        }
        int[] iArr = this.f991x;
        int[] iArrOnCreateDrawableState = super.onCreateDrawableState(i2 + iArr.length);
        boolean z2 = this.f985r;
        iArr[0] = z2 ? R.attr.state_liftable : -2130969383;
        iArr[1] = (z2 && this.f986s) ? R.attr.state_lifted : -2130969384;
        iArr[2] = z2 ? R.attr.state_collapsible : -2130969381;
        iArr[3] = (z2 && this.f986s) ? R.attr.state_collapsed : -2130969380;
        return LinearLayout.mergeDrawableStates(iArrOnCreateDrawableState, iArr);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        WeakReference<View> weakReference = this.f989v;
        if (weakReference != null) {
            weakReference.clear();
        }
        this.f989v = null;
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
    public void onLayout(boolean z2, int i2, int i3, int i4, int i5) {
        boolean z3;
        super.onLayout(z2, i2, i3, i4, i5);
        AtomicInteger atomicInteger = y.a;
        boolean z4 = true;
        if (y.c.b(this) && e()) {
            int topInset = getTopInset();
            for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
                getChildAt(childCount).offsetTopAndBottom(topInset);
            }
        }
        this.f980m = -1;
        this.f981n = -1;
        this.f982o = -1;
        this.f983p = false;
        int childCount2 = getChildCount();
        int i6 = 0;
        while (true) {
            if (i6 >= childCount2) {
                break;
            }
            if (((a) getChildAt(i6).getLayoutParams()).f1003b != null) {
                this.f983p = true;
                break;
            }
            i6++;
        }
        Drawable drawable = this.f992y;
        if (drawable != null) {
            drawable.setBounds(0, 0, getWidth(), getTopInset());
        }
        if (!this.f987t) {
            int childCount3 = getChildCount();
            int i7 = 0;
            while (true) {
                if (i7 >= childCount3) {
                    z3 = false;
                    break;
                }
                int i8 = ((a) getChildAt(i7).getLayoutParams()).a;
                if ((i8 & 1) == 1 && (i8 & 10) != 0) {
                    z3 = true;
                    break;
                }
                i7++;
            }
            if (!z3) {
                z4 = false;
            }
        }
        if (this.f985r != z4) {
            this.f985r = z4;
            refreshDrawableState();
        }
    }

    @Override // android.widget.LinearLayout, android.view.View
    public void onMeasure(int i2, int i3) {
        super.onMeasure(i2, i3);
        int mode = View.MeasureSpec.getMode(i3);
        if (mode != 1073741824) {
            AtomicInteger atomicInteger = y.a;
            if (y.c.b(this) && e()) {
                int measuredHeight = getMeasuredHeight();
                if (mode == Integer.MIN_VALUE) {
                    measuredHeight = h.g(getTopInset() + getMeasuredHeight(), 0, View.MeasureSpec.getSize(i3));
                } else if (mode == 0) {
                    measuredHeight += getTopInset();
                }
                setMeasuredDimension(getMeasuredWidth(), measuredHeight);
            }
        }
        this.f980m = -1;
        this.f981n = -1;
        this.f982o = -1;
    }

    @Override // android.view.View
    public void setElevation(float f2) {
        super.setElevation(f2);
        g.e.a.a.a.H(this, f2);
    }

    public void setExpanded(boolean z2) {
        AtomicInteger atomicInteger = y.a;
        b(z2, y.f.c(this));
    }

    public void setLiftOnScroll(boolean z2) {
        this.f987t = z2;
    }

    public void setLiftOnScrollTargetViewId(int i2) {
        this.f988u = i2;
        WeakReference<View> weakReference = this.f989v;
        if (weakReference != null) {
            weakReference.clear();
        }
        this.f989v = null;
    }

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

    public void setStatusBarForeground(Drawable drawable) {
        Drawable drawable2 = this.f992y;
        if (drawable2 != drawable) {
            if (drawable2 != null) {
                drawable2.setCallback(null);
            }
            Drawable drawableMutate = drawable != null ? drawable.mutate() : null;
            this.f992y = drawableMutate;
            boolean z2 = false;
            if (drawableMutate != null) {
                if (drawableMutate.isStateful()) {
                    this.f992y.setState(getDrawableState());
                }
                Drawable drawable3 = this.f992y;
                AtomicInteger atomicInteger = y.a;
                d.h.d.k.c.b(drawable3, y.d.d(this));
                this.f992y.setVisible(getVisibility() == 0, false);
                this.f992y.setCallback(this);
            }
            if (this.f992y != null && getTopInset() > 0) {
                z2 = true;
            }
            setWillNotDraw(true ^ z2);
            AtomicInteger atomicInteger2 = y.a;
            y.c.k(this);
        }
    }

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

    public void setStatusBarForegroundResource(int i2) {
        setStatusBarForeground(d.b.d.a.a.a(getContext(), i2));
    }

    @Deprecated
    public void setTargetElevation(float f2) {
        int integer = getResources().getInteger(R.integer.app_bar_elevation_anim_duration);
        StateListAnimator stateListAnimator = new StateListAnimator();
        long j2 = integer;
        stateListAnimator.addState(new int[]{android.R.attr.enabled, R.attr.state_liftable, -2130969384}, ObjectAnimator.ofFloat(this, "elevation", 0.0f).setDuration(j2));
        stateListAnimator.addState(new int[]{android.R.attr.enabled}, ObjectAnimator.ofFloat(this, "elevation", f2).setDuration(j2));
        stateListAnimator.addState(new int[0], ObjectAnimator.ofFloat(this, "elevation", 0.0f).setDuration(0L));
        setStateListAnimator(stateListAnimator);
    }

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

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

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public LinearLayout.LayoutParams generateDefaultLayoutParams() {
        return new a(-1, -2);
    }

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