package com.bytedance.adsdk.ugeno.ef.yz;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import com.bytedance.adsdk.ugeno.core.ajl;
import com.bytedance.adsdk.ugeno.core.ku;
import com.bytedance.adsdk.ugeno.fm;
import com.bytedance.adsdk.ugeno.jnr;
import com.bytedance.adsdk.ugeno.wsy.wu;
import com.bytedance.adsdk.ugeno.wsy.yz;
import j4.a;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class lb extends com.bytedance.adsdk.ugeno.ro.lb<fm> {
    protected ImageView.ScaleType cyr;
    private float ex;
    protected String fm;
    private float ky;
    private float lsa;
    protected String po;
    protected boolean ucr;
    private int vod;
    private int wjb;

    public lb(Context context) {
        super(context);
        this.cyr = ImageView.ScaleType.FIT_XY;
        this.vod = -1;
        this.lsa = -1.0f;
        this.ex = -1.0f;
        this.wjb = 0;
        this.ky = 50.0f;
    }

    public String lb() {
        return this.po;
    }

    public void onz(String str) {
        this.fm = str;
    }

    private ImageView.ScaleType dsz(String str) {
        ImageView.ScaleType scaleType;
        scaleType = ImageView.ScaleType.FIT_XY;
        str.getClass();
        switch (str) {
            case "center":
                return ImageView.ScaleType.CENTER;
            case "fitEnd":
                return ImageView.ScaleType.FIT_END;
            case "fitStart":
                return ImageView.ScaleType.FIT_START;
            case "centerInside":
                return ImageView.ScaleType.CENTER_INSIDE;
            case "fit":
            case "fitCenter":
                return ImageView.ScaleType.FIT_CENTER;
            case "crop":
            case "centerCrop":
                return ImageView.ScaleType.CENTER_CROP;
            case "fill":
            case "fitXY":
            default:
                return scaleType;
        }
    }

    private void ef() {
        if (TextUtils.isEmpty(this.fm)) {
            return;
        }
        ((fm) this.jnr).setImageDrawable(null);
        if (this.fm.startsWith("local://")) {
            try {
                String strReplace = this.fm.replace("local://", "");
                if (TextUtils.equals(lb(), "raw")) {
                    ((fm) this.jnr).setImageResource(yz.fm(this.ro, strReplace));
                    return;
                } else {
                    fm((ImageView) this.jnr, strReplace);
                    return;
                }
            } catch (Throwable unused) {
                return;
            }
        }
        if (!this.fm.startsWith("@")) {
            vt();
            return;
        }
        try {
            ((fm) this.jnr).setImageResource(Integer.parseInt(this.fm.substring(1)));
        } catch (Exception unused2) {
        }
    }

    private void vt() {
        if (this.lsa > 0.0f) {
            jnr.fm().ro().fm(this.f6374ef, this.fm, new fm.InterfaceC0016fm() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.1
                @Override // com.bytedance.adsdk.ugeno.fm.InterfaceC0016fm
                public void fm(Bitmap bitmap) {
                    if (bitmap == null) {
                        if (((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs != null) {
                            ajl unused = ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs;
                            return;
                        }
                        return;
                    }
                    if (((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs != null) {
                        ajl unused2 = ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs;
                    }
                    final Bitmap bitmapFm = wu.fm(((com.bytedance.adsdk.ugeno.ro.lb) lb.this).ro, bitmap, (int) lb.this.lsa);
                    if (bitmapFm != null) {
                        wu.fm(new Runnable() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.1.1
                            @Override // java.lang.Runnable
                            public void run() {
                                ((fm) ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).jnr).setImageBitmap(bitmapFm);
                            }
                        });
                    }
                    lb lbVar = lb.this;
                    if (lbVar.ucr || lbVar.ex > 0.0f) {
                        Bitmap bitmapFm2 = wu.fm(((com.bytedance.adsdk.ugeno.ro.lb) lb.this).ro, bitmap, lb.this.ex > 0.0f ? (int) lb.this.ex : 10);
                        if (bitmapFm2 != null) {
                            final BitmapDrawable bitmapDrawable = new BitmapDrawable(((com.bytedance.adsdk.ugeno.ro.lb) lb.this).ro.getResources(), bitmapFm2);
                            wu.fm(new Runnable() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.1.2
                                @Override // java.lang.Runnable
                                public void run() {
                                    ((fm) ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).jnr).setBackground(bitmapDrawable);
                                }
                            });
                        }
                    }
                }
            });
            return;
        }
        com.bytedance.adsdk.ugeno.fm fmVarRo = jnr.fm().ro();
        ku kuVar = this.f6374ef;
        String str = this.fm;
        T t10 = this.jnr;
        fmVarRo.fm(kuVar, str, (ImageView) t10, ((fm) t10).getWidth(), ((fm) this.jnr).getHeight(), new fm.InterfaceC0016fm() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.2
            @Override // com.bytedance.adsdk.ugeno.fm.InterfaceC0016fm
            public void fm(Bitmap bitmap) {
                if (bitmap == null) {
                    if (((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs != null) {
                        ajl unused = ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs;
                    }
                } else if (((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs != null) {
                    ajl unused2 = ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).grs;
                }
            }
        });
        if (this.ucr || this.ex > 0.0f) {
            jnr.fm().ro().fm(this.f6374ef, this.fm, new fm.InterfaceC0016fm() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.3
                @Override // com.bytedance.adsdk.ugeno.fm.InterfaceC0016fm
                public void fm(Bitmap bitmap) {
                    if (bitmap == null) {
                        return;
                    }
                    final Bitmap bitmapFm = wu.fm(((com.bytedance.adsdk.ugeno.ro.lb) lb.this).ro, bitmap, lb.this.ex > 0.0f ? (int) lb.this.ex : 10);
                    wu.fm(new Runnable() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.3.1
                        @Override // java.lang.Runnable
                        public void run() {
                            if (bitmapFm != null) {
                                ((fm) ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).jnr).setBackground(new BitmapDrawable(((com.bytedance.adsdk.ugeno.ro.lb) lb.this).ro.getResources(), bitmapFm));
                            }
                        }
                    });
                }
            });
        }
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void ro() {
        super.ro();
        ef();
        ((fm) this.jnr).setScaleType(this.cyr);
        ((fm) this.jnr).setBorderColor(this.ado);
        ((fm) this.jnr).setCornerRadius(this.f6385qf);
        ((fm) this.jnr).setBorderWidth(this.mj);
        int i10 = this.vod;
        if (i10 != -1) {
            ((fm) this.jnr).setColorFilter(i10);
        }
        ((fm) this.jnr).setEraseEnabled(this.wjb == 1);
        ((fm) this.jnr).setEraseRadius(this.ky);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb, com.bytedance.adsdk.ugeno.yz
    public void wsy() {
        super.wsy();
        ((fm) this.jnr).post(new Runnable() { // from class: com.bytedance.adsdk.ugeno.ef.yz.lb.4
            @Override // java.lang.Runnable
            public void run() {
                Drawable drawable = ((fm) ((com.bytedance.adsdk.ugeno.ro.lb) lb.this).jnr).getDrawable();
                if (Build.VERSION.SDK_INT < 28 || !a.x(drawable)) {
                    return;
                }
                a.f(drawable).start();
            }
        });
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb, com.bytedance.adsdk.ugeno.yz
    public void wu() {
        super.wu();
        Drawable drawable = ((fm) this.jnr).getDrawable();
        if (Build.VERSION.SDK_INT < 28 || !a.x(drawable)) {
            return;
        }
        a.f(drawable).stop();
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    /* JADX INFO: renamed from: yz, reason: merged with bridge method [inline-methods] */
    public fm fm() {
        fm fmVar = new fm(this.ro);
        fmVar.fm(this);
        return fmVar;
    }

    public void fm(ImageView imageView, String str) {
        imageView.setImageResource(yz.ro(this.ro, str));
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void fm(String str, String str2) {
        T t10;
        if (TextUtils.isEmpty(str)) {
        }
        super.fm(str, str2);
        str.getClass();
        switch (str) {
            case "scaleMode":
            case "scaleType":
                this.cyr = dsz(str2);
                break;
            case "imageBlur":
                this.lsa = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                break;
            case "eraseRadius":
                float fFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 50.0f);
                this.ky = fFm;
                T t11 = this.jnr;
                if (t11 != 0) {
                    ((fm) t11).setEraseRadius(fFm);
                    break;
                }
                break;
            case "isBgGaussianBlur":
                this.ucr = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, false);
                break;
            case "src":
                this.fm = str2;
                break;
            case "erase":
                int iFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0);
                this.wjb = iFm;
                if (iFm == 1 && (t10 = this.jnr) != 0) {
                    ((fm) t10).setEraseEnabled(true);
                    break;
                }
                break;
            case "tintColor":
                this.vod = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2);
                break;
            case "imageBgBlur":
                this.ex = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                break;
        }
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb, com.bytedance.adsdk.ugeno.yz
    public void fm(String str, Map<String, Object> map) {
        this.wsy = (com.bytedance.adsdk.ugeno.ro.fm) ro((com.bytedance.adsdk.ugeno.ro.lb) this);
        ArrayList arrayList = new ArrayList();
        arrayList.add(pkk());
        Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            arrayList.add(it.next().getValue());
        }
        fm(this.wsy, str, arrayList.toArray());
    }

    private void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar, String str, Object... objArr) {
        List<com.bytedance.adsdk.ugeno.ro.lb<View>> listEf;
        if (lbVar == null) {
            return;
        }
        lbVar.fm(str, objArr);
        if (!(lbVar instanceof com.bytedance.adsdk.ugeno.ro.fm) || (listEf = ((com.bytedance.adsdk.ugeno.ro.fm) lbVar).ef()) == null || listEf.isEmpty()) {
            return;
        }
        Iterator<com.bytedance.adsdk.ugeno.ro.lb<View>> it = listEf.iterator();
        while (it.hasNext()) {
            fm(it.next(), str, objArr);
        }
    }
}
