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

import X.0CB;
import X.0CH;
import X.2Pr;
import X.3G1;
import X.6Is;
import X.7he;
import X.BTH;
import X.C3362BHi;
import X.C4876Bqa;
import X.C5119BuV;
import X.C5142Bus;
import X.C5144Buu;
import X.C5145Buv;
import X.C5146Buw;
import X.C5151Bv1;
import X.C5502C1q;
import X.C6348CYe;
import X.CBZ;
import X.CYV;
import X.Crj;
import X.D1G;
import X.KEM;
import X.LeS;
import X.LnI;
import X.LsC;
import X.M12;
import X.Qeg;
import android.content.Context;
import android.content.res.Resources;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.jedi.ext.adapter.JediSimpleViewHolder;
import com.ss.android.ugc.aweme.ecommerce.combinepayment.ordersubmit.OrderSubmitViewModel;
import com.ss.android.ugc.aweme.ecommerce.libtrack.api.data.LaneParams;
import kotlin.h.b.n;

public final class PlatformDiscountsVH extends JediSimpleViewHolder<C5119BuV> implements 6Is {
    public final View LJFF;
    public final Crj LJI;

    static {
        Covode.recordClassIndex(69159);
    }

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

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

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

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public PlatformDiscountsVH(View view) {
        super(view);
        M12.LIZ(view);
        this.LJFF = view;
        D1G LIZ = KEM.LIZ.LIZ(OrderSubmitViewModel.class);
        this.LJI = 7he.LIZ(new C3362BHi(this, LIZ, LIZ));
    }

    /* JADX WARNING: type inference failed for: r0v5, types: [X.Bus, android.view.View$OnClickListener] */
    public final /* synthetic */ void LIZ(Object obj) {
        int LIZ;
        int LIZ2;
        int LIZ3;
        boolean z;
        boolean z2;
        String str;
        MethodCollector.i(1745);
        C5119BuV buV = (C5119BuV) obj;
        M12.LIZ(buV);
        View view = this.LJFF;
        boolean LIZ4 = C4876Bqa.LIZ.LIZ();
        Qeg findViewById = view.findViewById(2131368561);
        n.LIZIZ(findViewById, "");
        C5502C1q.LIZ((TextView) findViewById, (CharSequence) buV.LIZ);
        ConstraintLayout findViewById2 = view.findViewById(2131368562);
        n.LIZIZ(findViewById2, "");
        findViewById2.setOnClickListener(new C5142Bus(view, LIZ4, this, buV));
        CBZ.LIZ(view, (CYV) new C6348CYe(), (LsC<? super LaneParams, 2Pr>) new C5144Buu(LIZ4, this, buV));
        int i = 1;
        byte b = 0;
        if (!(!buV.LJ.isEmpty()) || !LIZ4) {
            HorizontalScrollView horizontalScrollView = (HorizontalScrollView) view.findViewById(2131363803);
            n.LIZIZ(horizontalScrollView, "");
            C5502C1q.LIZ((View) horizontalScrollView, false);
            Qeg findViewById3 = view.findViewById(2131371987);
            n.LIZIZ(findViewById3, "");
            C5502C1q.LIZ((View) findViewById3, buV.LIZJ);
            MethodCollector.o(1745);
            return;
        }
        Qeg findViewById4 = view.findViewById(2131371987);
        n.LIZIZ(findViewById4, "");
        C5502C1q.LIZ((View) findViewById4, false);
        HorizontalScrollView horizontalScrollView2 = (HorizontalScrollView) view.findViewById(2131363803);
        n.LIZIZ(horizontalScrollView2, "");
        C5502C1q.LIZ((View) horizontalScrollView2, true);
        LinearLayout linearLayout = (LinearLayout) view.findViewById(2131363804);
        n.LIZIZ(linearLayout, "");
        if (linearLayout.getChildCount() > 0) {
            ((LinearLayout) view.findViewById(2131363804)).removeAllViews();
        }
        int size = buV.LJ.size();
        float f = 7.0f;
        int i2 = 2;
        if (size == 1) {
            int LIZIZ = 3G1.LIZIZ(view.getContext());
            Resources system = Resources.getSystem();
            n.LIZIZ(system, "");
            LIZ = LIZIZ - (LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system.getDisplayMetrics())) * 2);
        } else if (size == 2) {
            int LIZIZ2 = 3G1.LIZIZ(view.getContext());
            Resources system2 = Resources.getSystem();
            n.LIZIZ(system2, "");
            int LIZ5 = LIZIZ2 - (LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system2.getDisplayMetrics())) * 2);
            Resources system3 = Resources.getSystem();
            n.LIZIZ(system3, "");
            LIZ = (LIZ5 - LnI.LIZ(TypedValue.applyDimension(1, 7.0f, system3.getDisplayMetrics()))) / 2;
        } else {
            Resources system4 = Resources.getSystem();
            n.LIZIZ(system4, "");
            LIZ = LnI.LIZ(TypedValue.applyDimension(1, 147.0f, system4.getDisplayMetrics()));
        }
        if (size > 1) {
            Resources system5 = Resources.getSystem();
            n.LIZIZ(system5, "");
            LIZ2 = LnI.LIZ(TypedValue.applyDimension(1, 44.0f, system5.getDisplayMetrics()));
        } else {
            Resources system6 = Resources.getSystem();
            n.LIZIZ(system6, "");
            LIZ2 = LnI.LIZ(TypedValue.applyDimension(1, 48.0f, system6.getDisplayMetrics()));
        }
        if (size > 1) {
            Resources system7 = Resources.getSystem();
            n.LIZIZ(system7, "");
            LIZ3 = LnI.LIZ(TypedValue.applyDimension(1, 8.0f, system7.getDisplayMetrics()));
        } else {
            Resources system8 = Resources.getSystem();
            n.LIZIZ(system8, "");
            LIZ3 = LnI.LIZ(TypedValue.applyDimension(1, 14.0f, system8.getDisplayMetrics()));
        }
        int i3 = 0;
        for (C5151Bv1 next : buV.LJ) {
            int i4 = i3 + 1;
            if (i3 < 0) {
                LeS.LIZIZ();
            }
            C5151Bv1 bv1 = next;
            Context context = view.getContext();
            n.LIZIZ(context, "");
            C5145Buv buv = new C5145Buv(context, b);
            String str2 = bv1.LIZIZ;
            if (str2 != null) {
                buv.setDiscountTitle(str2);
            }
            String str3 = bv1.LJ;
            if (str3 != null) {
                buv.setButtonText(str3);
                buv.setButtonTextMarginEnd(LIZ3);
            }
            if (size == i && (str = bv1.LIZJ) != null) {
                buv.setDiscountThresholdText(str);
            }
            String str4 = bv1.LIZLLL;
            if (str4 != null) {
                buv.setDiscountDescription(str4);
            }
            Integer num = bv1.LJFF;
            if (num != null) {
                int intValue = num.intValue();
                if (size == i) {
                    z2 = true;
                } else {
                    z2 = false;
                }
                buv.LIZ(intValue, z2);
            } else {
                if (size == i) {
                    z = true;
                } else {
                    z = false;
                }
                buv.LIZ(i2, z);
            }
            if (i3 == buV.LJ.size() - i) {
                ConstraintLayout LIZ6 = buv.LIZ(2131363702);
                n.LIZIZ(LIZ6, "");
                ViewGroup.LayoutParams layoutParams = LIZ6.getLayoutParams();
                if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
                    layoutParams = null;
                }
                ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
                if (marginLayoutParams != null) {
                    marginLayoutParams.setMarginEnd(b);
                }
                buv.LIZ(LIZ, Integer.valueOf(LIZ2));
            } else {
                Resources system9 = Resources.getSystem();
                n.LIZIZ(system9, "");
                buv.LIZ(LnI.LIZ(TypedValue.applyDimension(i, f, system9.getDisplayMetrics())) + LIZ, Integer.valueOf(LIZ2));
            }
            ((LinearLayout) view.findViewById(2131363804)).addView(buv);
            int i5 = size;
            int i6 = LIZ3;
            View view2 = view;
            int i7 = i3;
            C5151Bv1 bv12 = bv1;
            buv.setExposureCallback(new C5146Buw(bv12, i7, view2, i6, i5, LIZ, LIZ2, this, buV));
            i3 = i4;
            size = size;
            i2 = 2;
            f = 7.0f;
            b = 0;
            i = 1;
        }
        MethodCollector.o(1745);
    }
}
