package com.ss.android.ugc.aweme.ecommerce.combinepayment.ordersubmit.viewholder;

import X.0CB;
import X.0CH;
import X.2k0;
import X.36a;
import X.4ma;
import X.6Is;
import X.6d9;
import X.B3G;
import X.BTH;
import X.C5349ByD;
import X.C5391Byt;
import X.C5392Byu;
import X.J8H;
import X.M12;
import X.QHW;
import X.QJt;
import X.Qeg;
import X.TjA;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ImageSpan;
import android.view.View;
import android.widget.FrameLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.ext.adapter.JediSimpleViewHolder;
import com.bytedance.lighten.loader.SmartImageView;
import com.ss.android.ugc.aweme.ecommerce.service.vo.Image;
import java.util.List;
import kotlin.h.b.n;

public final class AnnouncementVH extends JediSimpleViewHolder<C5392Byu> implements 6Is {
    public final View LJFF;

    static {
        Covode.recordClassIndex(69109);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final void LJ() {
        AnnouncementVH.super.LJ();
        BTH.LIZLLL.LIZ(this.LJFF, false);
    }

    /* JADX WARNING: type inference failed for: r0v39, types: [android.view.View$OnClickListener, X.Byt] */
    public final /* synthetic */ void LIZ(Object obj) {
        String str;
        Spanned fromHtml;
        List<String> urls;
        String str2;
        List<String> urls2;
        B3G imageUrlModel;
        C5392Byu byu = (C5392Byu) obj;
        M12.LIZ(byu);
        View view = this.LJFF;
        String str3 = "";
        if (36a.LIZ(byu.LIZLLL)) {
            FrameLayout frameLayout = (FrameLayout) view.findViewById(2131362347);
            n.LIZIZ(frameLayout, str3);
            frameLayout.setOnClickListener(new C5391Byt(view, byu));
            J8H findViewById = view.findViewById(2131362391);
            n.LIZIZ(findViewById, str3);
            findViewById.setVisibility(0);
        } else {
            J8H findViewById2 = view.findViewById(2131362391);
            n.LIZIZ(findViewById2, str3);
            findViewById2.setVisibility(8);
            ((FrameLayout) view.findViewById(2131362347)).setOnClickListener((View.OnClickListener) null);
        }
        SmartImageView findViewById3 = view.findViewById(2131362346);
        n.LIZIZ(findViewById3, str3);
        findViewById3.setVisibility(8);
        Image image = byu.LJ;
        if (!(image == null || (imageUrlModel = image.toImageUrlModel()) == null)) {
            SmartImageView findViewById4 = view.findViewById(2131362346);
            n.LIZIZ(findViewById4, str3);
            findViewById4.setVisibility(0);
            QJt LIZ = QHW.LIZ(imageUrlModel);
            LIZ.LJJII = 4ma.MEDIUM;
            LIZ.LJJIIZ = view.findViewById(2131362346);
            LIZ.LIZJ();
        }
        Image image2 = byu.LIZJ;
        if (image2 == null || (urls = image2.getUrls()) == null || urls.size() <= 0) {
            str = byu.LIZIZ;
        } else {
            StringBuilder sb = new StringBuilder("<img src='");
            Image image3 = byu.LIZJ;
            if (image3 == null || (urls2 = image3.getUrls()) == null) {
                str2 = null;
            } else {
                str2 = urls2.get(0);
            }
            sb.append(str2);
            sb.append("'/> ");
            sb.append(byu.LIZIZ);
            str = sb.toString();
        }
        if (Build.VERSION.SDK_INT >= 24) {
            Context context = view.getContext();
            n.LIZIZ(context, str3);
            Qeg findViewById5 = view.findViewById(2131362348);
            n.LIZIZ(findViewById5, str3);
            fromHtml = Html.fromHtml(str, 0, new TjA(context, findViewById5), (Html.TagHandler) null);
        } else {
            Context context2 = view.getContext();
            n.LIZIZ(context2, str3);
            Qeg findViewById6 = view.findViewById(2131362348);
            n.LIZIZ(findViewById6, str3);
            fromHtml = Html.fromHtml(str, new TjA(context2, findViewById6), (Html.TagHandler) null);
        }
        if (fromHtml instanceof SpannableStringBuilder) {
            for (ImageSpan imageSpan : (ImageSpan[]) fromHtml.getSpans(0, fromHtml.length(), ImageSpan.class)) {
                int spanStart = fromHtml.getSpanStart(imageSpan);
                int spanEnd = fromHtml.getSpanEnd(imageSpan);
                n.LIZIZ(imageSpan, str3);
                Drawable drawable = imageSpan.getDrawable();
                n.LIZIZ(drawable, str3);
                SpannableStringBuilder spannableStringBuilder = (SpannableStringBuilder) fromHtml;
                spannableStringBuilder.setSpan(new 6d9(drawable), spanStart, spanEnd, 34);
                spannableStringBuilder.removeSpan(imageSpan);
            }
        }
        Qeg findViewById7 = view.findViewById(2131362348);
        n.LIZIZ(findViewById7, str3);
        findViewById7.setText(fromHtml);
        String str4 = byu.LIZ;
        if (str4 != null) {
            str3 = str4;
        }
        M12.LIZ(str3);
        2k0.LIZ.LIZ("tiktokec_banner_show", new C5349ByD(str3));
    }
}
