discord-jadx/app/src/main/java/androidx/appcompat/graphics/drawable/DrawableContainer.java

1138 lines
42 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.Build;
import android.os.SystemClock;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.graphics.drawable.DrawableCompat;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public class DrawableContainer extends Drawable implements Drawable.Callback {
private static final boolean DEBUG = false;
private static final boolean DEFAULT_DITHER = true;
private static final String TAG = "DrawableContainer";
private int mAlpha = 255;
private Runnable mAnimationRunnable;
private BlockInvalidateCallback mBlockInvalidateCallback;
private int mCurIndex = -1;
private Drawable mCurrDrawable;
private DrawableContainerState mDrawableContainerState;
private long mEnterAnimationEnd;
private long mExitAnimationEnd;
private boolean mHasAlpha;
private Rect mHotspotBounds;
private Drawable mLastDrawable;
private boolean mMutated;
/* renamed from: androidx.appcompat.graphics.drawable.DrawableContainer$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public AnonymousClass1() {
}
@Override // java.lang.Runnable
public void run() {
DrawableContainer.this.animate(true);
DrawableContainer.this.invalidateSelf();
}
}
public static class BlockInvalidateCallback implements Drawable.Callback {
private Drawable.Callback mCallback;
@Override // android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(@NonNull Drawable drawable) {
}
@Override // android.graphics.drawable.Drawable.Callback
public void scheduleDrawable(@NonNull Drawable drawable, @NonNull 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(@NonNull Drawable drawable, @NonNull Runnable runnable) {
Drawable.Callback callback = this.mCallback;
if (callback != null) {
callback.unscheduleDrawable(drawable, runnable);
}
}
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;
}
}
public static abstract class DrawableContainerState extends Drawable.ConstantState {
public boolean mAutoMirrored;
public boolean mCanConstantState;
public int mChangingConfigurations;
public boolean mCheckedConstantSize;
public boolean mCheckedConstantState;
public boolean mCheckedOpacity;
public boolean mCheckedPadding;
public boolean mCheckedStateful;
public int mChildrenChangingConfigurations;
public ColorFilter mColorFilter;
public int mConstantHeight;
public int mConstantMinimumHeight;
public int mConstantMinimumWidth;
public Rect mConstantPadding;
public boolean mConstantSize;
public int mConstantWidth;
public int mDensity = 160;
public boolean mDither;
public SparseArray<Drawable.ConstantState> mDrawableFutures;
public Drawable[] mDrawables;
public int mEnterFadeDuration;
public int mExitFadeDuration;
public boolean mHasColorFilter;
public boolean mHasTintList;
public boolean mHasTintMode;
public int mLayoutDirection;
public boolean mMutated;
public int mNumChildren;
public int mOpacity;
public final DrawableContainer mOwner;
public Resources mSourceRes;
public boolean mStateful;
public ColorStateList mTintList;
public PorterDuff.Mode mTintMode;
public boolean mVariablePadding;
public DrawableContainerState(DrawableContainerState drawableContainerState, DrawableContainer drawableContainer, Resources resources) {
this.mVariablePadding = false;
this.mConstantSize = false;
this.mDither = true;
this.mEnterFadeDuration = 0;
this.mExitFadeDuration = 0;
this.mOwner = drawableContainer;
this.mSourceRes = resources != null ? resources : drawableContainerState != null ? drawableContainerState.mSourceRes : null;
int resolveDensity = DrawableContainer.resolveDensity(resources, drawableContainerState != null ? drawableContainerState.mDensity : 0);
this.mDensity = resolveDensity;
if (drawableContainerState != null) {
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 = new Rect(drawableContainerState.mConstantPadding);
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++) {
if (drawableArr[i2] != null) {
Drawable.ConstantState constantState = drawableArr[i2].getConstantState();
if (constantState != null) {
this.mDrawableFutures.put(i2, constantState);
} else {
this.mDrawables[i2] = drawableArr[i2];
}
}
}
return;
}
this.mDrawables = new Drawable[10];
this.mNumChildren = 0;
}
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) {
if (Build.VERSION.SDK_INT >= 23) {
drawable.setLayoutDirection(this.mLayoutDirection);
}
Drawable mutate = drawable.mutate();
mutate.setCallback(this.mOwner);
return mutate;
}
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;
}
@RequiresApi(21)
public 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++) {
if (drawableArr[i2] != null && drawableArr[i2].canApplyTheme()) {
drawableArr[i2].applyTheme(theme);
this.mChildrenChangingConfigurations |= drawableArr[i2].getChangingConfigurations();
}
}
updateDensity(theme.getResources());
}
}
@Override // android.graphics.drawable.Drawable.ConstantState
@RequiresApi(21)
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) {
Drawable.ConstantState constantState = this.mDrawableFutures.get(i2);
if (constantState != null && constantState.canApplyTheme()) {
return true;
}
} else if (drawable.canApplyTheme()) {
return true;
}
}
return false;
}
public synchronized 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;
}
public final void clearMutated() {
this.mMutated = false;
}
public 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 getCapacity() {
return this.mDrawables.length;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public int getChangingConfigurations() {
return this.mChangingConfigurations | this.mChildrenChangingConfigurations;
}
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;
}
public final int getChildCount() {
return this.mNumChildren;
}
public final int getConstantHeight() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantHeight;
}
public final int getConstantMinimumHeight() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantMinimumHeight;
}
public final int getConstantMinimumWidth() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantMinimumWidth;
}
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);
}
int i3 = rect3.left;
if (i3 > rect.left) {
rect.left = i3;
}
int i4 = rect3.top;
if (i4 > rect.top) {
rect.top = i4;
}
int i5 = rect3.right;
if (i5 > rect.right) {
rect.right = i5;
}
int i6 = rect3.bottom;
if (i6 > rect.bottom) {
rect.bottom = i6;
}
}
}
this.mCheckedPadding = true;
this.mConstantPadding = rect;
return rect;
}
public final int getConstantWidth() {
if (!this.mCheckedConstantSize) {
computeConstantSize();
}
return this.mConstantWidth;
}
public final int getEnterFadeDuration() {
return this.mEnterFadeDuration;
}
public final int getExitFadeDuration() {
return this.mExitFadeDuration;
}
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 void growArray(int i, int i2) {
Drawable[] drawableArr = new Drawable[i2];
System.arraycopy(this.mDrawables, 0, drawableArr, 0, i);
this.mDrawables = drawableArr;
}
public void invalidateCache() {
this.mCheckedOpacity = false;
this.mCheckedStateful = false;
}
public final boolean isConstantSize() {
return this.mConstantSize;
}
public final boolean isStateful() {
if (this.mCheckedStateful) {
return this.mStateful;
}
createAllFutures();
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
boolean z2 = false;
int i2 = 0;
while (true) {
if (i2 >= i) {
break;
} else if (drawableArr[i2].isStateful()) {
z2 = true;
break;
} else {
i2++;
}
}
this.mStateful = z2;
this.mCheckedStateful = true;
return z2;
}
public void mutate() {
int i = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
for (int i2 = 0; i2 < i; i2++) {
if (drawableArr[i2] != null) {
drawableArr[i2].mutate();
}
}
this.mMutated = true;
}
public final void setConstantSize(boolean z2) {
this.mConstantSize = z2;
}
public final void setEnterFadeDuration(int i) {
this.mEnterFadeDuration = i;
}
public final void setExitFadeDuration(int i) {
this.mExitFadeDuration = i;
}
public final boolean setLayoutDirection(int i, int i2) {
int i3 = this.mNumChildren;
Drawable[] drawableArr = this.mDrawables;
boolean z2 = false;
for (int i4 = 0; i4 < i3; i4++) {
if (drawableArr[i4] != null) {
boolean layoutDirection = Build.VERSION.SDK_INT >= 23 ? drawableArr[i4].setLayoutDirection(i) : false;
if (i4 == i2) {
z2 = layoutDirection;
}
}
}
this.mLayoutDirection = i;
return z2;
}
public final void setVariablePadding(boolean z2) {
this.mVariablePadding = z2;
}
public final void updateDensity(Resources resources) {
if (resources != null) {
this.mSourceRes = resources;
int resolveDensity = DrawableContainer.resolveDensity(resources, this.mDensity);
int i = this.mDensity;
this.mDensity = resolveDensity;
if (i != resolveDensity) {
this.mCheckedConstantSize = false;
this.mCheckedPadding = false;
}
}
}
}
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);
}
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
if (drawableContainerState.mHasColorFilter) {
drawable.setColorFilter(drawableContainerState.mColorFilter);
} else {
if (drawableContainerState.mHasTintList) {
DrawableCompat.setTintList(drawable, drawableContainerState.mTintList);
}
DrawableContainerState drawableContainerState2 = this.mDrawableContainerState;
if (drawableContainerState2.mHasTintMode) {
DrawableCompat.setTintMode(drawable, drawableContainerState2.mTintMode);
}
}
drawable.setVisible(isVisible(), true);
drawable.setDither(this.mDrawableContainerState.mDither);
drawable.setState(getState());
drawable.setLevel(getLevel());
drawable.setBounds(getBounds());
if (Build.VERSION.SDK_INT >= 23) {
drawable.setLayoutDirection(getLayoutDirection());
}
drawable.setAutoMirrored(this.mDrawableContainerState.mAutoMirrored);
Rect rect = this.mHotspotBounds;
if (rect != null) {
drawable.setHotspotBounds(rect.left, rect.top, rect.right, rect.bottom);
}
} finally {
drawable.setCallback(this.mBlockInvalidateCallback.unwrap());
}
}
private boolean needsMirroring() {
return isAutoMirrored() && DrawableCompat.getLayoutDirection(this) == 1;
}
public static int resolveDensity(@Nullable Resources resources, int i) {
if (resources != null) {
i = resources.getDisplayMetrics().densityDpi;
}
if (i == 0) {
return 160;
}
return i;
}
/* JADX WARNING: Removed duplicated region for block: B:12:0x003f */
/* JADX WARNING: Removed duplicated region for block: B:18:0x0065 */
/* JADX WARNING: Removed duplicated region for block: B:21:0x006a A[ADDED_TO_REGION] */
/* JADX WARNING: Removed duplicated region for block: B:24:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
public void animate(boolean z2) {
boolean z3;
Drawable drawable;
boolean z4 = true;
this.mHasAlpha = true;
long uptimeMillis = SystemClock.uptimeMillis();
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
long j = this.mEnterAnimationEnd;
if (j != 0) {
if (j <= uptimeMillis) {
drawable2.setAlpha(this.mAlpha);
this.mEnterAnimationEnd = 0;
} else {
drawable2.setAlpha(((255 - (((int) ((j - uptimeMillis) * 255)) / this.mDrawableContainerState.mEnterFadeDuration)) * this.mAlpha) / 255);
z3 = true;
drawable = this.mLastDrawable;
if (drawable == null) {
long j2 = this.mExitAnimationEnd;
if (j2 != 0) {
if (j2 <= uptimeMillis) {
drawable.setVisible(false, false);
this.mLastDrawable = null;
this.mExitAnimationEnd = 0;
} else {
drawable.setAlpha(((((int) ((j2 - uptimeMillis) * 255)) / this.mDrawableContainerState.mExitFadeDuration) * this.mAlpha) / 255);
if (!z2 && z4) {
scheduleSelf(this.mAnimationRunnable, uptimeMillis + 16);
return;
}
return;
}
}
} else {
this.mExitAnimationEnd = 0;
}
z4 = z3;
if (!z2) {
return;
}
return;
}
}
} else {
this.mEnterAnimationEnd = 0;
}
z3 = false;
drawable = this.mLastDrawable;
if (drawable == null) {
}
z4 = z3;
if (!z2) {
}
}
@Override // android.graphics.drawable.Drawable
@RequiresApi(21)
public void applyTheme(@NonNull Resources.Theme theme) {
this.mDrawableContainerState.applyTheme(theme);
}
@Override // android.graphics.drawable.Drawable
@RequiresApi(21)
public boolean canApplyTheme() {
return this.mDrawableContainerState.canApplyTheme();
}
public void clearMutated() {
this.mDrawableContainerState.clearMutated();
this.mMutated = false;
}
public DrawableContainerState cloneConstantState() {
return this.mDrawableContainerState;
}
@Override // android.graphics.drawable.Drawable
public void draw(@NonNull 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 getAlpha() {
return this.mAlpha;
}
@Override // android.graphics.drawable.Drawable
public int getChangingConfigurations() {
return super.getChangingConfigurations() | this.mDrawableContainerState.getChangingConfigurations();
}
@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
@NonNull
public Drawable getCurrent() {
return this.mCurrDrawable;
}
public int getCurrentIndex() {
return this.mCurIndex;
}
@Override // android.graphics.drawable.Drawable
public void getHotspotBounds(@NonNull Rect rect) {
Rect rect2 = this.mHotspotBounds;
if (rect2 != null) {
rect.set(rect2);
} else {
super.getHotspotBounds(rect);
}
}
@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 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 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
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 getOpacity() {
Drawable drawable = this.mCurrDrawable;
if (drawable == null || !drawable.isVisible()) {
return -2;
}
return this.mDrawableContainerState.getOpacity();
}
@Override // android.graphics.drawable.Drawable
@RequiresApi(21)
public void getOutline(@NonNull Outline outline) {
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
drawable.getOutline(outline);
}
}
@Override // android.graphics.drawable.Drawable
public boolean getPadding(@NonNull Rect rect) {
boolean z2;
Rect constantPadding = this.mDrawableContainerState.getConstantPadding();
if (constantPadding != null) {
rect.set(constantPadding);
z2 = (constantPadding.right | ((constantPadding.left | constantPadding.top) | constantPadding.bottom)) != 0;
} else {
Drawable drawable = this.mCurrDrawable;
z2 = drawable != null ? drawable.getPadding(rect) : super.getPadding(rect);
}
if (needsMirroring()) {
int i = rect.left;
rect.left = rect.right;
rect.right = i;
}
return z2;
}
@Override // android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(@NonNull Drawable drawable) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
if (drawableContainerState != null) {
drawableContainerState.invalidateCache();
}
if (drawable == this.mCurrDrawable && getCallback() != null) {
getCallback().invalidateDrawable(this);
}
}
@Override // android.graphics.drawable.Drawable
public boolean isAutoMirrored() {
return this.mDrawableContainerState.mAutoMirrored;
}
@Override // android.graphics.drawable.Drawable
public boolean isStateful() {
return this.mDrawableContainerState.isStateful();
}
@Override // android.graphics.drawable.Drawable
public void jumpToCurrentState() {
boolean z2;
Drawable drawable = this.mLastDrawable;
boolean z3 = true;
if (drawable != null) {
drawable.jumpToCurrentState();
this.mLastDrawable = null;
z2 = true;
} else {
z2 = false;
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
drawable2.jumpToCurrentState();
if (this.mHasAlpha) {
this.mCurrDrawable.setAlpha(this.mAlpha);
}
}
if (this.mExitAnimationEnd != 0) {
this.mExitAnimationEnd = 0;
z2 = true;
}
if (this.mEnterAnimationEnd != 0) {
this.mEnterAnimationEnd = 0;
} else {
z3 = z2;
}
if (z3) {
invalidateSelf();
}
}
@Override // android.graphics.drawable.Drawable
@NonNull
public Drawable mutate() {
if (!this.mMutated && super.mutate() == this) {
DrawableContainerState cloneConstantState = cloneConstantState();
cloneConstantState.mutate();
setConstantState(cloneConstantState);
this.mMutated = true;
}
return this;
}
@Override // android.graphics.drawable.Drawable
public 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 onLayoutDirectionChanged(int i) {
return this.mDrawableContainerState.setLayoutDirection(i, getCurrentIndex());
}
@Override // android.graphics.drawable.Drawable
public 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 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.Callback
public void scheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable, long j) {
if (drawable == this.mCurrDrawable && getCallback() != null) {
getCallback().scheduleDrawable(this, runnable, j);
}
}
/* JADX WARNING: Removed duplicated region for block: B:31:0x006b */
/* JADX WARNING: Removed duplicated region for block: B:32:0x0073 */
public boolean selectDrawable(int i) {
Runnable runnable;
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 = ((long) this.mDrawableContainerState.mExitFadeDuration) + uptimeMillis;
} else {
this.mLastDrawable = null;
this.mExitAnimationEnd = 0;
}
} else {
Drawable drawable3 = this.mCurrDrawable;
if (drawable3 != null) {
drawable3.setVisible(false, false);
}
}
if (i >= 0) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
if (i < drawableContainerState.mNumChildren) {
Drawable child = drawableContainerState.getChild(i);
this.mCurrDrawable = child;
this.mCurIndex = i;
if (child != null) {
int i2 = this.mDrawableContainerState.mEnterFadeDuration;
if (i2 > 0) {
this.mEnterAnimationEnd = uptimeMillis + ((long) i2);
}
initializeDrawableForDisplay(child);
}
if (!(this.mEnterAnimationEnd == 0 && this.mExitAnimationEnd == 0)) {
runnable = this.mAnimationRunnable;
if (runnable != null) {
this.mAnimationRunnable = new AnonymousClass1();
} else {
unscheduleSelf(runnable);
}
animate(true);
}
invalidateSelf();
return true;
}
}
this.mCurrDrawable = null;
this.mCurIndex = -1;
runnable = this.mAnimationRunnable;
if (runnable != null) {
}
animate(true);
invalidateSelf();
return true;
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
if (!this.mHasAlpha || this.mAlpha != i) {
this.mHasAlpha = true;
this.mAlpha = i;
Drawable drawable = this.mCurrDrawable;
if (drawable == null) {
return;
}
if (this.mEnterAnimationEnd == 0) {
drawable.setAlpha(i);
} else {
animate(false);
}
}
}
@Override // android.graphics.drawable.Drawable
public void setAutoMirrored(boolean z2) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
if (drawableContainerState.mAutoMirrored != z2) {
drawableContainerState.mAutoMirrored = z2;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
DrawableCompat.setAutoMirrored(drawable, z2);
}
}
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
drawableContainerState.mHasColorFilter = true;
if (drawableContainerState.mColorFilter != colorFilter) {
drawableContainerState.mColorFilter = colorFilter;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
drawable.setColorFilter(colorFilter);
}
}
}
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;
}
public void setCurrentIndex(int i) {
selectDrawable(i);
}
@Override // android.graphics.drawable.Drawable
public void setDither(boolean z2) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
if (drawableContainerState.mDither != z2) {
drawableContainerState.mDither = z2;
Drawable drawable = this.mCurrDrawable;
if (drawable != null) {
drawable.setDither(z2);
}
}
}
public void setEnterFadeDuration(int i) {
this.mDrawableContainerState.mEnterFadeDuration = i;
}
public void setExitFadeDuration(int i) {
this.mDrawableContainerState.mExitFadeDuration = i;
}
@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, androidx.core.graphics.drawable.TintAwareDrawable
public void setTintList(ColorStateList colorStateList) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
drawableContainerState.mHasTintList = true;
if (drawableContainerState.mTintList != colorStateList) {
drawableContainerState.mTintList = colorStateList;
DrawableCompat.setTintList(this.mCurrDrawable, colorStateList);
}
}
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
public void setTintMode(@NonNull PorterDuff.Mode mode) {
DrawableContainerState drawableContainerState = this.mDrawableContainerState;
drawableContainerState.mHasTintMode = true;
if (drawableContainerState.mTintMode != mode) {
drawableContainerState.mTintMode = mode;
DrawableCompat.setTintMode(this.mCurrDrawable, mode);
}
}
@Override // android.graphics.drawable.Drawable
public boolean setVisible(boolean z2, boolean z3) {
boolean visible = super.setVisible(z2, z3);
Drawable drawable = this.mLastDrawable;
if (drawable != null) {
drawable.setVisible(z2, z3);
}
Drawable drawable2 = this.mCurrDrawable;
if (drawable2 != null) {
drawable2.setVisible(z2, z3);
}
return visible;
}
@Override // android.graphics.drawable.Drawable.Callback
public void unscheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable) {
if (drawable == this.mCurrDrawable && getCallback() != null) {
getCallback().unscheduleDrawable(this, runnable);
}
}
public final void updateDensity(Resources resources) {
this.mDrawableContainerState.updateDensity(resources);
}
}