package com.ss.android.ugc.aweme.profile.ui.multiaccount;

import X.0Br;
import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.1hK;
import X.2Ea;
import X.2GD;
import X.2UX;
import X.2nK;
import X.2uR;
import X.3S8;
import X.3YD;
import X.3cA;
import X.3cC;
import X.3cI;
import X.7he;
import X.C0295Crj;
import X.C2961DyH;
import X.C2999Dyt;
import X.C3004Dyy;
import X.C3005Dyz;
import X.DRN;
import X.DRO;
import X.DRP;
import X.DRQ;
import X.DRR;
import X.M12;
import X.Ryl;
import X.Ryr;
import android.content.Context;
import android.content.Intent;
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 androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.bytedance.tux.sheet.sheet.TuxSheet;
import com.ss.android.ugc.aweme.account.login.auth.I18nSignUpActivity;
import com.ss.android.ugc.aweme.account.login.auth.SignupViewModel;
import com.ss.android.ugc.aweme.user.viewmodel.CheckMultiAccountViewModel;
import com.ss.android.ugc.aweme.user.viewmodel.MultiProfilesViewModel;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class CheckAccountBottomSheetFragment extends Fragment implements 3YD, C3004Dyy {
    public static final DRQ LIZJ = new DRQ((byte) 0);
    public C3005Dyz LIZ;
    public List<Ryr> LIZIZ;
    public CheckMultiAccountViewModel LIZLLL;
    public MultiProfilesViewModel LJ;
    public final C0295Crj LJFF = 7he.LIZ(new DRO(this));
    public SparseArray LJI;

    static {
        Covode.recordClassIndex(99242);
    }

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

    public final 2uR ch_() {
        2uR r3 = new 2uR();
        3cC r2 = new 3cC();
        String string = getString(2131827129);
        n.LIZIZ(string, "");
        r2.LIZ(string);
        r3.LIZ(r2);
        3cA r1 = new 3cA();
        r1.LIZ(2131755740);
        r1.LIZ(new DRP(this));
        r3.LIZIZ(new 3cI[]{r1});
        return r3;
    }

    public static 0Bx LIZ(1hK r2) {
        0Bx LIZ2 = 0By.LIZ(r2, (0Bv) null);
        if (2GD.LIZ) {
            0Bs.LIZ(LIZ2, r2);
        }
        return LIZ2;
    }

    public static final /* synthetic */ C3005Dyz LIZ(CheckAccountBottomSheetFragment checkAccountBottomSheetFragment) {
        C3005Dyz dyz = checkAccountBottomSheetFragment.LIZ;
        if (dyz == null) {
            n.LIZ("");
        }
        return dyz;
    }

    public final void onCreate(Bundle bundle) {
        CheckAccountBottomSheetFragment.super.onCreate(bundle);
        1hK activity = getActivity();
        if (activity != null) {
            CheckMultiAccountViewModel LIZ2 = LIZ(activity).LIZ(CheckMultiAccountViewModel.class);
            n.LIZIZ(LIZ2, "");
            this.LIZLLL = LIZ2;
            MultiProfilesViewModel LIZ3 = LIZ(activity).LIZ(MultiProfilesViewModel.class);
            n.LIZIZ(LIZ3, "");
            this.LJ = LIZ3;
        }
    }

    public final void LIZ(Boolean bool) {
        Bundle bundle;
        Intent buildIntent;
        String str;
        if (bool != null) {
            List<Ryr> list = this.LIZIZ;
            if (list != null) {
                2UX r2 = new 2UX();
                r2.LIZ("detail_info", C2999Dyt.LIZ.LIZ(list));
                r2.LIZ("account_cnt", list.size());
                r2.LIZ("enter_method", "auto");
                if (n.LIZ(bool, true)) {
                    str = "add_account_mine";
                } else {
                    str = "add_account_someone_else";
                }
                r2.LIZ("exit_method", str);
                r2.LIZ("enter_from", "login_page");
                2nK.LIZ("account_list_submit", r2.LIZ);
            }
            if (getActivity() != null && (getActivity() instanceof I18nSignUpActivity)) {
                I18nSignUpActivity activity = getActivity();
                Objects.requireNonNull(activity, "null cannot be cast to non-null type com.ss.android.ugc.aweme.account.login.auth.I18nSignUpActivity");
                I18nSignUpActivity i18nSignUpActivity = activity;
                Intent intent = i18nSignUpActivity.LIZJ;
                SignupViewModel signupViewModel = i18nSignUpActivity.LJ;
                if (signupViewModel == null) {
                    n.LIZ("");
                }
                boolean z = false;
                if (signupViewModel.LJIIIIZZ().getBoolean("is_multi_account", false) && C2961DyH.LIZIZ.LIZ()) {
                    z = true;
                }
                if (intent != null) {
                    if (z) {
                        Bundle LIZ2 = I18nSignUpActivity.LIZ(intent);
                        if (LIZ2 == null) {
                            LIZ2 = new Bundle();
                        }
                        n.LIZIZ(LIZ2, "");
                        LIZ2.putBoolean("is_multi_account_same_user", true);
                        intent.putExtras(LIZ2);
                    }
                    Ryl.LIZ.LIZ(i18nSignUpActivity, intent);
                } else {
                    if (z) {
                        SmartRoute smartRoute = i18nSignUpActivity.LIZLLL;
                        if (smartRoute == null || (buildIntent = smartRoute.buildIntent()) == null || (bundle = I18nSignUpActivity.LIZ(buildIntent)) == null) {
                            bundle = new Bundle();
                        }
                        n.LIZIZ(bundle, "");
                        bundle.putBoolean("is_multi_account_same_user", true);
                        SmartRoute smartRoute2 = i18nSignUpActivity.LIZLLL;
                        if (smartRoute2 != null) {
                            smartRoute2.withParam(bundle);
                        }
                    }
                    SmartRoute smartRoute3 = i18nSignUpActivity.LIZLLL;
                    if (smartRoute3 != null) {
                        smartRoute3.open();
                    }
                }
            }
        }
        3S8.LIZ(TuxSheet.LJIJI, this);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        Context context = getContext();
        if (context == null) {
            n.LIZIZ();
        }
        RecyclerView recyclerView = new RecyclerView(context);
        recyclerView.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
        1hK activity = getActivity();
        if (activity != null) {
            n.LIZIZ(activity, "");
            this.LIZ = new C3005Dyz(new WeakReference(this), (2Ea) this.LJFF.getValue(), activity);
            CheckMultiAccountViewModel checkMultiAccountViewModel = this.LIZLLL;
            if (checkMultiAccountViewModel == null) {
                n.LIZ("");
            }
            LiveData LIZ2 = 0Br.LIZ(checkMultiAccountViewModel.LIZ, DRR.LIZ);
            n.LIZIZ(LIZ2, "");
            LIZ2.observe(getViewLifecycleOwner(), new DRN(this, recyclerView));
        }
        return recyclerView;
    }
}
