package com.ss.android.ugc.aweme.compliance.business.phl;

import X.0HH;
import X.1od;
import X.7he;
import X.AnonymousClass2UX;
import X.AnonymousClass397;
import X.AnonymousClass39E;
import X.AnonymousClass39F;
import X.AnonymousClass39G;
import X.AnonymousClass39J;
import X.AnonymousClass39N;
import X.AnonymousClass39O;
import X.AnonymousClass39P;
import X.AnonymousClass39Q;
import X.AnonymousClass39R;
import X.AnonymousClass39S;
import X.AnonymousClass39T;
import X.AnonymousClass39U;
import X.AnonymousClass39V;
import X.AnonymousClass39X;
import X.AnonymousClass4ZZ;
import X.C03012Pr;
import X.C12422nK;
import X.C19542yo;
import X.C226239a;
import X.CbG;
import X.Crj;
import X.LnI;
import X.Ls2;
import X.LsC;
import X.M12;
import X.NzO;
import X.OQg;
import X.Qeg;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.foundation.fragment.BaseFragment;
import com.bytedance.ies.foundation.fragment.BaseFragmentViewModel;
import com.ss.android.ugc.aweme.compliance.api.phl.vm.PhlViewModel;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class PhlFragment extends BaseFragment implements AnonymousClass397 {
    public static final AnonymousClass39J LJIILJJIL = new AnonymousClass39J((byte) 0);
    public OQg LJ;
    public View LJFF;
    public TextView LJI;
    public NzO LJII;
    public Qeg LJIIIIZZ;
    public CbG LJIIIZ;
    public Ls2<C03012Pr> LJIIJ;
    public String LJIIJJI = "";
    public Runnable LJIIL;
    public long LJIILIIL;
    public AnonymousClass4ZZ LJIILL;
    public 1od LJIILLIIL;
    public RecyclerView LJIIZILJ;
    public View LJIJ;
    public final Crj LJIJI = 7he.LIZ(new AnonymousClass39G(this));
    public final Crj LJIJJ = 7he.LIZ(new AnonymousClass39F(this));
    public final Crj LJIJJLI = 7he.LIZ(AnonymousClass39T.LIZ);
    public SparseArray LJIL;

    static {
        Covode.recordClassIndex(61059);
    }

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

    public final PhlViewModel LIZ() {
        return (PhlViewModel) this.LJIJI.getValue();
    }

    public final C19542yo LIZIZ() {
        return (C19542yo) this.LJIJJ.getValue();
    }

    public final Handler LIZJ() {
        return (Handler) this.LJIJJLI.getValue();
    }

    public final void LJI() {
        SparseArray sparseArray = this.LJIL;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        LJI();
    }

    public final void onResume() {
        PhlFragment.super.onResume();
        LIZLLL();
    }

    public final void onPause() {
        PhlFragment.super.onPause();
        LIZJ().removeCallbacksAndMessages((Object) null);
    }

    private final void LIZLLL() {
        LIZJ().removeCallbacksAndMessages((Object) null);
        AnonymousClass39S r3 = new AnonymousClass39S(this);
        this.LJIIL = r3;
        LIZJ().postDelayed(r3, 1000);
    }

    public final void LIZ(Ls2<C03012Pr> ls2) {
        this.LJIIJ = ls2;
    }

    public final void onCreate(Bundle bundle) {
        Object obj;
        super.onCreate(bundle);
        LIZ((LsC<? super BaseFragmentViewModel, C03012Pr>) AnonymousClass39Q.LIZ);
        Bundle arguments = getArguments();
        if (arguments != null) {
            obj = LIZ(arguments, "enter_from");
        } else {
            obj = null;
        }
        Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlin.String");
        this.LJIIJJI = (String) obj;
        LIZLLL();
    }

    public final void LIZ(String str) {
        Integer num;
        M12.LIZ(str);
        AnonymousClass2UX r3 = new AnonymousClass2UX();
        r3.LIZ("enter_from", this.LJIIJJI);
        List list = (List) LIZ().LIZJ.getValue();
        if (list != null) {
            num = Integer.valueOf(list.size());
        } else {
            num = null;
        }
        r3.LIZ("video_cnt", (Object) num);
        r3.LIZ("exit_method", str);
        r3.LIZ("staytime", this.LJIILIIL);
        C12422nK.LIZ("exit_privacy_highlights_teens_page", r3.LIZ);
    }

    public static Object LIZ(Bundle bundle, String str) {
        try {
            return bundle.get(str);
        } catch (Exception | OutOfMemoryError unused) {
            return null;
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        this.LJ = view.findViewById(2131368461);
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            OQg oQg = this.LJ;
            if (oQg != null) {
                oQg.setVisibility(8);
            }
        } else {
            OQg oQg2 = this.LJ;
            if (oQg2 != null) {
                oQg2.setVisibility(0);
            }
            OQg oQg3 = this.LJ;
            if (oQg3 != null) {
                oQg3.LIZ();
            }
            LIZ().LJ.observe(this, new AnonymousClass39N(this));
        }
        View findViewById = view.findViewById(2131368457);
        n.LIZIZ(findViewById, "");
        this.LJIILL = (AnonymousClass4ZZ) findViewById;
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            AnonymousClass4ZZ r0 = this.LJIILL;
            if (r0 == null) {
                n.LIZ("");
            }
            r0.setVisibility(8);
        } else {
            AnonymousClass4ZZ r02 = this.LJIILL;
            if (r02 == null) {
                n.LIZ("");
            }
            r02.setVisibility(0);
            AnonymousClass4ZZ r1 = this.LJIILL;
            if (r1 == null) {
                n.LIZ("");
            }
            r1.setOnClickListener(new AnonymousClass39U(this));
        }
        this.LJFF = view.findViewById(2131368462);
        this.LJI = (TextView) view.findViewById(2131368464);
        NzO findViewById2 = view.findViewById(2131368465);
        this.LJII = findViewById2;
        if (findViewById2 == null) {
            n.LIZIZ();
        }
        findViewById2.setFontWeight(3);
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            NzO nzO = this.LJII;
            if (nzO == null) {
                n.LIZIZ();
            }
            ViewGroup.LayoutParams layoutParams = nzO.getLayoutParams();
            Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
            Resources system = Resources.getSystem();
            n.LIZIZ(system, "");
            marginLayoutParams.setMarginStart(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system.getDisplayMetrics())));
            Resources system2 = Resources.getSystem();
            n.LIZIZ(system2, "");
            marginLayoutParams.setMarginEnd(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system2.getDisplayMetrics())));
            NzO nzO2 = this.LJII;
            if (nzO2 == null) {
                n.LIZIZ();
            }
            nzO2.setLayoutParams(marginLayoutParams);
            NzO nzO3 = this.LJII;
            if (nzO3 == null) {
                n.LIZIZ();
            }
            nzO3.setTextSize(1, 36.0f);
        }
        this.LJIIIIZZ = view.findViewById(2131368463);
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            Qeg qeg = this.LJIIIIZZ;
            if (qeg == null) {
                n.LIZIZ();
            }
            ViewGroup.LayoutParams layoutParams2 = qeg.getLayoutParams();
            Objects.requireNonNull(layoutParams2, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) layoutParams2;
            Resources system3 = Resources.getSystem();
            n.LIZIZ(system3, "");
            marginLayoutParams2.setMarginStart(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system3.getDisplayMetrics())));
            Resources system4 = Resources.getSystem();
            n.LIZIZ(system4, "");
            marginLayoutParams2.setMarginEnd(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system4.getDisplayMetrics())));
            Resources system5 = Resources.getSystem();
            n.LIZIZ(system5, "");
            marginLayoutParams2.topMargin = LnI.LIZ(TypedValue.applyDimension(1, 8.0f, system5.getDisplayMetrics()));
            Qeg qeg2 = this.LJIIIIZZ;
            if (qeg2 == null) {
                n.LIZIZ();
            }
            qeg2.setLayoutParams(marginLayoutParams2);
        }
        1od findViewById3 = view.findViewById(2131368460);
        this.LJIILLIIL = findViewById3;
        if (findViewById3 == null) {
            n.LIZIZ();
        }
        findViewById3.setOnScrollChangeListener(new AnonymousClass39P(this));
        LIZ().LIZ.observe(this, new AnonymousClass39O(this));
        LIZ().LIZIZ.observe(this, new AnonymousClass39X(this));
        this.LJIIZILJ = view.findViewById(2131368459);
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            RecyclerView recyclerView = this.LJIIZILJ;
            if (recyclerView == null) {
                n.LIZIZ();
            }
            ViewGroup.LayoutParams layoutParams3 = recyclerView.getLayoutParams();
            Objects.requireNonNull(layoutParams3, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            ViewGroup.MarginLayoutParams marginLayoutParams3 = (ViewGroup.MarginLayoutParams) layoutParams3;
            Resources system6 = Resources.getSystem();
            n.LIZIZ(system6, "");
            marginLayoutParams3.setMarginStart(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system6.getDisplayMetrics())));
            Resources system7 = Resources.getSystem();
            n.LIZIZ(system7, "");
            marginLayoutParams3.setMarginEnd(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system7.getDisplayMetrics())));
            RecyclerView recyclerView2 = this.LJIIZILJ;
            if (recyclerView2 == null) {
                n.LIZIZ();
            }
            recyclerView2.setLayoutParams(marginLayoutParams3);
        }
        getContext();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager();
        RecyclerView recyclerView3 = this.LJIIZILJ;
        if (recyclerView3 == null) {
            n.LIZIZ();
        }
        recyclerView3.setLayoutManager(linearLayoutManager);
        RecyclerView recyclerView4 = this.LJIIZILJ;
        if (recyclerView4 == null) {
            n.LIZIZ();
        }
        recyclerView4.setAdapter(LIZIZ());
        LIZ().LIZJ.observe(this, new AnonymousClass39E(this));
        View findViewById4 = view.findViewById(2131368458);
        n.LIZIZ(findViewById4, "");
        this.LJIJ = findViewById4;
        CbG findViewById5 = view.findViewById(2131368448);
        n.LIZIZ(findViewById5, "");
        this.LJIIIZ = findViewById5;
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            View view2 = this.LJIJ;
            if (view2 == null) {
                n.LIZ("");
            }
            view2.setVisibility(0);
            CbG cbG = this.LJIIIZ;
            if (cbG == null) {
                n.LIZ("");
            }
            cbG.setVisibility(0);
            CbG cbG2 = this.LJIIIZ;
            if (cbG2 == null) {
                n.LIZ("");
            }
            ViewGroup.LayoutParams layoutParams4 = cbG2.getLayoutParams();
            Objects.requireNonNull(layoutParams4, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            ViewGroup.MarginLayoutParams marginLayoutParams4 = (ViewGroup.MarginLayoutParams) layoutParams4;
            Resources system8 = Resources.getSystem();
            n.LIZIZ(system8, "");
            marginLayoutParams4.setMarginStart(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system8.getDisplayMetrics())));
            Resources system9 = Resources.getSystem();
            n.LIZIZ(system9, "");
            marginLayoutParams4.setMarginEnd(LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system9.getDisplayMetrics())));
            CbG cbG3 = this.LJIIIZ;
            if (cbG3 == null) {
                n.LIZ("");
            }
            cbG3.setLayoutParams(marginLayoutParams4);
            CbG cbG4 = this.LJIIIZ;
            if (cbG4 == null) {
                n.LIZ("");
            }
            cbG4.setOnClickListener(new AnonymousClass39V(this));
            LIZ().LIZLLL.observe(this, new AnonymousClass39R(this));
        } else {
            View view3 = this.LJIJ;
            if (view3 == null) {
                n.LIZ("");
            }
            view3.setVisibility(8);
            CbG cbG5 = this.LJIIIZ;
            if (cbG5 == null) {
                n.LIZ("");
            }
            cbG5.setVisibility(8);
        }
        if (n.LIZ(this.LJIIJJI, "new_user_journey")) {
            LIZ().LJFF.observe(this, C226239a.LIZ);
        }
    }

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