package com.bytedance.sdk.openadsdk.utils;

import a3.r;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.bytedance.sdk.component.adexpress.dynamic.dynamicview.a;
import java.lang.ref.WeakReference;

/* JADX INFO: loaded from: classes2.dex */
public class ai implements com.bytedance.sdk.component.jnr.irt {
    private final WeakReference<ImageView> fm;

    public ai(ImageView imageView) {
        this.fm = new WeakReference<>(imageView);
    }

    @Override // com.bytedance.sdk.component.jnr.irt
    public void fm(com.bytedance.sdk.component.jnr.ku kuVar) {
        ImageView imageView = this.fm.get();
        if (imageView == null) {
            return;
        }
        try {
            Object objRo = kuVar.ro();
            if (objRo instanceof Bitmap) {
                imageView.setImageBitmap((Bitmap) objRo);
                return;
            }
            if (!(objRo instanceof Drawable)) {
                imageView.setVisibility(8);
                return;
            }
            if (Build.VERSION.SDK_INT >= 28 && r.D(objRo)) {
                a.h(objRo).start();
            }
            imageView.setImageDrawable((Drawable) objRo);
        } catch (Throwable unused) {
            imageView.setVisibility(8);
        }
    }

    @Override // com.bytedance.sdk.component.jnr.irt
    public void fm(int i10, String str, @Nullable Throwable th) {
        ImageView imageView = this.fm.get();
        if (imageView == null) {
            return;
        }
        imageView.setVisibility(8);
    }
}
