package defpackage;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import java.util.ArrayList;

/* renamed from: ᵧᵩʢᵸ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3667 extends Drawable implements Animatable {

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public Rect f13661;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public Paint f13662;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public boolean f13663;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public int f13664;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public boolean f13665;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final C4727 f13667;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public boolean f13668;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public boolean f13669;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public boolean f13666 = true;

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public final int f13660 = -1;

    public C3667(C4727 c4727) {
        this.f13667 = c4727;
    }

    @Override // android.graphics.drawable.Drawable
    public final void draw(Canvas canvas) {
        if (this.f13668) {
            return;
        }
        if (this.f13663) {
            int intrinsicWidth = getIntrinsicWidth();
            int intrinsicHeight = getIntrinsicHeight();
            Rect bounds = getBounds();
            if (this.f13661 == null) {
                this.f13661 = new Rect();
            }
            Gravity.apply(119, intrinsicWidth, intrinsicHeight, bounds, this.f13661);
            this.f13663 = false;
        }
        C1578 c1578 = (C1578) this.f13667.f17459;
        C1116 c1116 = c1578.f6251;
        Bitmap bitmap = c1116 != null ? c1116.f4825 : c1578.f6247;
        if (this.f13661 == null) {
            this.f13661 = new Rect();
        }
        Rect rect = this.f13661;
        if (this.f13662 == null) {
            this.f13662 = new Paint(2);
        }
        canvas.drawBitmap(bitmap, (Rect) null, rect, this.f13662);
    }

    @Override // android.graphics.drawable.Drawable
    public final Drawable.ConstantState getConstantState() {
        return this.f13667;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicHeight() {
        return ((C1578) this.f13667.f17459).f6246;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicWidth() {
        return ((C1578) this.f13667.f17459).f6255;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getOpacity() {
        return -2;
    }

    @Override // android.graphics.drawable.Animatable
    public final boolean isRunning() {
        return this.f13665;
    }

    @Override // android.graphics.drawable.Drawable
    public final void onBoundsChange(Rect rect) {
        super.onBoundsChange(rect);
        this.f13663 = true;
    }

    @Override // android.graphics.drawable.Drawable
    public final void setAlpha(int i) {
        if (this.f13662 == null) {
            this.f13662 = new Paint(2);
        }
        this.f13662.setAlpha(i);
    }

    @Override // android.graphics.drawable.Drawable
    public final void setColorFilter(ColorFilter colorFilter) {
        if (this.f13662 == null) {
            this.f13662 = new Paint(2);
        }
        this.f13662.setColorFilter(colorFilter);
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean setVisible(boolean z, boolean z2) {
        ᵼᵙᵖᵱ.ᵻᵢﹳᵰ("Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility.", !this.f13668);
        this.f13666 = z;
        if (!z) {
            this.f13665 = false;
            C1578 c1578 = (C1578) this.f13667.f17459;
            ArrayList arrayList = c1578.f6250;
            arrayList.remove(this);
            if (arrayList.isEmpty()) {
                c1578.f6249 = false;
            }
        } else if (this.f13669) {
            m8257();
        }
        return super.setVisible(z, z2);
    }

    @Override // android.graphics.drawable.Animatable
    public final void start() {
        this.f13669 = true;
        this.f13664 = 0;
        if (this.f13666) {
            m8257();
        }
    }

    @Override // android.graphics.drawable.Animatable
    public final void stop() {
        this.f13669 = false;
        this.f13665 = false;
        C1578 c1578 = (C1578) this.f13667.f17459;
        ArrayList arrayList = c1578.f6250;
        arrayList.remove(this);
        if (arrayList.isEmpty()) {
            c1578.f6249 = false;
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m8257() {
        ᵼᵙᵖᵱ.ᵻᵢﹳᵰ("You cannot start a recycled Drawable. Ensure thatyou clear any references to the Drawable when clearing the corresponding request.", !this.f13668);
        C1578 c1578 = (C1578) this.f13667.f17459;
        if (c1578.f6252.f10432.f4849 == 1) {
            invalidateSelf();
            return;
        }
        if (this.f13665) {
            return;
        }
        this.f13665 = true;
        ArrayList arrayList = c1578.f6250;
        if (c1578.f6257) {
            ᵹˉᵞ.ᵳٴᵶ("Cannot subscribe to a cleared frame loader");
            return;
        }
        if (arrayList.contains(this)) {
            ᵹˉᵞ.ᵳٴᵶ("Cannot subscribe twice in a row");
            return;
        }
        boolean zIsEmpty = arrayList.isEmpty();
        arrayList.add(this);
        if (zIsEmpty && !c1578.f6249) {
            c1578.f6249 = true;
            c1578.f6257 = false;
            c1578.m4554();
        }
        invalidateSelf();
    }
}
