package com.google.android.material.internal; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.Gravity; import androidx.appcompat.widget.LinearLayoutCompat; import o.C17052tZT; import o.uqW; /* loaded from: classes2.dex */ public class ForegroundLinearLayout extends LinearLayoutCompat { private int a; private boolean b; private boolean c; private Drawable d; private final Rect e; private final Rect f; public ForegroundLinearLayout(Context context) { this(context, null); } public ForegroundLinearLayout(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public ForegroundLinearLayout(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.f = new Rect(); this.e = new Rect(); this.a = 119; this.b = true; this.c = false; int[] iArr = C17052tZT.jNh.ForegroundLinearLayout; uqW.Kb_(context, attributeSet, i, 0); uqW.Kc_(context, attributeSet, iArr, i, 0, new int[0]); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, i, 0); this.a = obtainStyledAttributes.getInt(C17052tZT.jNh.ForegroundLinearLayout_android_foregroundGravity, this.a); Drawable drawable = obtainStyledAttributes.getDrawable(C17052tZT.jNh.ForegroundLinearLayout_android_foreground); if (drawable != null) { setForeground(drawable); } this.b = obtainStyledAttributes.getBoolean(C17052tZT.jNh.ForegroundLinearLayout_foregroundInsidePadding, true); obtainStyledAttributes.recycle(); } @Override // android.view.View public void setForegroundGravity(int i) { if (this.a != i) { if ((8388615 & i) == 0) { i |= 8388611; } if ((i & 112) == 0) { i |= 48; } this.a = i; if (i == 119 && this.d != null) { this.d.getPadding(new Rect()); } requestLayout(); } } @Override // android.view.View protected boolean verifyDrawable(Drawable drawable) { return super.verifyDrawable(drawable) || drawable == this.d; } @Override // android.view.ViewGroup, android.view.View public void jumpDrawablesToCurrentState() { super.jumpDrawablesToCurrentState(); Drawable drawable = this.d; if (drawable != null) { drawable.jumpToCurrentState(); } } @Override // android.view.ViewGroup, android.view.View protected void drawableStateChanged() { super.drawableStateChanged(); Drawable drawable = this.d; if (drawable == null || !drawable.isStateful()) { return; } this.d.setState(getDrawableState()); } @Override // android.view.View public void setForeground(Drawable drawable) { Drawable drawable2 = this.d; if (drawable2 != drawable) { if (drawable2 != null) { drawable2.setCallback(null); unscheduleDrawable(this.d); } this.d = drawable; this.c = true; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (this.a == 119) { drawable.getPadding(new Rect()); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } } @Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup, android.view.View public void onLayout(boolean z, int i, int i2, int i3, int i4) { super.onLayout(z, i, i2, i3, i4); this.c = z | this.c; } @Override // android.view.View protected void onSizeChanged(int i, int i2, int i3, int i4) { super.onSizeChanged(i, i2, i3, i4); this.c = true; } @Override // android.view.View public void draw(Canvas canvas) { super.draw(canvas); Drawable drawable = this.d; if (drawable != null) { if (this.c) { this.c = false; Rect rect = this.f; Rect rect2 = this.e; int right = getRight() - getLeft(); int bottom = getBottom() - getTop(); if (this.b) { rect.set(0, 0, right, bottom); } else { rect.set(getPaddingLeft(), getPaddingTop(), right - getPaddingRight(), bottom - getPaddingBottom()); } Gravity.apply(this.a, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), rect, rect2); drawable.setBounds(rect2); } drawable.draw(canvas); } } @Override // android.view.View public void drawableHotspotChanged(float f, float f2) { super.drawableHotspotChanged(f, f2); Drawable drawable = this.d; if (drawable != null) { drawable.setHotspot(f, f2); } } @Override // android.view.View public int getForegroundGravity() { return this.a; } @Override // android.view.View public Drawable getForeground() { return this.d; } }