package com.ss.android.ugc.aweme.ecommerce.semipdp;

import X.05s;
import X.070;
import X.0Bv;
import X.0CH;
import X.0HH;
import X.1gt;
import X.1hK;
import X.2Pr;
import X.2cN;
import X.3SM;
import X.3Y9;
import X.3df;
import X.4ZZ;
import X.5Am;
import X.5An;
import X.5vY;
import X.5wO;
import X.7W7;
import X.7df;
import X.7he;
import X.B1N;
import X.B8T;
import X.BTH;
import X.C1835Aid;
import X.C5829CEf;
import X.C6162CRa;
import X.C6163CRb;
import X.C6164CRc;
import X.C6201CSn;
import X.C6202CSo;
import X.C6205CSr;
import X.C6206CSs;
import X.C6207CSt;
import X.C6489CbV;
import X.C6B;
import X.CAZ;
import X.COI;
import X.COK;
import X.CP3;
import X.CPM;
import X.CRZ;
import X.CS2;
import X.CS3;
import X.CS4;
import X.CS5;
import X.CS9;
import X.CSB;
import X.CSC;
import X.CSD;
import X.CSF;
import X.CSJ;
import X.CSL;
import X.CSO;
import X.CSX;
import X.CSY;
import X.CT8;
import X.CVL;
import X.CqM;
import X.Crj;
import X.Cwt;
import X.D1G;
import X.D4t;
import X.DRZ;
import X.DUT;
import X.DUy;
import X.DUz;
import X.DV0;
import X.DV9;
import X.DVU;
import X.KEM;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.M12;
import X.OQg;
import X.PHD;
import X.Qen;
import X.Szm;
import X.Szo;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.bytedance.jedi.arch.JediViewModel;
import com.bytedance.jedi.arch.lifecycleAwareLazy;
import com.bytedance.tux.sheet.sheet.TuxSheet;
import com.ss.android.ugc.aweme.ecommerce.pdp.repository.dto.ProductPackStruct;
import com.ss.android.ugc.aweme.ecommerce.pdp.repository.dto.ThirdParty;
import com.ss.android.ugc.aweme.ecommerce.semipdp.SemiPdpStarter;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.h.b.n;

public final class SemiPdpFragment extends Fragment implements B1N<C1835Aid>, 5vY, 3Y9 {
    public static final float LIZLLL = ((((float) 3SM.LIZIZ) - 3SM.LIZ()) + 100.0f);
    public static final CT8 LJ = new CT8((byte) 0);
    public final C1835Aid LIZ = new C1835Aid();
    public CVL LIZIZ;
    public CS5 LIZJ;
    public final lifecycleAwareLazy LJFF;
    public final Crj LJI;
    public boolean LJII;
    public SparseArray LJIIIIZZ;

    public final View LIZ(int i) {
        if (this.LJIIIIZZ == null) {
            this.LJIIIIZZ = new SparseArray();
        }
        View view = (View) this.LJIIIIZZ.get(i);
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIIIIZZ.put(i, findViewById);
        return findViewById;
    }

    public final SemiPdpViewModel LIZIZ() {
        return (SemiPdpViewModel) this.LJFF.getValue();
    }

    public final C6B LIZLLL() {
        return (C6B) this.LJI.getValue();
    }

    public final boolean di_() {
        return false;
    }

    public final boolean getUniqueOnlyGlobal() {
        return true;
    }

    public final /* bridge */ /* synthetic */ 0Bv be_() {
        return this.LIZ;
    }

    public final /* bridge */ /* synthetic */ 5An getReceiver() {
        return this;
    }

    public final 0CH getLifecycleOwner() {
        5wO.LIZJ(this);
        return this;
    }

    public final DUz getLifecycleOwnerHolder() {
        5wO.LIZ(this);
        return this;
    }

    public final DUy<DVU> getReceiverHolder() {
        5wO.LIZIZ(this);
        return this;
    }

    public final /* synthetic */ void onDestroyView() {
        SemiPdpFragment.super.onDestroyView();
        SparseArray sparseArray = this.LJIIIIZZ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    static {
        Covode.recordClassIndex(72375);
    }

    public final void onPause() {
        SemiPdpFragment.super.onPause();
        if (LIZIZ().LIZJ) {
            CqM.LIZ(new 3df(false, getContext()));
        }
    }

    public final void onResume() {
        SemiPdpFragment.super.onResume();
        CqM.LIZ(new 3df(true, getContext()));
    }

    public final void onStart() {
        SemiPdpFragment.super.onStart();
        LIZIZ().LIZIZ().LIZIZ = SystemClock.elapsedRealtime();
    }

    public SemiPdpFragment() {
        D1G LIZ2 = KEM.LIZ.LIZ(SemiPdpViewModel.class);
        CSY csy = new CSY(LIZ2);
        this.LJFF = new lifecycleAwareLazy(this, csy, new CS9(this, csy, LIZ2, CSX.INSTANCE));
        this.LJI = 7he.LIZ(new C6205CSr(this));
    }

    public final void onStop() {
        String str;
        int i;
        SemiPdpFragment.super.onStop();
        if (ActivityStack.isAppBackGround()) {
            LIZIZ().LIZ("close");
        }
        SemiPdpViewModel LIZIZ2 = LIZIZ();
        C5829CEf cEf = LIZIZ2.LJIIL;
        if (cEf == null) {
            n.LIZ("");
            return;
        }
        if (LIZIZ2.LIZJ) {
            str = "full_screen";
        } else {
            str = "half_screen";
        }
        int size = LIZIZ2.LJIIJJI.size();
        boolean z = LIZIZ2.LJI;
        if (LIZIZ2.LIZ != null) {
            i = 1;
        } else {
            i = 0;
        }
        String str2 = LIZIZ2.LJFF;
        HashMap<String, Object> LJII2 = LIZIZ2.LJII();
        M12.LIZ(str, str2, LJII2);
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("page_show_type", str);
        linkedHashMap.put("main_photo_view_cnt", Integer.valueOf(size));
        linkedHashMap.put("is_image_clicked", Integer.valueOf(z ? 1 : 0));
        linkedHashMap.put("is_load_data", Integer.valueOf(i));
        linkedHashMap.put("quit_type", str2);
        linkedHashMap.put("stay_time", Long.valueOf(SystemClock.elapsedRealtime() - cEf.LIZIZ));
        linkedHashMap.putAll(LJII2);
        cEf.LIZIZ("tiktokec_stay_product_detail", linkedHashMap);
    }

    public static final /* synthetic */ CVL LIZ(SemiPdpFragment semiPdpFragment) {
        CVL cvl = semiPdpFragment.LIZIZ;
        if (cvl == null) {
            n.LIZ("");
        }
        return cvl;
    }

    public static final /* synthetic */ CS5 LIZIZ(SemiPdpFragment semiPdpFragment) {
        CS5 cs5 = semiPdpFragment.LIZJ;
        if (cs5 == null) {
            n.LIZ("");
        }
        return cs5;
    }

    private final void LIZ(float f) {
        CVL cvl = this.LIZIZ;
        if (cvl == null) {
            n.LIZ("");
        } else {
            cvl.setTranslationY(f);
        }
    }

    private final void LIZ(boolean z) {
        if (isResumed() && this.LJII) {
            if (z) {
                View view = getView();
                if (view != null) {
                    view.post(C6202CSo.LIZ);
                }
                7df.LJJJI().LJJIIZ();
                return;
            }
            7df.LJJJI().LJJIIZI();
            7df.LJJJI().LJJI();
        }
    }

    public final void onActivityCreated(Bundle bundle) {
        View view;
        View rootView;
        ViewGroup viewGroup;
        MethodCollector.i(674);
        SemiPdpFragment.super.onActivityCreated(bundle);
        if (getContext() != null) {
            FrameLayout frameLayout = null;
            if (LIZIZ().LJ) {
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -2);
                FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-1, -2);
                layoutParams.gravity = 80;
                layoutParams2.gravity = 48;
                View view2 = getView();
                if (view2 instanceof FrameLayout) {
                    frameLayout = view2;
                }
                FrameLayout frameLayout2 = frameLayout;
                if (frameLayout2 != null) {
                    CVL cvl = this.LIZIZ;
                    if (cvl == null) {
                        n.LIZ("");
                    }
                    frameLayout2.addView(cvl, layoutParams);
                    CS5 cs5 = this.LIZJ;
                    if (cs5 == null) {
                        n.LIZ("");
                    }
                    frameLayout2.addView(cs5, layoutParams2);
                }
                CS5 cs52 = this.LIZJ;
                if (cs52 == null) {
                    n.LIZ("");
                    MethodCollector.o(674);
                    return;
                }
                cs52.LIZ(2131363399).setIconRes(2131755170);
                MethodCollector.o(674);
                return;
            }
            View view3 = getView();
            if (!(view3 == null || (rootView = view3.getRootView()) == null || (viewGroup = (ViewGroup) rootView.findViewById(2131364037)) == null)) {
                viewGroup.setElevation(0.0f);
            }
            View view4 = getView();
            if (view4 != null) {
                view = CAZ.LIZ(view4);
            } else {
                view = null;
            }
            05s r2 = new 05s(-1, -2);
            05s r1 = new 05s(-1, -2);
            r2.LIZJ = 80;
            r1.LIZJ = 48;
            if (view instanceof 1gt) {
                frameLayout = view;
            }
            1gt r4 = (1gt) frameLayout;
            if (r4 != null) {
                CVL cvl2 = this.LIZIZ;
                if (cvl2 == null) {
                    n.LIZ("");
                }
                r4.addView(cvl2, r2);
                CS5 cs53 = this.LIZJ;
                if (cs53 == null) {
                    n.LIZ("");
                }
                r4.addView(cs53, r1);
            }
            CS5 cs54 = this.LIZJ;
            if (cs54 == null) {
                n.LIZ("");
            } else {
                cs54.setVisibility(8);
                MethodCollector.o(674);
                return;
            }
        }
        MethodCollector.o(674);
    }

    public final void onCreate(Bundle bundle) {
        Integer num;
        ProductPackStruct productPackStruct;
        Serializable serializable;
        boolean z;
        boolean z2;
        HashMap<String, Object> trackParams;
        String str;
        Map<String, String> map;
        String str2;
        Map<String, String> map2;
        SemiPdpFragment.super.onCreate(bundle);
        Bundle arguments = getArguments();
        HashMap<String, Object> hashMap = null;
        if (arguments != null) {
            num = Integer.valueOf(arguments.getInt("ERROR_CODE"));
        } else {
            num = null;
        }
        Bundle arguments2 = getArguments();
        if (arguments2 != null) {
            productPackStruct = (ProductPackStruct) arguments2.getParcelable("product_info");
        } else {
            productPackStruct = null;
        }
        Bundle arguments3 = getArguments();
        if (arguments3 != null) {
            serializable = arguments3.getSerializable("ENTER_PARAMS");
        } else {
            serializable = null;
        }
        if (!(serializable instanceof SemiPdpStarter.SemiPdpEnterParams)) {
            serializable = null;
        }
        SemiPdpStarter.SemiPdpEnterParams semiPdpEnterParams = (SemiPdpStarter.SemiPdpEnterParams) serializable;
        LIZIZ().LIZIZ = semiPdpEnterParams;
        SemiPdpViewModel LIZIZ2 = LIZIZ();
        if (semiPdpEnterParams != null) {
            z = semiPdpEnterParams.getFullScreen();
        } else {
            z = false;
        }
        LIZIZ2.LIZ(z);
        SemiPdpViewModel LIZIZ3 = LIZIZ();
        if (semiPdpEnterParams != null) {
            z2 = semiPdpEnterParams.getFullScreen();
        } else {
            z2 = false;
        }
        LIZIZ3.LJ = z2;
        if (!(semiPdpEnterParams == null || (trackParams = semiPdpEnterParams.getTrackParams()) == null)) {
            if (productPackStruct == null || (map = productPackStruct.LJJIIJ) == null || map.get("mix_product_type") == null) {
                str = "";
            } else {
                if (productPackStruct == null || (map2 = productPackStruct.LJJIIJ) == null) {
                    str2 = null;
                } else {
                    str2 = map2.get("mix_product_type");
                }
                str = String.valueOf(str2);
            }
            trackParams.put("is_mix_product", str);
        }
        SemiPdpViewModel LIZIZ4 = LIZIZ();
        if (semiPdpEnterParams != null) {
            hashMap = semiPdpEnterParams.getTrackParams();
        }
        C5829CEf cEf = new C5829CEf(hashMap);
        LinkedHashMap<String, Object> linkedHashMap = cEf.LIZ;
        HashMap<String, Object> hashMap2 = cEf.LIZJ;
        if (hashMap2 != null) {
            linkedHashMap.putAll(hashMap2);
        }
        linkedHashMap.put("page_name", "semi_product_detail");
        linkedHashMap.put("EVENT_ORIGIN_FEATURE", "TEMAI");
        M12.LIZ(cEf);
        LIZIZ4.LJIIL = cEf;
        if (num != null) {
            if (num.intValue() == 0 && productPackStruct != null) {
                LIZIZ().LIZ(productPackStruct);
                LIZIZ().LIZ(0);
                return;
            } else if (num.intValue() != 0) {
                LIZIZ().LIZ(num.intValue());
                return;
            }
        }
        LIZIZ().LIZ(-99999);
    }

    public final <VM1 extends JediViewModel<S1>, S1 extends 5Am, R> R withState(VM1 vm1, LsC<? super S1, ? extends R> lsC) {
        M12.LIZ(vm1, lsC);
        return 5wO.LIZ(vm1, lsC);
    }

    private final void LIZIZ(TuxSheet tuxSheet, int i) {
        if (i == 3) {
            Szm szm = Szo.LIZIZ;
            1hK activity = tuxSheet.getActivity();
            if (activity == null) {
                n.LIZIZ();
            }
            n.LIZIZ(activity, "");
            Dialog dialog = tuxSheet.getDialog();
            n.LIZIZ(dialog, "");
            Szo LIZ2 = szm.LIZ(activity, dialog);
            LIZ2.LIZIZ(true);
            LIZ2.LIZ();
            LIZ2.LJ(-16777216);
            LIZ2.LIZJ(true);
            LIZ2.LIZ(false);
            LIZ2.LIZ.LIZJ();
            LIZ(true);
        } else if (i == 4 || i == 5) {
            Szm szm2 = Szo.LIZIZ;
            1hK activity2 = tuxSheet.getActivity();
            if (activity2 == null) {
                n.LIZIZ();
            }
            n.LIZIZ(activity2, "");
            Dialog dialog2 = tuxSheet.getDialog();
            n.LIZIZ(dialog2, "");
            Szo LIZ3 = szm2.LIZ(activity2, dialog2);
            LIZ3.LIZIZ(false);
            LIZ3.LIZ();
            LIZ3.LJ(-16777216);
            LIZ3.LIZJ(true);
            LIZ3.LIZ(false);
            LIZ3.LIZ.LIZJ();
            LIZ(false);
        }
        LIZIZ().LJII = i;
    }

    public final void LIZ(TuxSheet tuxSheet, float f) {
        OQg LIZ2;
        M12.LIZ(tuxSheet);
        if (f == 1.0f) {
            LIZIZ().LIZ(true);
        } else {
            LIZIZ().LIZ(false);
        }
        if (f <= 0.0f) {
            LIZ((-f) * 3SM.LIZJ);
        } else {
            LIZ(0.0f);
        }
        if (f >= 0.0f && (LIZ2 = LIZ(2131370625)) != null) {
            Qen.LIZ(LIZ2, (Integer) null, (Integer) null, (Integer) null, Integer.valueOf((int) (LIZLLL * (1.0f - f))), false, 23);
        }
    }

    public final void LIZ(TuxSheet tuxSheet, int i) {
        C5829CEf LIZIZ2;
        C5829CEf LIZIZ3;
        C5829CEf LIZIZ4;
        M12.LIZ(tuxSheet);
        if (i == 3) {
            if (LIZIZ().LJII == 4 && (LIZIZ2 = LIZIZ().LIZIZ()) != null) {
                LIZIZ2.LIZ("halftofull");
            }
            LIZIZ(tuxSheet, i);
        } else if (i == 4) {
            if (LIZIZ().LJII == 3 && (LIZIZ3 = LIZIZ().LIZIZ()) != null) {
                LIZIZ3.LIZ("fulltohalf");
            }
            LIZIZ(tuxSheet, i);
        } else if (i == 5) {
            if (LIZIZ().LJII == 4 && (LIZIZ4 = LIZIZ().LIZIZ()) != null) {
                LIZIZ4.LIZ("halftoquit");
            }
            LIZIZ(tuxSheet, i);
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        int i;
        String str;
        ThirdParty thirdParty;
        OQg LIZ2;
        M12.LIZ(view);
        SemiPdpFragment.super.onViewCreated(view, bundle);
        LIZ(2131368395).LIZ(new BTH(070.LIZJ(requireContext(), 2131099720), 0, 0.0f, 6));
        LIZLLL().setShowFooter(false);
        RecyclerView LIZ3 = LIZ(2131368395);
        n.LIZIZ(LIZ3, "");
        LIZ3.setAdapter(LIZLLL());
        LIZ(2131368395).LIZ(new CSJ(this));
        Context context = getContext();
        if (context != null) {
            this.LIZIZ = new CVL(context, new COK(this), new CS2(this, context));
            CS5 cs5 = new CS5(context, new CSO(this), new COI(this, context));
            this.LIZJ = cs5;
            boolean LIZ4 = SettingsManager.LIZ().LIZ("ecom_semi_pdp_show_report", false);
            cs5.LIZJ = LIZ4;
            4ZZ LIZ5 = cs5.LIZ(2131367705);
            n.LIZIZ(LIZ5, "");
            if (LIZ4) {
                i = 0;
            } else {
                i = 8;
            }
            LIZ5.setVisibility(i);
            OQg LIZ6 = LIZ(2131370625);
            if (LIZ6 != null) {
                View LIZ7 = C6489CbV.LIZ(context, 2131559119, (ViewGroup) null, false);
                n.LIZIZ(LIZ7, "");
                LIZ6.LIZ(LIZ7);
            }
            if (!LIZIZ().LJ && (LIZ2 = LIZ(2131370625)) != null) {
                Qen.LIZ(LIZ2, (Integer) null, (Integer) null, (Integer) null, Integer.valueOf((int) LIZLLL), false, 23);
            }
            CVL cvl = this.LIZIZ;
            if (cvl == null) {
                n.LIZ("");
            }
            ProductPackStruct productPackStruct = LIZIZ().LIZ;
            if (productPackStruct == null || (thirdParty = productPackStruct.LJIILLIIL) == null || (str = thirdParty.LIZLLL) == null) {
                str = "";
            }
            cvl.setBottomText(str);
        }
        DV0.LIZ(this, LIZIZ(), C6163CRb.LIZ, new CSF(this));
        DV0.LIZ(this, LIZIZ(), C6164CRc.LIZ, new CSB(this));
        DV0.LIZ(this, LIZIZ(), CRZ.LIZ, new CSL(this));
        DV0.LIZ(this, LIZIZ(), C6162CRa.LIZ, new CSD(this));
        DV0.LIZ(this, LIZIZ(), CP3.LIZ, C6206CSs.LIZ, new CSC(this));
        DV0.LIZ(this, LIZIZ(), C6207CSt.LIZ, new CS3(this));
        DV0.LIZ(this, LIZIZ(), CPM.LIZ, new CS4(this));
        View view2 = getView();
        if (view2 != null) {
            view2.setFocusableInTouchMode(true);
        }
        View view3 = getView();
        if (view3 != null) {
            view3.requestFocus();
        }
        View view4 = getView();
        if (view4 != null) {
            view4.setOnKeyListener(new C6201CSn(this));
        }
        7W7 LJJJI = 7df.LJJJI();
        n.LIZIZ(LJJJI, "");
        this.LJII = LJJJI.LJIILJJIL();
    }

    public final <S extends 5Am> 2cN subscribe(JediViewModel<S> jediViewModel, DUT<S> dut, LsD<? super DVU, ? super S, 2Pr> lsD) {
        M12.LIZ(jediViewModel, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, dut, lsD);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131559178, viewGroup, false);
    }

    public final <S extends 5Am, A> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, DUT<DRZ<A>> dut, LsD<? super DVU, ? super A, 2Pr> lsD) {
        M12.LIZ(jediViewModel, phd, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD);
    }

    public final <S extends 5Am, A, B> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, DUT<Cwt<A, B>> dut, LsE<? super DVU, ? super A, ? super B, 2Pr> lsE) {
        M12.LIZ(jediViewModel, phd, phd2, dut, lsE);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, dut, lsE);
    }

    public final <S extends 5Am, T> 2cN asyncSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends B8T<? extends T>> phd, DUT<DRZ<B8T<T>>> dut, LsD<? super DVU, ? super Throwable, 2Pr> lsD, LsC<? super DVU, 2Pr> lsC, LsD<? super DVU, ? super T, 2Pr> lsD2) {
        M12.LIZ(jediViewModel, phd, dut);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD, lsC, lsD2);
    }

    public final <S extends 5Am, A, B, C> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, DUT<DV9<A, B, C>> dut, LsF<? super DVU, ? super A, ? super B, ? super C, 2Pr> lsF) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, dut, lsF);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, dut, lsF);
    }

    public final <S extends 5Am, A, B, C, D> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, PHD<S, ? extends D> phd4, DUT<D4t<A, B, C, D>> dut, Lsh<? super DVU, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
    }
}
