package com.ss.android.ugc.aweme.view.hub;

import X.0CH;
import X.0HH;
import X.2Pr;
import X.2UX;
import X.2cN;
import X.2nK;
import X.2rf;
import X.5Am;
import X.5An;
import X.5vY;
import X.5wO;
import X.7he;
import X.B8T;
import X.C2936JEx;
import X.C2950JFl;
import X.C2961JFw;
import X.C2965JGa;
import X.C2966JGb;
import X.C2969JGe;
import X.Crj;
import X.Cwt;
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.JEJ;
import X.JEN;
import X.JEQ;
import X.JF0;
import X.JG3;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.Lu4;
import X.M12;
import X.PHD;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.arch.JediViewModel;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.ss.android.ugc.aweme.IProfileNaviService;
import com.ss.android.ugc.aweme.ProfileNaviServiceImpl;
import com.ss.android.ugc.aweme.viewModel.ProfileNaviSwitcherViewModel;
import java.util.List;
import kotlin.h.b.n;

public final class ProfileNaviSwitcherBottomSheet extends BottomSheetDialogFragment implements 5vY, 2rf {
    public final Crj LIZ = 7he.LIZ(new JEN(this));
    public SparseArray LIZIZ;

    static {
        Covode.recordClassIndex(123427);
    }

    public final ProfileNaviSwitcherViewModel LIZIZ() {
        return (ProfileNaviSwitcherViewModel) this.LIZ.getValue();
    }

    public final View LIZJ() {
        if (this.LIZIZ == null) {
            this.LIZIZ = new SparseArray();
        }
        View view = (View) this.LIZIZ.get(2131368960);
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(2131368960);
        this.LIZIZ.put(2131368960, findViewById);
        return findViewById;
    }

    public final boolean getUniqueOnlyGlobal() {
        return true;
    }

    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() {
        ProfileNaviSwitcherBottomSheet.super.onDestroyView();
        SparseArray sparseArray = this.LIZIZ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final void LIZ() {
        int i;
        IProfileNaviService LIZ2 = ProfileNaviServiceImpl.LIZ();
        List<JF0> naviList = LIZIZ().LIZ(this).getNaviList();
        if (naviList != null) {
            i = naviList.size();
        } else {
            i = 0;
        }
        if (LIZ2.LIZ((Fragment) this, i)) {
            C2950JFl.LIZIZ.LIZ(C2950JFl.LIZ);
            dismiss();
            ProfileNaviSwitcherViewModel LIZIZ2 = LIZIZ();
            LIZIZ2.LIZLLL(C2965JGa.LIZ);
            LIZIZ2.LIZLLL(C2966JGb.LIZ);
        }
    }

    public final void onStart() {
        ProfileNaviSwitcherBottomSheet.super.onStart();
        if (getDialog() != null) {
            View findViewById = getDialog().findViewById(2131364037);
            n.LIZIZ(findViewById, "");
            ViewGroup.LayoutParams layoutParams = findViewById.getLayoutParams();
            JG3 jg3 = C2969JGe.LIZ;
            Context context = getContext();
            if (context == null) {
                n.LIZIZ();
            }
            n.LIZIZ(context, "");
            layoutParams.height = (int) jg3.LIZ(context, 360.0f);
        }
    }

    public final Dialog onCreateDialog(Bundle bundle) {
        Context context = getContext();
        if (context == null) {
            n.LIZIZ();
        }
        return new Lu4(context, 2131887154);
    }

    public final void LIZ(JF0 jf0) {
        M12.LIZ(jf0);
        String navi_id = jf0.getNavi_id();
        2UX r2 = new 2UX();
        r2.LIZ("enter_from", "avatar_switcher_page");
        r2.LIZ("avatar_id", navi_id);
        2nK.LIZ("choose_avatar", r2.LIZ);
        dismiss();
        LIZIZ();
        C2936JEx jEx = JEJ.LIZ;
        String str = null;
        if (!(jEx == null || jEx.LIZ == null)) {
            LIZIZ();
            C2936JEx jEx2 = JEJ.LIZ;
            if (jEx2 != null) {
                str = jEx2.LIZ;
            }
            if (!(!n.LIZ(str, jf0.getNavi_id()))) {
                return;
            }
        }
        LIZIZ().LIZ(jf0);
    }

    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);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        ProfileNaviSwitcherBottomSheet.super.onViewCreated(view, bundle);
        LIZIZ().LIZJ();
        DV0.LIZ(this, LIZIZ(), JEQ.LIZ, new C2961JFw(this));
        LIZIZ().LIZIZ();
    }

    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);
        2UX r2 = new 2UX();
        r2.LIZ("enter_from", "avatar_hub");
        2nK.LIZ("enter_avatar_switch", r2.LIZ);
        return 0HH.LIZ(layoutInflater, 2131560874, 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);
    }
}
