package com.ss.android.ugc.aweme.discover.adapter;

import X.0CB;
import X.0CC;
import X.0CH;
import X.0EG;
import X.0GV;
import X.0GZ;
import X.0Gf;
import X.0Gp;
import X.2ha;
import X.2nK;
import X.3F7;
import X.3G1;
import X.7he;
import X.9bx;
import X.BIQ;
import X.C3232LDj;
import X.C4097LeS;
import X.C4105Lea;
import X.C4116Lel;
import X.C4645LnI;
import X.CX1;
import X.CX3;
import X.Crj;
import X.Cwu;
import X.D1G;
import X.ESC;
import X.FLr;
import X.HeD;
import X.JBY;
import X.KEM;
import X.LWC;
import X.LWG;
import X.LWJ;
import X.LWK;
import X.LWO;
import X.LWP;
import X.LWQ;
import X.LWS;
import X.LWU;
import X.M12;
import X.MNS;
import X.Spj;
import X.StA;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.ext.adapter.JediSimpleViewHolder;
import com.ss.android.ugc.aweme.discover.model.Banner;
import com.ss.android.ugc.aweme.discover.model.DiscoverSectionItem;
import com.ss.android.ugc.aweme.discover.viewmodel.TrendsTabViewModel;
import java.util.List;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class DiscoverBannerViewHolder extends JediSimpleViewHolder<DiscoverSectionItem> implements 0GV, CX1, CX3, CX3 {
    public static final List<Banner> LJIIJ = C4097LeS.LIZJ(new Banner());
    public static final LWQ LJIIJJI = new LWQ((byte) 0);
    public final 0GZ LJFF;
    public List<? extends Banner> LJI = C4116Lel.INSTANCE;
    public boolean LJIIIZ;
    public final TextView LJIIL;
    public final LWS LJIILIIL;
    public final View LJIILJJIL;
    public LWC LJIILL;
    public final JBY LJIILLIIL;
    public final Context LJIIZILJ;
    public final Crj LJIJ;
    public final CX3 LJIJI;
    public int LJIJJ;

    private final TrendsTabViewModel LJIILIIL() {
        return (TrendsTabViewModel) this.LJIJ.getValue();
    }

    public final void LIZ(int i, float f, int i2) {
    }

    public final void LIZIZ(int i) {
    }

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

    public final void LIZLLL() {
        this.LJIJI.LIZLLL();
    }

    public final void LJII() {
        DiscoverBannerViewHolder.super.LJII();
        LIZ(false);
    }

    public final void LJI() {
        DiscoverBannerViewHolder.super.LJI();
        withState(LJIILIIL(), new LWJ(this));
    }

    static {
        Covode.recordClassIndex(64157);
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x008b  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x00a0  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LJIIL() {
        /*
            r20 = this;
            r1 = r20
            X.LWM r0 = X.LWN.LIZ()
            X.LWL r0 = r0.LIZ
            boolean r0 = r0.LIZ
            if (r0 != 0) goto L_0x000d
            return
        L_0x000d:
            X.LUx r10 = X.C3688LUx.LIZJ
            android.content.Context r5 = r1.LJIIZILJ
            java.lang.String r6 = ""
            kotlin.h.b.n.LIZIZ(r5, r6)
            android.view.View r13 = r1.itemView
            X.LWH r3 = new X.LWH
            r3.<init>(r1)
            X.K07 r4 = new X.K07
            X.LWM r0 = X.LWN.LIZ()
            X.LWL r0 = r0.LIZ
            boolean r0 = r0.LIZIZ
            if (r0 == 0) goto L_0x003d
            X.Jq2 r2 = X.Jq2.USE_ONE_PIV
        L_0x002b:
            r1 = 0
            r0 = 4
            r4.<init>(r2, r1, r0)
            X.M12.LIZ(r5, r3, r4)
            long r8 = android.os.SystemClock.currentThreadTimeMillis()
            if (r13 != 0) goto L_0x0040
            r3.LIZ(new X.LV4())
            return
        L_0x003d:
            X.Jq2 r2 = X.Jq2.USE_HALF
            goto L_0x002b
        L_0x0040:
            int r14 = r13.getWidth()
            int r15 = r13.getHeight()
            r2 = 2
            int[] r7 = new int[r2]
            int r12 = r14 * r15
            X.Jq2 r1 = r4.LIZIZ
            X.Jq2 r0 = X.Jq2.USE_ONE_PIV
            r5 = 1
            if (r1 != r0) goto L_0x008f
        L_0x0054:
            r12 = 1
        L_0x0055:
            r13.getLocationOnScreen(r7)
            java.lang.StringBuilder r2 = new java.lang.StringBuilder
            r2.<init>()
            r0 = 0
            r0 = r7[r0]
            r2.append(r0)
            java.lang.String r1 = ", "
            r2.append(r1)
            r0 = r7[r5]
            r2.append(r0)
            r2.append(r1)
            int r0 = r13.getWidth()
            r2.append(r0)
            r2.append(r1)
            int r0 = r13.getHeight()
            r2.append(r0)
            java.lang.String r18 = r2.toString()
            boolean r0 = r13.hasWindowFocus()
            if (r0 != 0) goto L_0x00a0
            r3.LIZ(new X.LV4())
            return
        L_0x008f:
            X.Jq2 r1 = r4.LIZIZ
            X.Jq2 r0 = X.Jq2.USE_HALF
            if (r1 != r0) goto L_0x0097
            int r12 = r12 / r2
            goto L_0x0055
        L_0x0097:
            java.lang.Integer r0 = r4.LIZJ
            if (r0 == 0) goto L_0x0054
            int r12 = r0.intValue()
            goto L_0x0055
        L_0x00a0:
            java.util.UUID r0 = java.util.UUID.randomUUID()
            java.lang.String r2 = r0.toString()
            kotlin.h.b.n.LIZ(r2, r6)
            X.LUs r11 = new X.LUs
            long r0 = java.lang.System.nanoTime()
            r11.<init>(r0, r2)
            r11.LIZJ = r5
            r10.LIZ(r13, r11, r12)
            long r16 = android.os.SystemClock.currentThreadTimeMillis()
            long r16 = r16 - r8
            boolean r0 = r4.LIZ
            if (r0 == 0) goto L_0x00c9
            r19 = r3
            r10.LIZ(r11, r12, r13, r14, r15, r16, r18, r19)
            return
        L_0x00c9:
            X.LUz r9 = new X.LUz
            r19 = r3
            r9.<init>(r10, r11, r12, r13, r14, r15, r16, r18, r19)
            java.util.concurrent.ExecutorService r0 = r10.LIZ
            r0.execute(r9)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.discover.adapter.DiscoverBannerViewHolder.LJIIL():void");
    }

    public final void e_(int i) {
        withState(LJIILIIL(), new LWK(this));
    }

    public final void LIZ(boolean z) {
        if (z) {
            this.LJIILLIIL.LIZ();
            return;
        }
        this.LJIILLIIL.LIZIZ();
        this.LJFF.setOnTouchListener((View.OnTouchListener) null);
    }

    public final void LIZIZ(boolean z) {
        this.LJIIIZ = z;
        if (z && getLifecycle().LIZ().compareTo(0CC.STARTED) >= 0) {
            LJIIL();
            LIZJ(this.LJFF.getCurrentItem());
            LIZ(true);
        }
    }

    public final void LIZJ(int i) {
        if (!this.LJI.isEmpty()) {
            List<? extends Banner> list = this.LJI;
            Banner banner = (Banner) list.get(i % list.size());
            List<? extends Banner> list2 = this.LJI;
            0Gp.LIZ(new LWG((i % this.LJI.size()) + 1, banner, LWP.LIZ(((Banner) list2.get(i % list2.size())).getSchema())), 2nK.LIZ(), (0Gf) null);
            if (banner.isAd()) {
                C3232LDj.LIZ().LIZ(this.LJIIZILJ, banner, (i % this.LJI.size()) + 1);
                if (ESC.LIZLLL()) {
                    9bx.LIZ("ftc_show_banner_ad", "", (JSONObject) null);
                }
            }
        }
    }

    public final /* synthetic */ void LIZ(Object obj) {
        int i;
        DiscoverSectionItem.BannerSection bannerSection = (DiscoverSectionItem) obj;
        M12.LIZ((Object) bannerSection);
        List<? extends Banner> list = bannerSection.bannerList;
        if (!n.LIZ(list, LJIIJ)) {
            View view = this.itemView;
            n.LIZIZ(view, "");
            Context context = view.getContext();
            Cwu LIZ = MNS.LIZ.LIZ().LIZ(list.size(), list.size() * 10000);
            int intValue = ((Number) LIZ.getFirst()).intValue();
            int intValue2 = ((Number) LIZ.getSecond()).intValue();
            if (this.LJIILL == null) {
                this.LJIILL = new LWC(this, context, LayoutInflater.from(context));
                this.LJFF.setAdapter(new StA(this.LJIILL, intValue));
            }
            boolean LIZ2 = 3F7.LIZ(context);
            this.LJIILLIIL.LIZIZ = list.size();
            LWC lwc = this.LJIILL;
            if (lwc == null) {
                n.LIZIZ();
            }
            M12.LIZ((Object) list);
            if (lwc.LIZLLL != list) {
                lwc.LIZLLL = list;
                lwc.LIZJ();
            }
            this.LJIILIIL.setUpViewPager(this.LJFF);
            LWS lws = this.LJIILIIL;
            if (list.size() < 2) {
                i = 8;
            } else {
                i = 0;
            }
            lws.setVisibility(i);
            if (LIZ2) {
                list = C4105Lea.LJIIIIZZ(list);
            }
            this.LJI = list;
            if (LIZ2) {
                intValue2--;
            }
            this.LJFF.setCurrentItem(intValue2);
            this.LJFF.setCurrentItem(intValue2);
            withState(LJIILIIL(), new LWO(this));
        }
    }

    public final void LIZ(Activity activity, Configuration configuration) {
        M12.LIZ((Object) configuration);
        if (this.LJIJJ != configuration.screenWidthDp) {
            this.LJIJJ = configuration.screenWidthDp;
            FLr.LIZ.LIZ(this.LJIIZILJ, this.LJIIL, this.LJFF, 2ha.LIZ((double) this.LJIJJ));
        }
    }

    /* JADX WARNING: type inference failed for: r2v1, types: [android.view.View, X.LWS] */
    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public DiscoverBannerViewHolder(CX3 cx3, View view) {
        super(view);
        M12.LIZ((Object) cx3, (Object) view);
        View findViewById = view.findViewById(2131371937);
        n.LIZIZ(findViewById, "");
        TextView textView = (TextView) findViewById;
        this.LJIIL = textView;
        0GZ findViewById2 = view.findViewById(2131372992);
        n.LIZIZ(findViewById2, "");
        0GZ r3 = findViewById2;
        this.LJFF = r3;
        View findViewById3 = view.findViewById(2131364199);
        n.LIZIZ(findViewById3, "");
        ? r2 = (LWS) findViewById3;
        this.LJIILIIL = r2;
        View findViewById4 = view.findViewById(2131370610);
        n.LIZIZ(findViewById4, "");
        this.LJIILJJIL = findViewById4;
        Context context = view.getContext();
        this.LJIIZILJ = context;
        this.LJIIIZ = true;
        D1G LIZ = KEM.LIZ.LIZ(TrendsTabViewModel.class);
        this.LJIJ = 7he.LIZ(new BIQ(this, LIZ, LIZ));
        this.LJIJI = cx3;
        if (Spj.LIZ.LJIJJ()) {
            LWU.LIZ.LIZ(view, 2.0f);
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            0EG r7 = (0EG) (!(layoutParams instanceof 0EG) ? null : layoutParams);
            if (r7 != null) {
                Resources system = Resources.getSystem();
                n.LIZIZ(system, "");
                r7.leftMargin = C4645LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system.getDisplayMetrics()));
                Resources system2 = Resources.getSystem();
                n.LIZIZ(system2, "");
                r7.rightMargin = C4645LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system2.getDisplayMetrics()));
            }
        }
        FLr.LIZ.LIZ(context, textView, r3, 3G1.LIZIZ(context));
        this.LJIILLIIL = new JBY(r3);
        findViewById4.getLayoutParams().height = HeD.LJ(view.getContext());
        r3.addOnPageChangeListener(this);
        r2.setLayoutDirection(0);
    }
}
