package com.ss.android.ugc.aweme.journey.step.applanguage;

import X.AnonymousClass2UX;
import X.AnonymousClass34W;
import X.C12422nK;
import X.C222737r;
import X.C222937t;
import X.C223037u;
import X.C223137v;
import X.C32833f9;
import X.C474046i;
import X.M12;
import X.OQN;
import android.content.Context;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.app.services.HybridABInfoService;
import com.ss.android.ugc.aweme.journey.step.JourneyBaseFragment;
import com.ss.android.ugc.aweme.setting.services.SettingServiceImpl;
import java.util.ArrayList;
import java.util.Map;
import kotlin.h.b.n;

public final class ChooseAppLanguageComponent extends JourneyBaseFragment {
    public SparseArray LJIIIZ;

    static {
        Covode.recordClassIndex(88883);
    }

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

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

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

    public final void onStop() {
        this.LIZLLL = new C222937t(this);
        super.onStop();
    }

    public final void LIZ(boolean z, String str) {
        if (!z) {
            AnonymousClass2UX r4 = new AnonymousClass2UX();
            r4.LIZ("enter_from", "new_user_journey");
            r4.LIZ("language_type", str);
            r4.LIZ("duration", System.currentTimeMillis() - this.LIZJ);
            C12422nK.LIZ("choose_language_popup", r4.LIZ);
        }
        AnonymousClass2UX r42 = new AnonymousClass2UX();
        r42.LIZ("enter_from", "new_user_journey");
        r42.LIZ("duration", System.currentTimeMillis() - this.LIZJ);
        Integer LIZ = HybridABInfoService.LIZIZ().LIZ();
        if (LIZ != null) {
            r42.LIZ("is_ab_backend_resp_received", LIZ.intValue());
        }
        C12422nK.LIZ("language_popup_duration", r42.LIZ);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        RecyclerView LIZIZ = LIZIZ();
        LIZIZ().getContext();
        LIZIZ.setLayoutManager(new LinearLayoutManager());
        String[] strArr = {"ms-MY", "zh-Hant-TW", "en"};
        ArrayList arrayList = new ArrayList();
        Map LJIIIZ2 = SettingServiceImpl.LJIJJ().LJIIIZ();
        int i = 0;
        do {
            Object obj = LJIIIZ2.get(strArr[i]);
            if (obj == null) {
                n.LIZIZ();
            }
            arrayList.add(obj);
            i++;
        } while (i < 3);
        C223137v r1 = new C223137v(this);
        String string = getString(2131827501);
        n.LIZIZ(string, "");
        AnonymousClass34W r2 = new AnonymousClass34W(arrayList, r1, string);
        LIZIZ().setAdapter(r2);
        OQN LIZ = LIZ(2131371262);
        String str2 = r2.LIZ;
        if (str2 == null) {
            str2 = "";
        }
        LIZ.setTitle(str2);
        LIZ().setOnClickListener(new C222737r(this));
        LIZ(2131370385).setOnClickListener(new C223037u(this));
        C32833f9 r22 = C32833f9.LIZ;
        Context context = LIZIZ().getContext();
        n.LIZIZ(context, "");
        r22.LIZ(context, true);
        AnonymousClass2UX r23 = new AnonymousClass2UX();
        r23.LIZ("enter_from", "new_user_journey");
        IAccountUserService LJFF = C474046i.LJFF();
        n.LIZIZ(LJFF, "");
        if (LJFF.isLogin()) {
            str = "1";
        } else {
            str = "0";
        }
        r23.LIZ("is_login", str);
        C12422nK.LIZ("show_language_popup", r23.LIZ);
    }
}
