package com.ss.android.ugc.aweme.ecommerce.delivery.page.logistic;

import X.070;
import X.0CB;
import X.0CH;
import X.0FB;
import X.2i8;
import X.36a;
import X.5An;
import X.6Is;
import X.BJ3;
import X.BTH;
import X.C03;
import X.C0X;
import X.C1S;
import X.C5374Byc;
import X.C5428BzU;
import X.C5429BzV;
import X.C5430BzW;
import X.C5431BzX;
import X.C5434Bza;
import X.C5439Bzf;
import X.C5502C1q;
import X.C5525C2n;
import X.C5526C2o;
import X.C5528C2q;
import X.C5531C2t;
import X.C5532C2u;
import X.C5533C2v;
import X.C5534C2w;
import X.C6394CZy;
import X.Crj;
import X.DV0;
import X.DrK;
import X.DrS;
import X.LnI;
import X.LsD;
import X.Ltt;
import X.M12;
import X.QNA;
import X.Qeg;
import X.Qen;
import android.content.Context;
import android.content.res.Resources;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.style.ForegroundColorSpan;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.ext.adapter.JediSimpleViewHolder;
import com.bytedance.jedi.ext.adapter.JediViewHolder;
import com.ss.android.ugc.aweme.ecommerce.api.model.FeeTag;
import com.ss.android.ugc.aweme.ecommerce.api.model.Price;
import com.ss.android.ugc.aweme.ecommerce.delivery.repo.dto.LogisticDTO;
import com.ss.android.ugc.aweme.ecommerce.delivery.repo.dto.LogisticTextDTO;
import com.ss.android.ugc.aweme.ecommerce.delivery.vm.DeliveryPanelState;
import com.ss.android.ugc.aweme.ecommerce.delivery.vm.DeliveryPanelViewModel;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.h.b.n;
import kotlin.o.y;

public final class LogisticAdapter extends DrS<Object> {
    public boolean LIZLLL;
    public final 0CH LJ;

    static {
        Covode.recordClassIndex(69919);
    }

    public final class LogisticViewHolder extends JediSimpleViewHolder<LogisticDTO> implements 6Is {
        public final /* synthetic */ LogisticAdapter LJFF;
        public final Crj LJI;

        static {
            Covode.recordClassIndex(69920);
        }

        public final DeliveryPanelViewModel LJIIL() {
            return (DeliveryPanelViewModel) this.LJI.getValue();
        }

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

        public final void LJ() {
            LogisticAdapter.super.LJ();
        }

        /* JADX WARNING: type inference failed for: r6v34, types: [android.view.View$OnClickListener, X.BzW] */
        /* JADX WARNING: type inference failed for: r5v6, types: [android.view.View$OnClickListener, X.Bza] */
        public final /* synthetic */ void LIZ(Object obj) {
            boolean z;
            String str;
            int i;
            String str2;
            String str3;
            String str4;
            boolean z2;
            List<FeeTag> feeTags;
            LogisticDTO logisticDTO = (LogisticDTO) obj;
            M12.LIZ(logisticDTO);
            BJ3 bj3 = BTH.LIZLLL;
            View view = this.itemView;
            n.LIZIZ(view, "");
            if (this.LJIIIIZZ != this.LJFF.getItemCount() - 1) {
                z = true;
            } else {
                z = false;
            }
            bj3.LIZ(view, z);
            View view2 = this.itemView;
            Qeg findViewById = view2.findViewById(2131363866);
            n.LIZIZ(findViewById, "");
            Price price = logisticDTO.LJFF;
            if (price == null || (str = price.getPriceStr()) == null) {
                str = "";
            }
            findViewById.setText(str);
            if (n.LIZ(logisticDTO.LJII, true)) {
                i = 2131099731;
            } else {
                i = 2131099750;
            }
            View view3 = this.itemView;
            n.LIZIZ(view3, "");
            view2.findViewById(2131363866).setTextColor(070.LIZJ(view3.getContext(), i));
            Qeg findViewById2 = view2.findViewById(2131368279);
            n.LIZIZ(findViewById2, "");
            TextPaint paint = findViewById2.getPaint();
            n.LIZIZ(paint, "");
            Qeg findViewById3 = view2.findViewById(2131368279);
            n.LIZIZ(findViewById3, "");
            TextPaint paint2 = findViewById3.getPaint();
            n.LIZIZ(paint2, "");
            paint.setFlags(paint2.getFlags() | 16);
            Qeg findViewById4 = view2.findViewById(2131368279);
            n.LIZIZ(findViewById4, "");
            LIZ(findViewById4, logisticDTO.LJI);
            Qeg findViewById5 = view2.findViewById(2131367002);
            n.LIZIZ(findViewById5, "");
            LogisticTextDTO logisticTextDTO = logisticDTO.LJIIIZ;
            String str5 = null;
            if (logisticTextDTO != null) {
                str2 = logisticTextDTO.LIZJ;
            } else {
                str2 = null;
            }
            LIZ(findViewById5, str2);
            Qeg findViewById6 = view2.findViewById(2131364107);
            n.LIZIZ(findViewById6, "");
            LogisticTextDTO logisticTextDTO2 = logisticDTO.LJIIIZ;
            if (logisticTextDTO2 != null) {
                str3 = logisticTextDTO2.LIZ;
            } else {
                str3 = null;
            }
            LIZ(findViewById6, str3);
            Qeg findViewById7 = view2.findViewById(2131371180);
            n.LIZIZ(findViewById7, "");
            LogisticTextDTO logisticTextDTO3 = logisticDTO.LJIIIZ;
            if (logisticTextDTO3 != null) {
                str4 = logisticTextDTO3.LJ;
            } else {
                str4 = null;
            }
            LIZ(findViewById7, str4);
            Qeg findViewById8 = view2.findViewById(2131364005);
            n.LIZIZ(findViewById8, "");
            LIZ(findViewById8, logisticDTO.LIZIZ);
            Qeg findViewById9 = view2.findViewById(2131370129);
            n.LIZIZ(findViewById9, "");
            LogisticTextDTO logisticTextDTO4 = logisticDTO.LJIIIZ;
            if (logisticTextDTO4 != null) {
                str5 = logisticTextDTO4.LIZIZ;
            }
            LIZ(findViewById9, str5);
            View view4 = this.itemView;
            n.LIZIZ(view4, "");
            ConstraintLayout findViewById10 = view4.findViewById(2131363355);
            n.LIZIZ(findViewById10, "");
            findViewById10.setOnClickListener(new C5430BzW(this, logisticDTO));
            DV0.LIZ(this, LJIIL(), C5431BzX.LIZ, new C5374Byc(view2, this, logisticDTO));
            withState(LJIIL(), new C5428BzU(view2, this, logisticDTO));
            LinearLayout linearLayout = (LinearLayout) view2.findViewById(2131367270);
            n.LIZIZ(linearLayout, "");
            if (logisticDTO.LJIILJJIL != null) {
                z2 = true;
            } else {
                z2 = false;
            }
            C5502C1q.LIZ((View) linearLayout, z2);
            LinearLayout linearLayout2 = (LinearLayout) view2.findViewById(2131367270);
            n.LIZIZ(linearLayout2, "");
            if (C5502C1q.LIZ((View) linearLayout2)) {
                ConstraintLayout findViewById11 = view2.findViewById(2131363355);
                n.LIZIZ(findViewById11, "");
                Resources system = Resources.getSystem();
                n.LIZIZ(system, "");
                Qen.LIZ(findViewById11, (Integer) null, (Integer) null, (Integer) null, Integer.valueOf(LnI.LIZ(TypedValue.applyDimension(1, 8.0f, system.getDisplayMetrics()))), false, 23);
            } else {
                ConstraintLayout findViewById12 = view2.findViewById(2131363355);
                n.LIZIZ(findViewById12, "");
                Resources system2 = Resources.getSystem();
                n.LIZIZ(system2, "");
                Qen.LIZ(findViewById12, (Integer) null, (Integer) null, (Integer) null, Integer.valueOf(LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system2.getDisplayMetrics()))), false, 23);
            }
            if (logisticDTO.LJIILJJIL != null) {
                withState(LJIIL(), new C5429BzV(view2, this, logisticDTO));
                if (36a.LIZ(logisticDTO.LJIILJJIL.LIZJ)) {
                    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                    SpannableString spannableString = new SpannableString(" ");
                    View view5 = this.itemView;
                    n.LIZIZ(view5, "");
                    Context context = view5.getContext();
                    n.LIZIZ(context, "");
                    QNA qna = new QNA(context, 2131755708);
                    Resources system3 = Resources.getSystem();
                    n.LIZIZ(system3, "");
                    int LIZ = LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system3.getDisplayMetrics()));
                    Resources system4 = Resources.getSystem();
                    n.LIZIZ(system4, "");
                    qna.setBounds(0, 0, LIZ, LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system4.getDisplayMetrics())));
                    View view6 = this.itemView;
                    n.LIZIZ(view6, "");
                    Context context2 = view6.getContext();
                    n.LIZIZ(context2, "");
                    qna.LIZJ(C5502C1q.LIZ(context2, 2131099731));
                    spannableString.setSpan(new C6394CZy(qna), 0, spannableString.length(), 33);
                    spannableStringBuilder.append(spannableString);
                    String str6 = logisticDTO.LJIILJJIL.LIZ;
                    if (str6 == null) {
                        str6 = " ";
                    }
                    SpannableString spannableString2 = new SpannableString(str6);
                    View view7 = this.itemView;
                    n.LIZIZ(view7, "");
                    Context context3 = view7.getContext();
                    n.LIZIZ(context3, "");
                    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(C5502C1q.LIZ(context3, 2131099731));
                    spannableString2.setSpan(new Ltt(62), 0, spannableString2.length(), 33);
                    spannableString2.setSpan(foregroundColorSpan, 0, spannableString2.length(), 33);
                    spannableStringBuilder.append(" ").append(spannableString2);
                    spannableStringBuilder.append(" ").append(logisticDTO.LJIILJJIL.LIZJ);
                    View view8 = this.itemView;
                    n.LIZIZ(view8, "");
                    Qeg findViewById13 = view8.findViewById(2131371828);
                    n.LIZIZ(findViewById13, "");
                    findViewById13.setText(spannableStringBuilder);
                }
                if (36a.LIZ(logisticDTO.LJIILJJIL.LIZIZ)) {
                    View view9 = this.itemView;
                    n.LIZIZ(view9, "");
                    LinearLayout linearLayout3 = (LinearLayout) view9.findViewById(2131367270);
                    n.LIZIZ(linearLayout3, "");
                    linearLayout3.setOnClickListener(new C5434Bza(view2, this, logisticDTO));
                }
            }
            Price price2 = logisticDTO.LJFF;
            if (price2 == null || (feeTags = price2.getFeeTags()) == null || feeTags.isEmpty()) {
                Qeg findViewById14 = view2.findViewById(2131363762);
                n.LIZIZ(findViewById14, "");
                C5502C1q.LIZ((View) findViewById14, false);
                return;
            }
            FeeTag feeTag = logisticDTO.LJFF.getFeeTags().get(0);
            Qeg findViewById15 = view2.findViewById(2131363762);
            n.LIZIZ(findViewById15, "");
            C5502C1q.LIZ((View) findViewById15, 36a.LIZ(feeTag.LIZ));
            if (feeTag.LIZ != null) {
                Qeg findViewById16 = view2.findViewById(2131363762);
                n.LIZIZ(findViewById16, "");
                findViewById16.setText(feeTag.LIZ);
            }
        }

        private final void LIZ(TextView textView, String str) {
            int i = 0;
            if (str == null || str.length() == 0) {
                i = 8;
            }
            textView.setVisibility(i);
            textView.setText(str);
        }

        /* JADX WARNING: Illegal instructions before constructor call */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public LogisticViewHolder(com.ss.android.ugc.aweme.ecommerce.delivery.page.logistic.LogisticAdapter r4, android.view.ViewGroup r5) {
            /*
                r3 = this;
                X.M12.LIZ(r5)
                r3.LJFF = r4
                android.content.Context r0 = r5.getContext()
                android.view.LayoutInflater r2 = android.view.LayoutInflater.from(r0)
                r1 = 2131559031(0x7f0d0277, float:1.8743395E38)
                r0 = 0
                android.view.View r1 = X.0HH.LIZ(r2, r1, r5, r0)
                java.lang.String r0 = ""
                kotlin.h.b.n.LIZIZ(r1, r0)
                r3.<init>(r1)
                java.lang.Class<com.ss.android.ugc.aweme.ecommerce.delivery.vm.DeliveryPanelViewModel> r1 = com.ss.android.ugc.aweme.ecommerce.delivery.vm.DeliveryPanelViewModel.class
                X.KEN r0 = X.KEM.LIZ
                X.D1G r1 = r0.LIZ(r1)
                X.BI3 r0 = new X.BI3
                r0.<init>(r3, r1, r1)
                X.Crj r0 = X.7he.LIZ(r0)
                r3.LJI = r0
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ecommerce.delivery.page.logistic.LogisticAdapter.LogisticViewHolder.<init>(com.ss.android.ugc.aweme.ecommerce.delivery.page.logistic.LogisticAdapter, android.view.ViewGroup):void");
        }

        public final void LIZ(String str, DeliveryPanelState deliveryPanelState, String str2, Integer num) {
            int i;
            Float f;
            String str3;
            String priceVal;
            String str4;
            List<Object> logisticList = deliveryPanelState.getLogisticList();
            if (logisticList != null) {
                ArrayList arrayList = new ArrayList();
                for (T next : logisticList) {
                    if (next instanceof LogisticDTO) {
                        arrayList.add(next);
                    }
                }
                Iterator it = arrayList.iterator();
                i = 0;
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    } else if (n.LIZ(((LogisticDTO) it.next()).LJIIJ, ((LogisticDTO) LJIIJJI()).LJIIJ)) {
                        break;
                    } else {
                        i++;
                    }
                }
            }
            i = -1;
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            Integer num2 = num;
            if (num2 != null) {
                num2.intValue();
                linkedHashMap.put("is_default", num2);
            }
            LogisticTextDTO logisticTextDTO = ((LogisticDTO) LJIIJJI()).LJIIIZ;
            String str5 = null;
            if (!(logisticTextDTO == null || (str4 = logisticTextDTO.LIZIZ) == null || y.LIZ(str4))) {
                linkedHashMap.put("track_status", str4);
            }
            Map<String, String> map = ((LogisticDTO) LJIIJJI()).LJIILL;
            if (map != null) {
                LinkedHashMap linkedHashMap2 = new LinkedHashMap();
                for (Map.Entry next2 : map.entrySet()) {
                    if (n.LIZ(next2.getKey(), "promotion_tag") || n.LIZ(next2.getKey(), "spend_more_amount") || n.LIZ(next2.getKey(), "spend_more_currency")) {
                        linkedHashMap2.put(next2.getKey(), next2.getValue());
                    }
                }
                linkedHashMap.putAll(linkedHashMap2);
            }
            String str6 = ((LogisticDTO) LJIIJJI()).LIZIZ;
            Map<String, String> map2 = ((LogisticDTO) LJIIJJI()).LJIILL;
            if (map2 != null) {
                str6 = map2.get("shipping_type");
            }
            String str7 = str2;
            if (str7 != null) {
                linkedHashMap.put("entrance_zone", str7);
            }
            C5439Bzf bzf = C5439Bzf.LIZJ;
            Price price = ((LogisticDTO) LJIIJJI()).LJFF;
            if (price == null || (priceVal = price.getPriceVal()) == null) {
                f = null;
            } else {
                f = 2i8.LIZJ(priceVal);
            }
            Price price2 = ((LogisticDTO) LJIIJJI()).LJFF;
            if (price2 != null) {
                str3 = price2.getCurrency();
            } else {
                str3 = null;
            }
            LogisticTextDTO logisticTextDTO2 = ((LogisticDTO) LJIIJJI()).LJIIIZ;
            if (logisticTextDTO2 != null) {
                str5 = logisticTextDTO2.LJFF;
            }
            bzf.LIZ(str, str6, "shipping_type", i, f, str3, str5, linkedHashMap);
        }
    }

    public final int getBasicItemViewType(int i) {
        return this.LIZ.LIZIZ(i);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public LogisticAdapter(0CH r3) {
        super(r3, (0FB) null, 6);
        M12.LIZ(r3);
        this.LJ = r3;
    }

    public final void LIZ(DrK<JediViewHolder<? extends 5An, ?>> drK) {
        M12.LIZ(drK);
        DrK unused = drK.LIZ(new C5525C2n(this), (LsD) null, C5532C2u.LIZ);
        DrK unused2 = drK.LIZ(new C1S(this), (LsD) null, C5533C2v.LIZ);
        DrK unused3 = drK.LIZ(new C5526C2o(this), (LsD) null, new C5528C2q(this));
        DrK unused4 = drK.LIZ(new C0X(this), (LsD) null, C5534C2w.LIZ);
        DrK unused5 = drK.LIZ(new C03(this), (LsD) null, C5531C2t.LIZ);
    }
}
