package com.ss.android.ugc.aweme.compliance.privacy.settings.account;

import X.0Bx;
import X.0EB;
import X.0Gp;
import X.1Cn;
import X.6iy;
import X.9LK;
import X.AnonymousClass2GO;
import X.AnonymousClass2HZ;
import X.AnonymousClass2UX;
import X.AnonymousClass2aZ;
import X.C03012Pr;
import X.C12422nK;
import X.C17702vq;
import X.C30953c7;
import X.C30983cA;
import X.C31003cC;
import X.C31063cI;
import X.C35783ju;
import X.C36023kI;
import X.C36063kM;
import X.C36623lG;
import X.C36673lL;
import X.C36883lg;
import X.C36893lh;
import X.C36903li;
import X.C36913lj;
import X.C37823nC;
import X.C37863nG;
import X.C38953p1;
import X.C38963p2;
import X.C39123pI;
import X.C49104Cw;
import X.CZv;
import X.Crj;
import X.EMo;
import X.Hx0;
import X.ISm;
import X.Lea;
import X.Ls2;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PhE;
import X.PlI;
import X.Rc9;
import X.SzB;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.ValueCallback;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRouter;
import com.bytedance.router.arg.RouteArgExtension;
import com.bytedance.router.fragment.FragmentRoute;
import com.ss.android.deviceregister.DeviceRegisterManager;
import com.ss.android.ugc.aweme.compliance.privacy.settings.account.base.BaseFragment;
import com.ss.android.ugc.aweme.views.WrapLinearLayoutManager;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import kotlin.h.b.n;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;

@CZv
public final class PrivacySettingFragmentMain extends BaseFragment implements AnonymousClass2HZ, AnonymousClass2GO {
    public C37823nC LIZ;
    public PrivacySettingViewModel LIZIZ;
    public long LIZJ;
    public boolean LIZLLL;
    public C36023kI LJ;
    public final Crj LJFF = RouteArgExtension.INSTANCE.optionalArg(this, C36903li.LIZ, "enter_method", String.class);
    public SparseArray LJI;

    static {
        Covode.recordClassIndex(61433);
    }

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

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

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(58, new Rc9(PrivacySettingFragmentMain.class, "onJsBroadCastEvent", Hx0.class, ThreadMode.MAIN, 0, false));
        return hashMap;
    }

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

    public final void onDestroy() {
        EventBus.LIZ().LIZIZ(this);
        PrivacySettingFragmentMain.super.onDestroy();
    }

    public final void LIZ() {
        C17702vq LIZ2;
        EMo LIZ3 = SzB.LIZ(this).LIZJ().LIZ("source_default_key", C17702vq.class);
        if (LIZ3 == null || (LIZ2 = LIZ3.LIZ()) == null || !LIZ2.LIZ) {
            super.LIZ();
        } else {
            FragmentRoute fragmentNavigation = SmartRouter.fragmentNavigation(this);
            FragmentRoute.pop$default(fragmentNavigation, (Boolean) null, 1, (Object) null);
            FragmentRoute.commit$default(fragmentNavigation, (Boolean) null, 1, (Object) null);
        }
        long j = this.LIZJ;
        AnonymousClass2UX r4 = new AnonymousClass2UX();
        r4.LIZ("enter_from", "privacy_and_safety_settings");
        r4.LIZ("duration", System.currentTimeMillis() - j);
        C12422nK.LIZ("stay_time", r4.LIZ);
    }

    public final void onAttach(Context context) {
        PrivacySettingFragmentMain.super.onAttach(context);
        if (!this.LIZLLL) {
            this.LIZLLL = true;
            C49104Cw.LIZ(this, "privacy-setting");
        }
    }

    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        PrivacySettingViewModel LIZ2 = new 0Bx(this).LIZ(PrivacySettingViewModel.class);
        n.LIZIZ(LIZ2, "");
        PrivacySettingViewModel privacySettingViewModel = LIZ2;
        this.LIZIZ = privacySettingViewModel;
        if (privacySettingViewModel == null) {
            n.LIZ("");
        }
        String str = (String) this.LJFF.getValue();
        if (str == null) {
            str = "";
        }
        M12.LIZ(str);
        privacySettingViewModel.LIZIZ = str;
        PrivacySettingViewModel privacySettingViewModel2 = this.LIZIZ;
        if (privacySettingViewModel2 == null) {
            n.LIZ("");
        }
        privacySettingViewModel2.LIZ.observe(this, C35783ju.LIZ);
        this.LJ = C36063kM.LIZ;
        C39123pI.LIZ.LIZ(false);
        EventBus.LIZ(EventBus.LIZ(), this);
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public final void onJsBroadCastEvent(Hx0 hx0) {
        Context context;
        M12.LIZ(hx0);
        if (C37863nG.LIZ.LIZIZ()) {
            try {
                if (TextUtils.equals("delete_unregistered_account_success", hx0.LIZIZ.getString("eventName")) && (context = getContext()) != null) {
                    DeviceRegisterManager.clearDidAndIid(context, UUID.randomUUID().toString());
                    CookieManager.getInstance().removeAllCookies((ValueCallback) null);
                    9LK.LIZ("privacy_monitor_event_relaunch", (JSONObject) null, (JSONObject) null, (JSONObject) null);
                    0Gp.LIZ(2000).LIZ(new C36913lj(context, this));
                }
            } catch (JSONException e) {
                AnonymousClass2aZ r2 = new AnonymousClass2aZ();
                r2.LIZ("privacy_monitor_param_name", "account_delete_success_event_json_exception");
                JSONObject LIZ2 = r2.LIZ();
                AnonymousClass2aZ r22 = new AnonymousClass2aZ();
                String message = e.getMessage();
                if (message == null) {
                    message = null;
                }
                r22.LIZ("privacy_monitor_param_log", message);
                9LK.LIZ("privacy_monitor_event_exception", LIZ2, (JSONObject) null, r22.LIZ());
            }
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        PrivacySettingFragmentMain.super.onViewCreated(view, bundle);
        C30983cA r1 = new C30983cA();
        r1.LIZ(2131755170);
        r1.LIZ((Ls2<C03012Pr>) new C36883lg(this));
        ((C30953c7) LIZ(2131371289)).LIZ((C31063cI) r1);
        C31003cC r12 = new C31003cC();
        String string = getString(2131820732);
        n.LIZIZ(string, "");
        r12.LIZ(string);
        ((C30953c7) LIZ(2131371289)).LIZ(r12);
        getContext();
        WrapLinearLayoutManager wrapLinearLayoutManager = new WrapLinearLayoutManager(1);
        RecyclerView LIZ2 = LIZ(2131367123);
        n.LIZIZ(LIZ2, "");
        LIZ2.setLayoutManager(wrapLinearLayoutManager);
        RecyclerView LIZ3 = LIZ(2131367123);
        n.LIZIZ(LIZ3, "");
        LIZ3.setItemAnimator((0EB) null);
        PrivacySettingViewModel privacySettingViewModel = this.LIZIZ;
        if (privacySettingViewModel == null) {
            n.LIZ("");
        }
        C37823nC r2 = new C37823nC(privacySettingViewModel, this);
        this.LIZ = r2;
        List LIZ4 = 6iy.LIZ(r2);
        RecyclerView LIZ5 = LIZ(2131367123);
        n.LIZIZ(LIZ5, "");
        LIZ5.setAdapter(new 1Cn(LIZ4));
        PrivacySettingViewModel privacySettingViewModel2 = this.LIZIZ;
        if (privacySettingViewModel2 == null) {
            n.LIZ("");
        }
        C38963p2.LIZIZ.LIZ(true);
        privacySettingViewModel2.LIZ();
        C38953p1.LIZ.LIZ().LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZIZ(C36893lh.LIZ).LIZ(new C36623lG(privacySettingViewModel2), C36673lL.LIZ);
        this.LIZJ = System.currentTimeMillis();
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        C37823nC r1 = this.LIZ;
        if (r1 == null) {
            n.LIZ("");
        }
        Iterator it = Lea.LJII(r1.LJI).iterator();
        while (it.hasNext()) {
            it.next();
        }
    }
}
