package pl.droidsonroids.gif; import android.content.Context; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Parcelable; import android.util.AttributeSet; import android.widget.TextView; import androidx.annotation.RequiresApi; import defpackage.cx5; import java.io.IOException; public class GifTextView extends TextView { /* renamed from: a reason: collision with root package name */ public cx5.b f31042a; public GifTextView(Context context) { super(context); } private void setBackgroundInternal(Drawable drawable) { if (Build.VERSION.SDK_INT >= 16) { setBackground(drawable); } else { setBackgroundDrawable(drawable); } } public final void a() { if (this.f31042a.f25652b >= 0) { for (Drawable drawable : getCompoundDrawables()) { cx5.a(this.f31042a.f25652b, drawable); } if (Build.VERSION.SDK_INT >= 17) { for (Drawable drawable2 : getCompoundDrawablesRelative()) { cx5.a(this.f31042a.f25652b, drawable2); } } cx5.a(this.f31042a.f25652b, getBackground()); } } public final Drawable b(int i) { if (i == 0) { return null; } Resources resources = getResources(); String resourceTypeName = resources.getResourceTypeName(i); if (!isInEditMode() && cx5.f25650a.contains(resourceTypeName)) { try { return new ax5(resources, i); } catch (Resources.NotFoundException | IOException unused) { } } if (Build.VERSION.SDK_INT >= 21) { return resources.getDrawable(i, getContext().getTheme()); } return resources.getDrawable(i); } public final void c(Drawable[] drawableArr) { for (Drawable drawable : drawableArr) { if (drawable != null) { drawable.setVisible(false, false); } } } public final void d(AttributeSet attributeSet, int i, int i2) { if (attributeSet != null) { Drawable b2 = b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "drawableLeft", 0)); Drawable b3 = b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "drawableTop", 0)); Drawable b4 = b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "drawableRight", 0)); Drawable b5 = b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "drawableBottom", 0)); Drawable b6 = b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "drawableStart", 0)); Drawable b7 = b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "drawableEnd", 0)); if (Build.VERSION.SDK_INT >= 17) { if (getLayoutDirection() == 0) { if (b6 == null) { b6 = b2; } if (b7 == null) { b7 = b4; } } else { if (b6 == null) { b6 = b4; } if (b7 == null) { b7 = b2; } } setCompoundDrawablesRelativeWithIntrinsicBounds(b6, b3, b7, b5); setCompoundDrawablesWithIntrinsicBounds(b2, b3, b4, b5); } else { setCompoundDrawablesWithIntrinsicBounds(b2, b3, b4, b5); } setBackgroundInternal(b(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "background", 0))); this.f31042a = new cx5.b(this, attributeSet, i, i2); a(); } this.f31042a = new cx5.b(); } public void onDetachedFromWindow() { super.onDetachedFromWindow(); c(getCompoundDrawables()); if (Build.VERSION.SDK_INT >= 17) { c(getCompoundDrawablesRelative()); } } public void onRestoreInstanceState(Parcelable parcelable) { if (!(parcelable instanceof GifViewSavedState)) { super.onRestoreInstanceState(parcelable); return; } GifViewSavedState gifViewSavedState = (GifViewSavedState) parcelable; super.onRestoreInstanceState(gifViewSavedState.getSuperState()); Drawable[] compoundDrawables = getCompoundDrawables(); gifViewSavedState.a(compoundDrawables[0], 0); gifViewSavedState.a(compoundDrawables[1], 1); gifViewSavedState.a(compoundDrawables[2], 2); gifViewSavedState.a(compoundDrawables[3], 3); if (Build.VERSION.SDK_INT >= 17) { Drawable[] compoundDrawablesRelative = getCompoundDrawablesRelative(); gifViewSavedState.a(compoundDrawablesRelative[0], 4); gifViewSavedState.a(compoundDrawablesRelative[2], 5); } gifViewSavedState.a(getBackground(), 6); } public Parcelable onSaveInstanceState() { Drawable[] drawableArr = new Drawable[7]; if (this.f31042a.f25651a) { Drawable[] compoundDrawables = getCompoundDrawables(); System.arraycopy(compoundDrawables, 0, drawableArr, 0, compoundDrawables.length); if (Build.VERSION.SDK_INT >= 17) { Drawable[] compoundDrawablesRelative = getCompoundDrawablesRelative(); drawableArr[4] = compoundDrawablesRelative[0]; drawableArr[5] = compoundDrawablesRelative[2]; } drawableArr[6] = getBackground(); } return new GifViewSavedState(super.onSaveInstanceState(), drawableArr); } public void setBackgroundResource(int i) { setBackgroundInternal(b(i)); } @Override // android.widget.TextView @RequiresApi(17) public void setCompoundDrawablesRelativeWithIntrinsicBounds(int i, int i2, int i3, int i4) { setCompoundDrawablesRelativeWithIntrinsicBounds(b(i), b(i2), b(i3), b(i4)); } @Override // android.widget.TextView public void setCompoundDrawablesWithIntrinsicBounds(int i, int i2, int i3, int i4) { setCompoundDrawablesWithIntrinsicBounds(b(i), b(i2), b(i3), b(i4)); } public void setFreezesAnimation(boolean z) { this.f31042a.f25651a = z; } public GifTextView(Context context, AttributeSet attributeSet) { super(context, attributeSet); d(attributeSet, 0, 0); } public GifTextView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); d(attributeSet, i, 0); } }