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.Bitmap; 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.TextPaint; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.widget.FrameLayout; import androidx.appcompat.widget.Toolbar; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.material.appbar.AppBarLayout; import java.util.List; import o.C1007TnW; import o.C17052tZT; import o.CEQ; import o.InterfaceC8624dQw; import o.Tlu; import o.lql; import o.nMh; import o.weT; /* loaded from: classes2.dex */ public class CollapsingToolbarLayout extends FrameLayout { private static final int b = C17052tZT.NHB.Widget_Design_CollapsingToolbar; private final Rect A; private int B; private boolean C; private View D; private int E; private int H; final lql a; Drawable c; WindowInsetsCompat d; int e; private boolean f; private Drawable g; private weT h; private View i; private boolean j; private int k; private int l; private int m; private int n; /* renamed from: o, reason: collision with root package name */ private int f6466o; private AppBarLayout.ojQ p; private boolean q; private int r; private boolean s; private boolean t; private long u; private final TimeInterpolator v; private final TimeInterpolator w; private int x; private ValueAnimator y; private ViewGroup z; /* loaded from: classes2.dex */ public interface IeS extends InterfaceC8624dQw { } @Override // android.widget.FrameLayout, android.view.ViewGroup public /* bridge */ /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) { return generateLayoutParams(attributeSet); } public CollapsingToolbarLayout(Context context) { this(context, null); } public CollapsingToolbarLayout(Context context, AttributeSet attributeSet) { this(context, attributeSet, C17052tZT.IeS.collapsingToolbarLayoutStyle); } /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public CollapsingToolbarLayout(android.content.Context r13, android.util.AttributeSet r14, int r15) { /* Method dump skipped, instructions count: 482 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.CollapsingToolbarLayout.(android.content.Context, android.util.AttributeSet, int):void"); } @Override // android.view.ViewGroup, android.view.View protected void onAttachedToWindow() { super.onAttachedToWindow(); ViewParent parent = getParent(); if (parent instanceof AppBarLayout) { AppBarLayout appBarLayout = (AppBarLayout) parent; if (this.B == 1) { appBarLayout.setLiftOnScroll(false); } ViewCompat.a(this, ViewCompat.l(appBarLayout)); if (this.p == null) { this.p = new HBt(this); } appBarLayout.e(this.p); ViewCompat.J(this); } } @Override // android.view.ViewGroup, android.view.View protected void onDetachedFromWindow() { List list; ViewParent parent = getParent(); AppBarLayout.ojQ ojq = this.p; if (ojq != null && (parent instanceof AppBarLayout) && (list = ((AppBarLayout) parent).d) != null && ojq != null) { list.remove(ojq); } super.onDetachedFromWindow(); } @Override // android.view.View public void draw(Canvas canvas) { Drawable drawable; super.draw(canvas); e(); if (this.z == null && (drawable = this.g) != null && this.r > 0) { drawable.mutate().setAlpha(this.r); this.g.draw(canvas); } if (this.j && this.f) { if (this.z != null && this.g != null && this.r > 0 && this.B == 1 && this.a.d < this.a.n) { int save = canvas.save(); canvas.clipRect(this.g.getBounds(), Region.Op.DIFFERENCE); this.a.JN_(canvas); canvas.restoreToCount(save); } else { this.a.JN_(canvas); } } if (this.c == null || this.r <= 0) { return; } WindowInsetsCompat windowInsetsCompat = this.d; int i = windowInsetsCompat != null ? windowInsetsCompat.i() : 0; if (i > 0) { this.c.setBounds(0, -this.e, getWidth(), i - this.e); this.c.mutate().setAlpha(this.r); this.c.draw(canvas); } } @Override // android.view.View protected void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); this.a.JP_(configuration); } @Override // android.view.View protected void onSizeChanged(int i, int i2, int i3, int i4) { super.onSizeChanged(i, i2, i3, i4); Drawable drawable = this.g; if (drawable != null) { HU_(drawable, this.z, i, i2); } } private void e() { if (this.t) { ViewGroup viewGroup = null; this.z = null; this.D = null; int i = this.E; if (i != -1) { ViewGroup viewGroup2 = (ViewGroup) findViewById(i); this.z = viewGroup2; if (viewGroup2 != null) { ViewParent parent = viewGroup2.getParent(); View view = viewGroup2; while (parent != this && parent != null) { if (parent instanceof View) { view = (View) parent; } parent = parent.getParent(); view = view; } this.D = view; } } if (this.z == null) { int childCount = getChildCount(); for (int i2 = 0; i2 < childCount; i2++) { View childAt = getChildAt(i2); if ((childAt instanceof Toolbar) || (childAt instanceof android.widget.Toolbar)) { viewGroup = (ViewGroup) childAt; break; } } this.z = viewGroup; } c(); this.t = false; } } private void c() { View view; if (!this.j && (view = this.i) != null) { ViewParent parent = view.getParent(); if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(this.i); } } if (!this.j || this.z == null) { return; } if (this.i == null) { this.i = new View(getContext()); } if (this.i.getParent() == null) { this.z.addView(this.i, -1, -1); } } @Override // android.widget.FrameLayout, android.view.View protected void onMeasure(int i, int i2) { e(); super.onMeasure(i, i2); int mode = View.MeasureSpec.getMode(i2); WindowInsetsCompat windowInsetsCompat = this.d; int i3 = windowInsetsCompat != null ? windowInsetsCompat.i() : 0; if ((mode == 0 || this.q) && i3 > 0) { this.H = i3; super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + i3, 1073741824)); } if (this.s && this.a.p > 1) { b(); e(0, 0, getMeasuredWidth(), getMeasuredHeight(), true); int i4 = this.a.h; if (i4 > 1) { lql lqlVar = this.a; TextPaint textPaint = lqlVar.z; textPaint.setTextSize(lqlVar.f); textPaint.setTypeface(lqlVar.f9209o); textPaint.setLetterSpacing(lqlVar.g); this.k = Math.round((-lqlVar.z.ascent()) + lqlVar.z.descent()) * (i4 - 1); super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + this.k, 1073741824)); } } ViewGroup viewGroup = this.z; if (viewGroup != null) { View view = this.D; if (view == null || view == this) { setMinimumHeight(e(viewGroup)); } else { setMinimumHeight(e(view)); } } } @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View protected void onLayout(boolean z, int i, int i2, int i3, int i4) { super.onLayout(z, i, i2, i3, i4); WindowInsetsCompat windowInsetsCompat = this.d; if (windowInsetsCompat != null) { int i5 = windowInsetsCompat.i(); int childCount = getChildCount(); for (int i6 = 0; i6 < childCount; i6++) { View childAt = getChildAt(i6); if (!ViewCompat.l(childAt) && childAt.getTop() < i5) { ViewCompat.d(childAt, i5); } } } int childCount2 = getChildCount(); for (int i7 = 0; i7 < childCount2; i7++) { C1007TnW a = a(getChildAt(i7)); a.c = a.b.getTop(); a.d = a.b.getLeft(); } e(i, i2, i3, i4, false); b(); d(); int childCount3 = getChildCount(); for (int i8 = 0; i8 < childCount3; i8++) { a(getChildAt(i8)).d(); } } private void e(int i, int i2, int i3, int i4, boolean z) { View view; int i5; int i6; int i7; if (!this.j || (view = this.i) == null) { return; } int i8 = 0; boolean z2 = ViewCompat.H(view) && this.i.getVisibility() == 0; this.f = z2; if (z2 || z) { boolean z3 = ViewCompat.m(this) == 1; View view2 = this.D; if (view2 == null) { view2 = this.z; } int b2 = b(view2); View view3 = this.i; Rect rect = this.A; rect.set(0, 0, view3.getWidth(), view3.getHeight()); CEQ.JT_(this, view3, rect); ViewGroup viewGroup = this.z; if (viewGroup instanceof Toolbar) { Toolbar toolbar = (Toolbar) viewGroup; i8 = toolbar.p; i6 = toolbar.k; i7 = toolbar.r; i5 = toolbar.f6379o; } else if (viewGroup instanceof android.widget.Toolbar) { android.widget.Toolbar toolbar2 = (android.widget.Toolbar) viewGroup; i8 = toolbar2.getTitleMarginStart(); i6 = toolbar2.getTitleMarginEnd(); i7 = toolbar2.getTitleMarginTop(); i5 = toolbar2.getTitleMarginBottom(); } else { i5 = 0; i6 = 0; i7 = 0; } lql lqlVar = this.a; int i9 = this.A.left; int i10 = z3 ? i6 : i8; int i11 = this.A.top; int i12 = this.A.right; if (!z3) { i8 = i6; } lqlVar.a(i9 + i10, i11 + b2 + i7, i12 - i8, (this.A.bottom + b2) - i5); this.a.c(z3 ? this.m : this.l, this.A.top + this.n, (i3 - i) - (z3 ? this.l : this.m), (i4 - i2) - this.f6466o); this.a.c(z); } } private static int e(View view) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams; return view.getMeasuredHeight() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin; } return view.getMeasuredHeight(); } static C1007TnW a(View view) { C1007TnW c1007TnW = (C1007TnW) view.getTag(C17052tZT.ZqN.view_offset_helper); if (c1007TnW != null) { return c1007TnW; } C1007TnW c1007TnW2 = new C1007TnW(view); view.setTag(C17052tZT.ZqN.view_offset_helper, c1007TnW2); return c1007TnW2; } public void setTitle(CharSequence charSequence) { this.a.d(charSequence); setContentDescription(this.j ? this.a.v : null); } public void setTitleCollapseMode(int i) { this.B = i; boolean z = i == 1; this.a.l = z; ViewParent parent = getParent(); if (parent instanceof AppBarLayout) { AppBarLayout appBarLayout = (AppBarLayout) parent; if (this.B == 1) { appBarLayout.setLiftOnScroll(false); } } if (z && this.g == null) { float dimension = getResources().getDimension(C17052tZT.HBt.design_appbar_elevation); weT wet = this.h; setContentScrimColor(wet.c(wet.d, dimension)); } } public void setTitleEllipsize(TextUtils.TruncateAt truncateAt) { lql lqlVar = this.a; lqlVar.B = truncateAt; lqlVar.c(false); } public void setScrimsShown(boolean z) { setScrimsShown(z, ViewCompat.G(this) && !isInEditMode()); } final void b(int i) { ViewGroup viewGroup; if (i != this.r) { if (this.g != null && (viewGroup = this.z) != null) { ViewCompat.N(viewGroup); } this.r = i; ViewCompat.N(this); } } public void setContentScrim(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) { HU_(mutate, this.z, getWidth(), getHeight()); this.g.setCallback(this); this.g.setAlpha(this.r); } ViewCompat.N(this); } } public void setContentScrimColor(int i) { setContentScrim(new ColorDrawable(i)); } public void setContentScrimResource(int i) { setContentScrim(nMh.getDrawable(getContext(), i)); } public void setStatusBarScrim(Drawable drawable) { Drawable drawable2 = this.c; if (drawable2 != drawable) { if (drawable2 != null) { drawable2.setCallback(null); } Drawable mutate = drawable != null ? drawable.mutate() : null; this.c = mutate; if (mutate != null) { if (mutate.isStateful()) { this.c.setState(getDrawableState()); } Tlu.pD_(this.c, ViewCompat.m(this)); this.c.setVisible(getVisibility() == 0, false); this.c.setCallback(this); this.c.setAlpha(this.r); } ViewCompat.N(this); } } @Override // android.view.ViewGroup, android.view.View protected void drawableStateChanged() { super.drawableStateChanged(); int[] drawableState = getDrawableState(); Drawable drawable = this.c; boolean z = false; boolean state = (drawable == null || !drawable.isStateful()) ? false : drawable.setState(drawableState); Drawable drawable2 = this.g; if (drawable2 != null && drawable2.isStateful()) { state |= drawable2.setState(drawableState); } lql lqlVar = this.a; if (lqlVar != null) { lqlVar.w = drawableState; if (lqlVar.b()) { lqlVar.c(false); z = true; } state |= z; } if (state) { invalidate(); } } @Override // android.view.View protected boolean verifyDrawable(Drawable drawable) { return super.verifyDrawable(drawable) || drawable == this.g || drawable == this.c; } @Override // android.view.View public void setVisibility(int i) { super.setVisibility(i); boolean z = i == 0; Drawable drawable = this.c; if (drawable != null && drawable.isVisible() != z) { this.c.setVisible(z, false); } Drawable drawable2 = this.g; if (drawable2 == null || drawable2.isVisible() == z) { return; } this.g.setVisible(z, false); } public void setStatusBarScrimColor(int i) { setStatusBarScrim(new ColorDrawable(i)); } public void setStatusBarScrimResource(int i) { setStatusBarScrim(nMh.getDrawable(getContext(), i)); } public void setCollapsedTitleTextAppearance(int i) { this.a.a(i); } public void setCollapsedTitleTextColor(int i) { setCollapsedTitleTextColor(ColorStateList.valueOf(i)); } public void setCollapsedTitleTextColor(ColorStateList colorStateList) { lql lqlVar = this.a; if (lqlVar.e != colorStateList) { lqlVar.e = colorStateList; lqlVar.c(false); } } public void setCollapsedTitleGravity(int i) { lql lqlVar = this.a; if (lqlVar.b != i) { lqlVar.b = i; lqlVar.c(false); } } public void setExpandedTitleTextAppearance(int i) { this.a.b(i); } public void setExpandedTitleColor(int i) { setExpandedTitleTextColor(ColorStateList.valueOf(i)); } public void setExpandedTitleTextColor(ColorStateList colorStateList) { lql lqlVar = this.a; if (lqlVar.j != colorStateList) { lqlVar.j = colorStateList; lqlVar.c(false); } } public void setExpandedTitleGravity(int i) { lql lqlVar = this.a; if (lqlVar.i != i) { lqlVar.i = i; lqlVar.c(false); } } public void setExpandedTitleTextSize(float f) { lql lqlVar = this.a; if (lqlVar.f != f) { lqlVar.f = f; lqlVar.c(false); } } public void setCollapsedTitleTextSize(float f) { lql lqlVar = this.a; if (lqlVar.a != f) { lqlVar.a = f; lqlVar.c(false); } } public void setExpandedTitleMargin(int i, int i2, int i3, int i4) { this.l = i; this.n = i2; this.m = i3; this.f6466o = i4; requestLayout(); } public void setExpandedTitleMarginStart(int i) { this.l = i; requestLayout(); } public void setExpandedTitleMarginTop(int i) { this.n = i; requestLayout(); } public void setExpandedTitleMarginEnd(int i) { this.m = i; requestLayout(); } public void setExpandedTitleMarginBottom(int i) { this.f6466o = i; requestLayout(); } public void setMaxLines(int i) { lql lqlVar = this.a; if (i != lqlVar.p) { lqlVar.p = i; Bitmap bitmap = lqlVar.m; lqlVar.c(false); } } public void setStaticLayoutBuilderConfigurer(IeS ieS) { lql lqlVar = this.a; if (lqlVar.y != ieS) { lqlVar.y = ieS; lqlVar.c(true); } } public void setScrimVisibleHeightTrigger(int i) { if (this.x != i) { this.x = i; d(); } } public final int a() { int i = this.x; if (i >= 0) { return i + this.H + this.k; } WindowInsetsCompat windowInsetsCompat = this.d; int i2 = windowInsetsCompat != null ? windowInsetsCompat.i() : 0; int o2 = ViewCompat.o(this); if (o2 > 0) { return Math.min((o2 << 1) + i2, getHeight()); } return getHeight() / 3; } public void setTitlePositionInterpolator(TimeInterpolator timeInterpolator) { lql lqlVar = this.a; lqlVar.u = timeInterpolator; lqlVar.c(false); } @Override // android.widget.FrameLayout, android.view.ViewGroup protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) { return layoutParams instanceof RVV; } @Override // android.widget.FrameLayout, android.view.ViewGroup public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) { return new RVV(getContext(), attributeSet); } /* loaded from: classes2.dex */ public static class RVV extends FrameLayout.LayoutParams { int c; float d; public RVV(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.c = 0; this.d = 0.5f; TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C17052tZT.jNh.CollapsingToolbarLayout_Layout); this.c = obtainStyledAttributes.getInt(C17052tZT.jNh.CollapsingToolbarLayout_Layout_layout_collapseMode, 0); this.d = obtainStyledAttributes.getFloat(C17052tZT.jNh.CollapsingToolbarLayout_Layout_layout_collapseParallaxMultiplier, 0.5f); obtainStyledAttributes.recycle(); } public RVV() { super(-1, -1); this.c = 0; this.d = 0.5f; } public RVV(ViewGroup.LayoutParams layoutParams) { super(layoutParams); this.c = 0; this.d = 0.5f; } } final void d() { if (this.g == null && this.c == null) { return; } setScrimsShown(getHeight() + this.e < a()); } final int b(View view) { return ((getHeight() - a(view).c) - view.getHeight()) - ((ViewGroup.MarginLayoutParams) ((RVV) view.getLayoutParams())).bottomMargin; } /* loaded from: classes2.dex */ class HBt implements AppBarLayout.ojQ { private CollapsingToolbarLayout b; HBt(CollapsingToolbarLayout collapsingToolbarLayout) { this.b = collapsingToolbarLayout; } @Override // com.google.android.material.appbar.AppBarLayout.RVV public final void c(AppBarLayout appBarLayout, int i) { this.b.e = i; int i2 = this.b.d != null ? this.b.d.i() : 0; int childCount = this.b.getChildCount(); for (int i3 = 0; i3 < childCount; i3++) { View childAt = this.b.getChildAt(i3); RVV rvv = (RVV) childAt.getLayoutParams(); C1007TnW a = CollapsingToolbarLayout.a(childAt); int i4 = rvv.c; if (i4 == 1) { int i5 = -i; int b = this.b.b(childAt); if (i5 < 0) { i5 = 0; } else if (i5 > b) { i5 = b; } if (a.a && a.e != i5) { a.e = i5; a.d(); } } else if (i4 == 2) { int round = Math.round((-i) * rvv.d); if (a.a && a.e != round) { a.e = round; a.d(); } } } this.b.d(); if (this.b.c != null && i2 > 0) { ViewCompat.N(this.b); } int height = this.b.getHeight(); int o2 = (height - ViewCompat.o(this.b)) - i2; int a2 = this.b.a(); lql lqlVar = this.b.a; float f = height - a2; float f2 = o2; float f3 = 1.0f; lqlVar.k = Math.min(1.0f, f / f2); float f4 = lqlVar.k; lqlVar.n = f4 + ((1.0f - f4) * 0.5f); this.b.a.c = this.b.e + o2; lql lqlVar2 = this.b.a; float abs = Math.abs(i) / f2; if (abs < BitmapDescriptorFactory.HUE_RED) { f3 = 0.0f; } else if (abs <= 1.0f) { f3 = abs; } if (f3 != lqlVar2.d) { lqlVar2.d = f3; lqlVar2.b(lqlVar2.d); } } } private void HU_(Drawable drawable, View view, int i, int i2) { if (this.B == 1 && view != null && this.j) { i2 = view.getBottom(); } drawable.setBounds(0, 0, i, i2); } private void b() { CharSequence title; if (this.z != null && this.j && TextUtils.isEmpty(this.a.v)) { ViewGroup viewGroup = this.z; if (!(viewGroup instanceof Toolbar)) { title = viewGroup instanceof android.widget.Toolbar ? ((android.widget.Toolbar) viewGroup).getTitle() : null; } else { title = ((Toolbar) viewGroup).q; } setTitle(title); } } @Override // android.view.ViewGroup protected boolean drawChild(Canvas canvas, View view, long j) { boolean z; View view2; Drawable drawable = this.g; if (drawable == null || this.r <= 0 || ((view2 = this.D) == null || view2 == this ? view != this.z : view != view2)) { z = false; } else { HU_(drawable, view, getWidth(), getHeight()); this.g.mutate().setAlpha(this.r); this.g.draw(canvas); z = true; } return super.drawChild(canvas, view, j) || z; } @Override // android.widget.FrameLayout, android.view.ViewGroup protected /* synthetic */ ViewGroup.LayoutParams generateDefaultLayoutParams() { return new RVV(); } @Override // android.widget.FrameLayout, android.view.ViewGroup protected /* synthetic */ FrameLayout.LayoutParams generateDefaultLayoutParams() { return new RVV(); } @Override // android.widget.FrameLayout, android.view.ViewGroup protected /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) { return new RVV(layoutParams); } public void setHyphenationFrequency(int i) { this.a.q = i; } public void setLineSpacingAdd(float f) { this.a.s = f; } public void setLineSpacingMultiplier(float f) { this.a.r = f; } public void setRtlTextDirectionHeuristicsEnabled(boolean z) { this.a.t = z; } public void setCollapsedTitleTypeface(Typeface typeface) { lql lqlVar = this.a; if (lqlVar.JL_(typeface)) { lqlVar.c(false); } } public void setExpandedTitleTypeface(Typeface typeface) { lql lqlVar = this.a; if (lqlVar.JM_(typeface)) { lqlVar.c(false); } } public void setScrimsShown(boolean z, boolean z2) { if (this.C != z) { if (!z2) { b(z ? 255 : 0); } else { int i = z ? 255 : 0; e(); ValueAnimator valueAnimator = this.y; if (valueAnimator == null) { ValueAnimator valueAnimator2 = new ValueAnimator(); this.y = valueAnimator2; valueAnimator2.setInterpolator(i > this.r ? this.v : this.w); this.y.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(this) { // from class: com.google.android.material.appbar.CollapsingToolbarLayout.5 private CollapsingToolbarLayout a; { this.a = this; } @Override // android.animation.ValueAnimator.AnimatorUpdateListener public final void onAnimationUpdate(ValueAnimator valueAnimator3) { this.a.b(((Integer) valueAnimator3.getAnimatedValue()).intValue()); } }); } else if (valueAnimator.isRunning()) { this.y.cancel(); } this.y.setDuration(this.u); this.y.setIntValues(this.r, i); this.y.start(); } this.C = z; } } public void setTitleEnabled(boolean z) { if (z != this.j) { this.j = z; setContentDescription(z ? this.a.v : null); c(); requestLayout(); } } public void setScrimAnimationDuration(long j) { this.u = j; } public void setForceApplySystemWindowInsetTop(boolean z) { this.q = z; } public void setExtraMultilineHeightEnabled(boolean z) { this.s = z; } }