package com.zyao89.view.zloading;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import ඓ.ᕣ.K.K.AbstractC0747;
import ඓ.ᕣ.K.K.C0738;

public class ZLoadingView extends ImageView {

    /* renamed from: ʬ  reason: contains not printable characters */
    public AbstractC0747 f3403;

    /* renamed from: ῲ  reason: contains not printable characters */
    public C0738 f3404;

    public ZLoadingView(Context context) {
        this(context, null);
    }

    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        C0738 r0 = this.f3404;
        if (r0 != null) {
            r0.start();
        }
    }

    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        C0738 r0 = this.f3404;
        if (r0 != null) {
            r0.stop();
        }
    }

    public void onVisibilityChanged(View view, int i) {
        super.onVisibilityChanged(view, i);
        if (i == 0 && getVisibility() == 0) {
            C0738 r1 = this.f3404;
            if (r1 != null) {
                r1.start();
                return;
            }
            return;
        }
        C0738 r12 = this.f3404;
        if (r12 != null) {
            r12.stop();
        }
    }

    public void setLoadingBuilder(Z_TYPE z_type) {
        this.f3403 = z_type.newInstance();
        AbstractC0747 k = this.f3403;
        if (k != null) {
            this.f3404 = new C0738(k);
            C0738 r3 = this.f3404;
            Context context = getContext();
            AbstractC0747 k2 = r3.f3757;
            if (k2 != null) {
                k2.m2206(context);
                r3.f3757.m2200(context);
            }
            setImageDrawable(this.f3404);
            return;
        }
        throw new RuntimeException("mZLoadingBuilder is null.");
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1945(Z_TYPE z_type, double d) {
        setLoadingBuilder(z_type);
        AbstractC0747 k = this.f3403;
        if (k != null) {
            k.m2202(d);
            return;
        }
        throw new RuntimeException("mZLoadingBuilder is null.");
    }

    public ZLoadingView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, -1);
    }

    public ZLoadingView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        try {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.ZLoadingView);
            int i2 = obtainStyledAttributes.getInt(R$styleable.ZLoadingView_z_type, 0);
            int color = obtainStyledAttributes.getColor(R$styleable.ZLoadingView_z_color, -16777216);
            float f = obtainStyledAttributes.getFloat(R$styleable.ZLoadingView_z_duration_percent, 1.0f);
            obtainStyledAttributes.recycle();
            m1945(Z_TYPE.values()[i2], (double) f);
            setColorFilter(color);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
