Rabbit-R1/android (non root)/java/sources/androidx/appcompat/graphics/drawable/DrawableContainerCompat.java
2024-05-21 17:08:36 -04:00

1183 lines
43 KiB
Java

package androidx.appcompat.graphics.drawable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.util.SparseArray;
import androidx.core.graphics.drawable.DrawableCompat;
/* loaded from: classes.dex */
public class DrawableContainerCompat extends Drawable implements Drawable.Callback {
private static final boolean DEBUG = false;
private static final boolean DEFAULT_DITHER = true;
private static final String TAG = "DrawableContainerCompat";
private Runnable mAnimationRunnable;
private BlockInvalidateCallback mBlockInvalidateCallback;
private Drawable mCurrDrawable;
private DrawableContainerState mDrawableContainerState;
private long mEnterAnimationEnd;
private long mExitAnimationEnd;
private boolean mHasAlpha;
private Rect mHotspotBounds;
private Drawable mLastDrawable;
private boolean mMutated;
private int mAlpha = 255;
private int mCurIndex = -1;
DrawableContainerState cloneConstantState() {
return this.mDrawableContainerState;
}
@Override // android.graphics.drawable.Drawable
public int getAlpha() {
return this.mAlpha;
}
@Override // android.graphics.drawable.Drawable
public Drawable getCurrent() {
return this.mCurrDrawable;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getCurrentIndex() {
return this.mCurIndex;
}
@Override // android.graphics.drawable.Drawable
public void draw(Canvas canvas) {
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
drawable.draw(canvas);
}
Drawable drawable2 = this.mLastDrawable;
if (drawable2 != null) {
drawable2.draw(canvas);
}
}
@Override // android.graphics.drawable.Drawable
public int getChangingConfigurations() {
return this.mDrawableContainerState.getChangingConfigurations() | super.getChangingConfigurations();
}
private boolean needsMirroring() {
return isAutoMirrored() && DrawableCompat.getLayoutDirection(this) == 1;
}
@Override // android.graphics.drawable.Drawable
public boolean getPadding(Rect rect) {
boolean padding;
Rect constantPadding = this.mDrawableContainerState.getConstantPadding();
if (constantPadding != null) {
rect.set(constantPadding);
padding = (constantPadding.right | ((constantPadding.left | constantPadding.top) | constantPadding.bottom)) != 0;
} else {
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
padding = drawable.getPadding(rect);
} else {
padding = super.getPadding(rect);
}
}
if (needsMirroring()) {
int i = rect.left;
rect.left = rect.right;
rect.right = i;
}
return padding;
}
@Override // android.graphics.drawable.Drawable
public void getOutline(Outline outline) {
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
Api21Impl.getOutline(drawable, outline);
}
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
if (this.mHasAlpha && this.mAlpha == i) {
return;
}
this.mHasAlpha = true;
this.mAlpha = i;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
if (this.mEnterAnimationEnd == 0) {
drawable.setAlpha(i);
} else {
animate(false);
}
}
}
@Override // android.graphics.drawable.Drawable
public void setDither(boolean z) {
if (this.mDrawableContainerState.mDither != z) {
this.mDrawableContainerState.mDither = z;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
drawable.setDither(this.mDrawableContainerState.mDither);
}
}
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
this.mDrawableContainerState.mHasColorFilter = true;
if (this.mDrawableContainerState.mColorFilter != colorFilter) {
this.mDrawableContainerState.mColorFilter = colorFilter;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
drawable.setColorFilter(colorFilter);
}
}
}
@Override // android.graphics.drawable.Drawable
public void setTint(int i) {
setTintList(ColorStateList.valueOf(i));
}
@Override // android.graphics.drawable.Drawable
public void setTintList(ColorStateList colorStateList) {
this.mDrawableContainerState.mHasTintList = true;
if (this.mDrawableContainerState.mTintList != colorStateList) {
this.mDrawableContainerState.mTintList = colorStateList;
DrawableCompat.setTintList(this.mCurrDrawable, colorStateList);
}
}
@Override // android.graphics.drawable.Drawable
public void setTintMode(PorterDuff.Mode mode) {
this.mDrawableContainerState.mHasTintMode = true;
if (this.mDrawableContainerState.mTintMode != mode) {
this.mDrawableContainerState.mTintMode = mode;
DrawableCompat.setTintMode(this.mCurrDrawable, mode);
}
}
public void setEnterFadeDuration(int i) {
this.mDrawableContainerState.mEnterFadeDuration = i;
}
public void setExitFadeDuration(int i) {
this.mDrawableContainerState.mExitFadeDuration = i;
}
@Override // android.graphics.drawable.Drawable
protected void onBoundsChange(Rect rect) {
Drawable drawable = this.mLastDrawable;
if (drawable != null) {
drawable.setBounds(rect);
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
drawable2.setBounds(rect);
}
}
@Override // android.graphics.drawable.Drawable
public boolean isStateful() {
return this.mDrawableContainerState.isStateful();
}
@Override // android.graphics.drawable.Drawable
public void setAutoMirrored(boolean z) {
if (this.mDrawableContainerState.mAutoMirrored != z) {
this.mDrawableContainerState.mAutoMirrored = z;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
DrawableCompat.setAutoMirrored(drawable, this.mDrawableContainerState.mAutoMirrored);
}
}
}
@Override // android.graphics.drawable.Drawable
public boolean isAutoMirrored() {
return this.mDrawableContainerState.mAutoMirrored;
}
@Override // android.graphics.drawable.Drawable
public void jumpToCurrentState() {
boolean z;
Drawable drawable = this.mLastDrawable;
boolean z2 = true;
if (drawable != null) {
drawable.jumpToCurrentState();
this.mLastDrawable = null;
z = true;
} else {
z = false;
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
drawable2.jumpToCurrentState();
if (this.mHasAlpha) {
this.mCurrDrawable.setAlpha(this.mAlpha);
}
}
if (this.mExitAnimationEnd != 0) {
this.mExitAnimationEnd = 0L;
} else {
z2 = z;
}
if (this.mEnterAnimationEnd != 0) {
this.mEnterAnimationEnd = 0L;
} else if (!z2) {
return;
}
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable
public void setHotspot(float f, float f2) {
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
DrawableCompat.setHotspot(drawable, f, f2);
}
}
@Override // android.graphics.drawable.Drawable
public void setHotspotBounds(int i, int i2, int i3, int i4) {
Rect rect = this.mHotspotBounds;
if (rect == null) {
this.mHotspotBounds = new Rect(i, i2, i3, i4);
} else {
rect.set(i, i2, i3, i4);
}
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
DrawableCompat.setHotspotBounds(drawable, i, i2, i3, i4);
}
}
@Override // android.graphics.drawable.Drawable
public void getHotspotBounds(Rect rect) {
Rect rect2 = this.mHotspotBounds;
if (rect2 != null) {
rect.set(rect2);
} else {
super.getHotspotBounds(rect);
}
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // android.graphics.drawable.Drawable
public boolean onStateChange(int[] iArr) {
Drawable drawable = this.mLastDrawable;
if (drawable != null) {
return drawable.setState(iArr);
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
return drawable2.setState(iArr);
}
return false;
}
@Override // android.graphics.drawable.Drawable
protected boolean onLevelChange(int i) {
Drawable drawable = this.mLastDrawable;
if (drawable != null) {
return drawable.setLevel(i);
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
return drawable2.setLevel(i);
}
return false;
}
@Override // android.graphics.drawable.Drawable
public boolean onLayoutDirectionChanged(int i) {
return this.mDrawableContainerState.setLayoutDirection(i, getCurrentIndex());
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
if (this.mDrawableContainerState.isConstantSize()) {
return this.mDrawableContainerState.getConstantWidth();
}
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
return drawable.getIntrinsicWidth();
}
return -1;
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
if (this.mDrawableContainerState.isConstantSize()) {
return this.mDrawableContainerState.getConstantHeight();
}
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
return drawable.getIntrinsicHeight();
}
return -1;
}
@Override // android.graphics.drawable.Drawable
public int getMinimumWidth() {
if (this.mDrawableContainerState.isConstantSize()) {
return this.mDrawableContainerState.getConstantMinimumWidth();
}
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
return drawable.getMinimumWidth();
}
return 0;
}
@Override // android.graphics.drawable.Drawable
public int getMinimumHeight() {
if (this.mDrawableContainerState.isConstantSize()) {
return this.mDrawableContainerState.getConstantMinimumHeight();
}
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
return drawable.getMinimumHeight();
}
return 0;
}
@Override // android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(Drawable drawable) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
if (drawableContainerState != null) {
drawableContainerState.invalidateCache();
}
if (drawable != this.mCurrDrawable || getCallback() == null) {
return;
}
getCallback().invalidateDrawable(this);
}
@Override // android.graphics.drawable.Drawable.Callback
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
if (drawable != this.mCurrDrawable || getCallback() == null) {
return;
}
getCallback().scheduleDrawable(this, runnable, j);
}
@Override // android.graphics.drawable.Drawable.Callback
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
if (drawable != this.mCurrDrawable || getCallback() == null) {
return;
}
getCallback().unscheduleDrawable(this, runnable);
}
@Override // android.graphics.drawable.Drawable
public boolean setVisible(boolean z, boolean z2) {
boolean visible = super.setVisible(z, z2);
Drawable drawable = this.mLastDrawable;
if (drawable != null) {
drawable.setVisible(z, z2);
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
drawable2.setVisible(z, z2);
}
return visible;
}
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
Drawable drawable = this.mCurrDrawable;
if (drawable == null || !drawable.isVisible()) {
return -2;
}
return this.mDrawableContainerState.getOpacity();
}
void setCurrentIndex(int i) {
selectDrawable(i);
}
/* JADX INFO: Access modifiers changed from: package-private */
public boolean selectDrawable(int i) {
if (i == this.mCurIndex) {
return false;
}
long uptimeMillis = SystemClock.uptimeMillis();
if (this.mDrawableContainerState.mExitFadeDuration > 0) {
Drawable drawable = this.mLastDrawable;
if (drawable != null) {
drawable.setVisible(false, false);
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
this.mLastDrawable = drawable2;
this.mExitAnimationEnd = this.mDrawableContainerState.mExitFadeDuration + uptimeMillis;
} else {
this.mLastDrawable = null;
this.mExitAnimationEnd = 0L;
}
} else {
Drawable drawable3 = this.mCurrDrawable;
if (drawable3 != null) {
drawable3.setVisible(false, false);
}
}
if (i < 0 || i >= this.mDrawableContainerState.mNumChildren) {
this.mCurrDrawable = null;
this.mCurIndex = -1;
} else {
Drawable child = this.mDrawableContainerState.getChild(i);
this.mCurrDrawable = child;
this.mCurIndex = i;
if (child != null) {
if (this.mDrawableContainerState.mEnterFadeDuration > 0) {
this.mEnterAnimationEnd = uptimeMillis + this.mDrawableContainerState.mEnterFadeDuration;
}
initializeDrawableForDisplay(child);
}
}
if (this.mEnterAnimationEnd != 0 || this.mExitAnimationEnd != 0) {
Runnable runnable = this.mAnimationRunnable;
if (runnable == null) {
this.mAnimationRunnable = new Runnable() { // from class: androidx.appcompat.graphics.drawable.DrawableContainerCompat.1
@Override // java.lang.Runnable
public void run() {
DrawableContainerCompat.this.animate(true);
DrawableContainerCompat.this.invalidateSelf();
}
};
} else {
unscheduleSelf(runnable);
}
animate(true);
}
invalidateSelf();
return true;
}
private void initializeDrawableForDisplay(Drawable drawable) {
if (this.mBlockInvalidateCallback == null) {
this.mBlockInvalidateCallback = new BlockInvalidateCallback();
}
drawable.setCallback(this.mBlockInvalidateCallback.wrap(drawable.getCallback()));
try {
if (this.mDrawableContainerState.mEnterFadeDuration <= 0 && this.mHasAlpha) {
drawable.setAlpha(this.mAlpha);
}
if (this.mDrawableContainerState.mHasColorFilter) {
drawable.setColorFilter(this.mDrawableContainerState.mColorFilter);
} else {
if (this.mDrawableContainerState.mHasTintList) {
DrawableCompat.setTintList(drawable, this.mDrawableContainerState.mTintList);
}
if (this.mDrawableContainerState.mHasTintMode) {
DrawableCompat.setTintMode(drawable, this.mDrawableContainerState.mTintMode);
}
}
drawable.setVisible(isVisible(), true);
drawable.setDither(this.mDrawableContainerState.mDither);
drawable.setState(getState());
drawable.setLevel(getLevel());
drawable.setBounds(getBounds());
DrawableCompat.setLayoutDirection(drawable, DrawableCompat.getLayoutDirection(this));
DrawableCompat.setAutoMirrored(drawable, this.mDrawableContainerState.mAutoMirrored);
Rect rect = this.mHotspotBounds;
if (rect != null) {
DrawableCompat.setHotspotBounds(drawable, rect.left, rect.top, rect.right, rect.bottom);
}
} finally {
drawable.setCallback(this.mBlockInvalidateCallback.unwrap());
}
}
/* JADX WARN: Removed duplicated region for block: B:11:0x003f */
/* JADX WARN: Removed duplicated region for block: B:18:0x006a A[ADDED_TO_REGION] */
/* JADX WARN: Removed duplicated region for block: B:23:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:25:0x0065 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
void animate(boolean r14) {
/*
r13 = this;
r0 = 1
r13.mHasAlpha = r0
long r1 = android.os.SystemClock.uptimeMillis()
android.graphics.drawable.Drawable r3 = r13.mCurrDrawable
r4 = 255(0xff, double:1.26E-321)
r6 = 0
r8 = 0
if (r3 == 0) goto L38
long r9 = r13.mEnterAnimationEnd
int r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1))
if (r11 == 0) goto L3a
int r11 = (r9 > r1 ? 1 : (r9 == r1 ? 0 : -1))
if (r11 > 0) goto L22
int r9 = r13.mAlpha
r3.setAlpha(r9)
r13.mEnterAnimationEnd = r6
goto L3a
L22:
long r9 = r9 - r1
long r9 = r9 * r4
int r3 = (int) r9
androidx.appcompat.graphics.drawable.DrawableContainerCompat$DrawableContainerState r9 = r13.mDrawableContainerState
int r9 = r9.mEnterFadeDuration
int r3 = r3 / r9
android.graphics.drawable.Drawable r9 = r13.mCurrDrawable
int r3 = 255 - r3
int r10 = r13.mAlpha
int r3 = r3 * r10
int r3 = r3 / 255
r9.setAlpha(r3)
r3 = r0
goto L3b
L38:
r13.mEnterAnimationEnd = r6
L3a:
r3 = r8
L3b:
android.graphics.drawable.Drawable r9 = r13.mLastDrawable
if (r9 == 0) goto L65
long r10 = r13.mExitAnimationEnd
int r12 = (r10 > r6 ? 1 : (r10 == r6 ? 0 : -1))
if (r12 == 0) goto L67
int r12 = (r10 > r1 ? 1 : (r10 == r1 ? 0 : -1))
if (r12 > 0) goto L52
r9.setVisible(r8, r8)
r0 = 0
r13.mLastDrawable = r0
r13.mExitAnimationEnd = r6
goto L67
L52:
long r10 = r10 - r1
long r10 = r10 * r4
int r3 = (int) r10
androidx.appcompat.graphics.drawable.DrawableContainerCompat$DrawableContainerState r4 = r13.mDrawableContainerState
int r4 = r4.mExitFadeDuration
int r3 = r3 / r4
android.graphics.drawable.Drawable r4 = r13.mLastDrawable
int r5 = r13.mAlpha
int r3 = r3 * r5
int r3 = r3 / 255
r4.setAlpha(r3)
goto L68
L65:
r13.mExitAnimationEnd = r6
L67:
r0 = r3
L68:
if (r14 == 0) goto L74
if (r0 == 0) goto L74
java.lang.Runnable r14 = r13.mAnimationRunnable
r3 = 16
long r1 = r1 + r3
r13.scheduleSelf(r14, r1)
L74:
return
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.graphics.drawable.DrawableContainerCompat.animate(boolean):void");
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void updateDensity(Resources resources) {
this.mDrawableContainerState.updateDensity(resources);
}
@Override // android.graphics.drawable.Drawable
public void applyTheme(Resources.Theme theme) {
this.mDrawableContainerState.applyTheme(theme);
}
@Override // android.graphics.drawable.Drawable
public boolean canApplyTheme() {
return this.mDrawableContainerState.canApplyTheme();
}
@Override // android.graphics.drawable.Drawable
public final Drawable.ConstantState getConstantState() {
if (!this.mDrawableContainerState.canConstantState()) {
return null;
}
this.mDrawableContainerState.mChangingConfigurations = getChangingConfigurations();
return this.mDrawableContainerState;
}
@Override // android.graphics.drawable.Drawable
public Drawable mutate() {
if (!this.mMutated && super.mutate() == this) {
DrawableContainerState cloneConstantState = cloneConstantState();
cloneConstantState.mutate();
setConstantState(cloneConstantState);
this.mMutated = true;
}
return this;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void clearMutated() {
this.mDrawableContainerState.clearMutated();
this.mMutated = false;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static abstract class DrawableContainerState extends Drawable.ConstantState {
boolean mAutoMirrored;
boolean mCanConstantState;
int mChangingConfigurations;
boolean mCheckedConstantSize;
boolean mCheckedConstantState;
boolean mCheckedOpacity;
boolean mCheckedPadding;
boolean mCheckedStateful;
int mChildrenChangingConfigurations;
ColorFilter mColorFilter;
int mConstantHeight;
int mConstantMinimumHeight;
int mConstantMinimumWidth;
Rect mConstantPadding;
boolean mConstantSize;
int mConstantWidth;
int mDensity;
boolean mDither;
SparseArray<Drawable.ConstantState> mDrawableFutures;
Drawable[] mDrawables;
int mEnterFadeDuration;
int mExitFadeDuration;
boolean mHasColorFilter;
boolean mHasTintList;
boolean mHasTintMode;
int mLayoutDirection;
boolean mMutated;
int mNumChildren;
int mOpacity;
final DrawableContainerCompat mOwner;
Resources mSourceRes;
boolean mStateful;
ColorStateList mTintList;
PorterDuff.Mode mTintMode;
boolean mVariablePadding;
final void clearMutated() {
this.mMutated = false;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public int getChangingConfigurations() {
return this.mChildrenChangingConfigurations | this.mChangingConfigurations;
}
public final int getChildCount() {
return this.mNumChildren;
}
public final int getEnterFadeDuration() {
return this.mEnterFadeDuration;
}
public final int getExitFadeDuration() {
return this.mExitFadeDuration;
}
void invalidateCache() {
this.mCheckedOpacity = false;
this.mCheckedStateful = false;
}
public final boolean isConstantSize() {
return this.mConstantSize;
}
public final void setConstantSize(boolean z) {
this.mConstantSize = z;
}
public final void setEnterFadeDuration(int i) {
this.mEnterFadeDuration = i;
}
public final void setExitFadeDuration(int i) {
this.mExitFadeDuration = i;
}
public final void setVariablePadding(boolean z) {
this.mVariablePadding = z;
}
/* JADX INFO: Access modifiers changed from: package-private */
public DrawableContainerState(DrawableContainerState drawableContainerState, DrawableContainerCompat drawableContainerCompat, Resources resources) {
Resources resources2;
this.mVariablePadding = false;
this.mConstantSize = false;
this.mDither = true;
this.mEnterFadeDuration = 0;
this.mExitFadeDuration = 0;
this.mOwner = drawableContainerCompat;
if (resources != null) {
resources2 = resources;
} else {
resources2 = drawableContainerState != null ? drawableContainerState.mSourceRes : null;
}
this.mSourceRes = resources2;
int resolveDensity = DrawableContainerCompat.resolveDensity(resources, drawableContainerState != null ? drawableContainerState.mDensity : 0);
this.mDensity = resolveDensity;
if (drawableContainerState == null) {
this.mDrawables = new Drawable[10];
this.mNumChildren = 0;
return;
}
this.mChangingConfigurations = drawableContainerState.mChangingConfigurations;
this.mChildrenChangingConfigurations = drawableContainerState.mChildrenChangingConfigurations;
this.mCheckedConstantState = true;
this.mCanConstantState = true;
this.mVariablePadding = drawableContainerState.mVariablePadding;
this.mConstantSize = drawableContainerState.mConstantSize;
this.mDither = drawableContainerState.mDither;
this.mMutated = drawableContainerState.mMutated;
this.mLayoutDirection = drawableContainerState.mLayoutDirection;
this.mEnterFadeDuration = drawableContainerState.mEnterFadeDuration;
this.mExitFadeDuration = drawableContainerState.mExitFadeDuration;
this.mAutoMirrored = drawableContainerState.mAutoMirrored;
this.mColorFilter = drawableContainerState.mColorFilter;
this.mHasColorFilter = drawableContainerState.mHasColorFilter;
this.mTintList = drawableContainerState.mTintList;
this.mTintMode = drawableContainerState.mTintMode;
this.mHasTintList = drawableContainerState.mHasTintList;
this.mHasTintMode = drawableContainerState.mHasTintMode;
if (drawableContainerState.mDensity == resolveDensity) {
if (drawableContainerState.mCheckedPadding) {
this.mConstantPadding = drawableContainerState.mConstantPadding != null ? new Rect(drawableContainerState.mConstantPadding) : null;
this.mCheckedPadding = true;
}
if (drawableContainerState.mCheckedConstantSize) {
this.mConstantWidth = drawableContainerState.mConstantWidth;
this.mConstantHeight = drawableContainerState.mConstantHeight;
this.mConstantMinimumWidth = drawableContainerState.mConstantMinimumWidth;
this.mConstantMinimumHeight = drawableContainerState.mConstantMinimumHeight;
this.mCheckedConstantSize = true;
}
}
if (drawableContainerState.mCheckedOpacity) {
this.mOpacity = drawableContainerState.mOpacity;
this.mCheckedOpacity = true;
}
if (drawableContainerState.mCheckedStateful) {
this.mStateful = drawableContainerState.mStateful;
this.mCheckedStateful = true;
}
Drawable[] drawableArr = drawableContainerState.mDrawables;
this.mDrawables = new Drawable[drawableArr.length];
this.mNumChildren = drawableContainerState.mNumChildren;
SparseArray<Drawable.ConstantState> sparseArray = drawableContainerState.mDrawableFutures;
if (sparseArray != null) {
this.mDrawableFutures = sparseArray.clone();
} else {
this.mDrawableFutures = new SparseArray<>(this.mNumChildren);
}
int i = this.mNumChildren;
for (int i2 = 0; i2 < i; i2++) {
Drawable drawable = drawableArr[i2];
if (drawable != null) {
Drawable.ConstantState constantState = drawable.getConstantState();
if (constantState != null) {
this.mDrawableFutures.put(i2, constantState);
} else {
this.mDrawables[i2] = drawableArr[i2];
}
}
}
}
public final int addChild(Drawable drawable) {
int i = this.mNumChildren;
if (i >= this.mDrawables.length) {
growArray(i, i + 10);
}
drawable.mutate();
drawable.setVisible(false, true);
drawable.setCallback(this.mOwner);
this.mDrawables[i] = drawable;
this.mNumChildren++;
this.mChildrenChangingConfigurations = drawable.getChangingConfigurations() | this.mChildrenChangingConfigurations;
invalidateCache();
this.mConstantPadding = null;
this.mCheckedPadding = false;
this.mCheckedConstantSize = false;
this.mCheckedConstantState = false;
return i;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final int getCapacity() {
return this.mDrawables.length;
}
private void createAllFutures() {
SparseArray<Drawable.ConstantState> sparseArray = this.mDrawableFutures;
if (sparseArray != null) {
int size = sparseArray.size();
for (int i = 0; i < size; i++) {
this.mDrawables[this.mDrawableFutures.keyAt(i)] = prepareDrawable(this.mDrawableFutures.valueAt(i).newDrawable(this.mSourceRes));
}
this.mDrawableFutures = null;
}
}
private Drawable prepareDrawable(Drawable drawable) {
DrawableCompat.setLayoutDirection(drawable, this.mLayoutDirection);
Drawable mutate = drawable.mutate();
mutate.setCallback(this.mOwner);
return mutate;
}
public final Drawable getChild(int i) {
int indexOfKey;
Drawable drawable = this.mDrawables[i];
if (drawable != null) {
return drawable;
}
SparseArray<Drawable.ConstantState> sparseArray = this.mDrawableFutures;
if (sparseArray == null || (indexOfKey = sparseArray.indexOfKey(i)) < 0) {
return null;
}
Drawable prepareDrawable = prepareDrawable(this.mDrawableFutures.valueAt(indexOfKey).newDrawable(this.mSourceRes));
this.mDrawables[i] = prepareDrawable;
this.mDrawableFutures.removeAt(indexOfKey);
if (this.mDrawableFutures.size() == 0) {
this.mDrawableFutures = null;
}
return prepareDrawable;
}
final boolean setLayoutDirection(int i, int i2) {
int i3 = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
boolean z = false;
for (int i4 = 0; i4 < i3; i4++) {
if (drawableArr[i4] != null) {
boolean layoutDirection = DrawableCompat.setLayoutDirection(drawableArr[i4], i);
if (i4 == i2) {
z = layoutDirection;
}
}
}
this.mLayoutDirection = i;
return z;
}
final void updateDensity(Resources resources) {
if (resources != null) {
this.mSourceRes = resources;
int resolveDensity = DrawableContainerCompat.resolveDensity(resources, this.mDensity);
int i = this.mDensity;
this.mDensity = resolveDensity;
if (i != resolveDensity) {
this.mCheckedConstantSize = false;
this.mCheckedPadding = false;
}
}
}
final void applyTheme(Resources.Theme theme) {
if (theme != null) {
createAllFutures();
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
for (int i2 = 0; i2 < i; i2++) {
Drawable drawable = drawableArr[i2];
if (drawable != null && DrawableCompat.canApplyTheme(drawable)) {
DrawableCompat.applyTheme(drawableArr[i2], theme);
this.mChildrenChangingConfigurations |= drawableArr[i2].getChangingConfigurations();
}
}
updateDensity(Api21Impl.getResources(theme));
}
}
@Override // android.graphics.drawable.Drawable.ConstantState
public boolean canApplyTheme() {
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
for (int i2 = 0; i2 < i; i2++) {
Drawable drawable = drawableArr[i2];
if (drawable != null) {
if (DrawableCompat.canApplyTheme(drawable)) {
return true;
}
} else {
Drawable.ConstantState constantState = this.mDrawableFutures.get(i2);
if (constantState != null && Api21Impl.canApplyTheme(constantState)) {
return true;
}
}
}
return false;
}
void mutate() {
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
for (int i2 = 0; i2 < i; i2++) {
Drawable drawable = drawableArr[i2];
if (drawable != null) {
drawable.mutate();
}
}
this.mMutated = true;
}
public final Rect getConstantPadding() {
Rect rect = null;
if (this.mVariablePadding) {
return null;
}
Rect rect2 = this.mConstantPadding;
if (rect2 != null || this.mCheckedPadding) {
return rect2;
}
createAllFutures();
Rect rect3 = new Rect();
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
for (int i2 = 0; i2 < i; i2++) {
if (drawableArr[i2].getPadding(rect3)) {
if (rect == null) {
rect = new Rect(0, 0, 0, 0);
}
if (rect3.left > rect.left) {
rect.left = rect3.left;
}
if (rect3.top > rect.top) {
rect.top = rect3.top;
}
if (rect3.right > rect.right) {
rect.right = rect3.right;
}
if (rect3.bottom > rect.bottom) {
rect.bottom = rect3.bottom;
}
}
}
this.mCheckedPadding = true;
this.mConstantPadding = rect;
return rect;
}
public final int getConstantWidth() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantWidth;
}
public final int getConstantHeight() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantHeight;
}
public final int getConstantMinimumWidth() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantMinimumWidth;
}
public final int getConstantMinimumHeight() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantMinimumHeight;
}
protected void computeConstantSize() {
this.mCheckedConstantSize = true;
createAllFutures();
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
this.mConstantHeight = -1;
this.mConstantWidth = -1;
this.mConstantMinimumHeight = 0;
this.mConstantMinimumWidth = 0;
for (int i2 = 0; i2 < i; i2++) {
Drawable drawable = drawableArr[i2];
int intrinsicWidth = drawable.getIntrinsicWidth();
if (intrinsicWidth > this.mConstantWidth) {
this.mConstantWidth = intrinsicWidth;
}
int intrinsicHeight = drawable.getIntrinsicHeight();
if (intrinsicHeight > this.mConstantHeight) {
this.mConstantHeight = intrinsicHeight;
}
int minimumWidth = drawable.getMinimumWidth();
if (minimumWidth > this.mConstantMinimumWidth) {
this.mConstantMinimumWidth = minimumWidth;
}
int minimumHeight = drawable.getMinimumHeight();
if (minimumHeight > this.mConstantMinimumHeight) {
this.mConstantMinimumHeight = minimumHeight;
}
}
}
public final int getOpacity() {
if (this.mCheckedOpacity) {
return this.mOpacity;
}
createAllFutures();
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
int opacity = i > 0 ? drawableArr[0].getOpacity() : -2;
for (int i2 = 1; i2 < i; i2++) {
opacity = Drawable.resolveOpacity(opacity, drawableArr[i2].getOpacity());
}
this.mOpacity = opacity;
this.mCheckedOpacity = true;
return opacity;
}
public final boolean isStateful() {
if (this.mCheckedStateful) {
return this.mStateful;
}
createAllFutures();
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
boolean z = false;
int i2 = 0;
while (true) {
if (i2 >= i) {
break;
}
if (drawableArr[i2].isStateful()) {
z = true;
break;
}
i2++;
}
this.mStateful = z;
this.mCheckedStateful = true;
return z;
}
public void growArray(int i, int i2) {
Drawable[] drawableArr = new Drawable[i2];
Drawable[] drawableArr2 = this.mDrawables;
if (drawableArr2 != null) {
System.arraycopy(drawableArr2, 0, drawableArr, 0, i);
}
this.mDrawables = drawableArr;
}
public boolean canConstantState() {
if (this.mCheckedConstantState) {
return this.mCanConstantState;
}
createAllFutures();
this.mCheckedConstantState = true;
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
for (int i2 = 0; i2 < i; i2++) {
if (drawableArr[i2].getConstantState() == null) {
this.mCanConstantState = false;
return false;
}
}
this.mCanConstantState = true;
return true;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void setConstantState(DrawableContainerState drawableContainerState) {
this.mDrawableContainerState = drawableContainerState;
int i = this.mCurIndex;
if (i >= 0) {
Drawable child = drawableContainerState.getChild(i);
this.mCurrDrawable = child;
if (child != null) {
initializeDrawableForDisplay(child);
}
}
this.mLastDrawable = null;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class BlockInvalidateCallback implements Drawable.Callback {
private Drawable.Callback mCallback;
@Override // android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(Drawable drawable) {
}
public Drawable.Callback unwrap() {
Drawable.Callback callback = this.mCallback;
this.mCallback = null;
return callback;
}
public BlockInvalidateCallback wrap(Drawable.Callback callback) {
this.mCallback = callback;
return this;
}
BlockInvalidateCallback() {
}
@Override // android.graphics.drawable.Drawable.Callback
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
Drawable.Callback callback = this.mCallback;
if (callback != null) {
callback.scheduleDrawable(drawable, runnable, j);
}
}
@Override // android.graphics.drawable.Drawable.Callback
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
Drawable.Callback callback = this.mCallback;
if (callback != null) {
callback.unscheduleDrawable(drawable, runnable);
}
}
}
static int resolveDensity(Resources resources, int i) {
if (resources != null) {
i = resources.getDisplayMetrics().densityDpi;
}
if (i == 0) {
return 160;
}
return i;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes.dex */
public static class Api21Impl {
private Api21Impl() {
}
public static boolean canApplyTheme(Drawable.ConstantState constantState) {
return constantState.canApplyTheme();
}
public static Resources getResources(Resources.Theme theme) {
return theme.getResources();
}
public static void getOutline(Drawable drawable, Outline outline) {
drawable.getOutline(outline);
}
}
}