package com.ss.android.ugc.aweme.interest;

import X.0E3;
import X.0EB;
import X.0EF;
import X.8gF;
import X.APJ;
import X.AnonymousClass2SI;
import X.AnonymousClass2XK;
import X.AnonymousClass2YG;
import X.AnonymousClass2cB;
import X.AnonymousClass2cE;
import X.AnonymousClass352;
import X.AnonymousClass354;
import X.AnonymousClass356;
import X.AnonymousClass35B;
import X.AnonymousClass35E;
import X.AnonymousClass35F;
import X.AnonymousClass35G;
import X.AnonymousClass35H;
import X.AnonymousClass367;
import X.C03012Pr;
import X.C12422nK;
import X.C16832uR;
import X.C214534n;
import X.C215334v;
import X.C215734z;
import X.C224738l;
import X.C30953c7;
import X.Ls2;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.OQg;
import X.PgU;
import X.PhE;
import X.PlI;
import X.Qeg;
import X.SNU;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.apm.agent.v2.instrumentation.ActivityAgent;
import com.bytedance.covode.number.Covode;
import com.bytedance.keva.Keva;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.google.android.flexbox.FlexboxLayoutManager;
import com.google.gson.Gson;
import com.google.gson.m;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class UpdateInterestActivity extends SNU {
    public int LIZ = -1;
    public final C224738l LIZIZ = C224738l.LJIIL.LIZ();
    public final Keva LIZJ = Keva.getRepo("new_user_journey");
    public long LIZLLL;
    public long LJ = System.currentTimeMillis();
    public SparseArray LJFF;

    static {
        Covode.recordClassIndex(88697);
    }

    public final void _$_clearFindViewByIdCache() {
        SparseArray sparseArray = this.LJFF;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final View _$_findCachedViewById(int i) {
        if (this.LJFF == null) {
            this.LJFF = new SparseArray();
        }
        View view = (View) this.LJFF.get(i);
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i);
        this.LJFF.put(i, findViewById);
        return findViewById;
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.interest.UpdateInterestActivity, X.SNU, android.app.Activity] */
    public final void onDestroy() {
        8gF.LJ(this);
        UpdateInterestActivity.super.onDestroy();
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.interest.UpdateInterestActivity, X.SNU, android.app.Activity] */
    public final void onPause() {
        8gF.LIZJ(this);
        UpdateInterestActivity.super.onPause();
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.interest.UpdateInterestActivity, X.SNU, android.app.Activity] */
    public final void onStart() {
        8gF.LIZ(this);
        UpdateInterestActivity.super.onStart();
    }

    public final void onWindowFocusChanged(boolean z) {
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.interest.UpdateInterestActivity", "onWindowFocusChanged", true);
        UpdateInterestActivity.super.onWindowFocusChanged(z);
    }

    public final long LIZ() {
        return (System.currentTimeMillis() - this.LJ) + this.LIZLLL;
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [com.ss.android.ugc.aweme.interest.UpdateInterestActivity, X.SNU, android.app.Activity] */
    public final void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.interest.UpdateInterestActivity", "onResume", true);
        UpdateInterestActivity.super.onResume();
        this.LJ = System.currentTimeMillis();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.interest.UpdateInterestActivity", "onResume", false);
    }

    /* JADX WARNING: type inference failed for: r6v0, types: [com.ss.android.ugc.aweme.interest.UpdateInterestActivity, X.SNU, android.app.Activity] */
    public final void onStop() {
        8gF.LIZLLL(this);
        UpdateInterestActivity.super.onStop();
        this.LIZLLL += System.currentTimeMillis() - this.LJ;
        if (EnterTransitionCrashOptimizer.getContext() != null) {
            try {
                getWindow().getDecorView().getViewTreeObserver().dispatchOnPreDraw();
            } catch (Throwable unused) {
            }
        }
        try {
            getWindow().getDecorView().getViewTreeObserver().dispatchOnPreDraw();
        } catch (Throwable unused2) {
        }
    }

    public final void LIZIZ() {
        String str;
        PgU<AnonymousClass2SI> LIZ2;
        String LIZIZ2 = AnonymousClass2cB.LIZLLL.LIZIZ();
        m mVar = new m();
        Integer LIZIZ3 = AnonymousClass2cE.LIZ.LIZIZ();
        if (LIZIZ3 != null) {
            LIZIZ3.intValue();
            mVar.LIZ(String.valueOf(AnonymousClass2XK.TOPIC_INTEREST_SELECTION.getId()), AnonymousClass2cE.LIZ.LIZIZ());
        }
        if (mVar.LIZ.size() != 0) {
            str = new Gson().LIZ(mVar);
        } else {
            str = null;
        }
        if (LIZIZ2 != null) {
            LIZ2 = AnonymousClass2YG.LIZ.getJourney(Integer.valueOf(this.LIZIZ.LJ()), "new_user_journey", LIZIZ2, str);
        } else {
            LIZ2 = AnonymousClass2YG.LIZ.getJourney(Integer.valueOf(this.LIZIZ.LJ()), "new_user_journey", (String) null, str);
        }
        LIZ2.LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZIZ(new AnonymousClass356(this));
    }

    /* JADX WARNING: type inference failed for: r7v0, types: [X.4Qh, com.ss.android.ugc.aweme.interest.UpdateInterestActivity] */
    public final void onBackPressed() {
        C214534n r5;
        RecyclerView _$_findCachedViewById = _$_findCachedViewById(2131369756);
        n.LIZIZ(_$_findCachedViewById, "");
        FlexboxLayoutManager flexboxLayoutManager = null;
        if (_$_findCachedViewById.getAdapter() != null) {
            RecyclerView _$_findCachedViewById2 = _$_findCachedViewById(2131369756);
            n.LIZIZ(_$_findCachedViewById2, "");
            0E3 adapter = _$_findCachedViewById2.getAdapter();
            Objects.requireNonNull(adapter, "null cannot be cast to non-null type com.ss.android.ugc.aweme.journey.step.interestselector.InterestAdapter");
            r5 = (C214534n) adapter;
        } else {
            r5 = null;
        }
        RecyclerView _$_findCachedViewById3 = _$_findCachedViewById(2131369756);
        n.LIZIZ(_$_findCachedViewById3, "");
        if (_$_findCachedViewById3.getLayoutManager() != null) {
            RecyclerView _$_findCachedViewById4 = _$_findCachedViewById(2131369756);
            n.LIZIZ(_$_findCachedViewById4, "");
            0EF layoutManager = _$_findCachedViewById4.getLayoutManager();
            Objects.requireNonNull(layoutManager, "null cannot be cast to non-null type com.google.android.flexbox.FlexboxLayoutManager");
            flexboxLayoutManager = (FlexboxLayoutManager) layoutManager;
        }
        C12422nK.LIZ("exit_interest_selection", C215734z.LIZ("customize_interests_page", "skip", "", LIZ(), r5, flexboxLayoutManager).LIZ);
        UpdateInterestActivity.super.onBackPressed();
    }

    /* JADX WARNING: type inference failed for: r6v0, types: [X.4Qh, com.ss.android.ugc.aweme.interest.UpdateInterestActivity] */
    public final void LIZ(List<C215334v> list) {
        M12.LIZ(list);
        OQg _$_findCachedViewById = _$_findCachedViewById(2131370607);
        n.LIZIZ(_$_findCachedViewById, "");
        _$_findCachedViewById.setVisibility(8);
        RecyclerView _$_findCachedViewById2 = _$_findCachedViewById(2131369756);
        n.LIZIZ(_$_findCachedViewById2, "");
        _$_findCachedViewById2.setLayoutManager(new FlexboxLayoutManager(this));
        RecyclerView _$_findCachedViewById3 = _$_findCachedViewById(2131369756);
        n.LIZIZ(_$_findCachedViewById3, "");
        _$_findCachedViewById3.setVisibility(0);
        AnonymousClass354 r2 = new AnonymousClass354(this);
        RecyclerView _$_findCachedViewById4 = _$_findCachedViewById(2131369756);
        n.LIZIZ(_$_findCachedViewById4, "");
        _$_findCachedViewById4.setAdapter(new AnonymousClass352(list, r2));
        C12422nK.LIZ("show_interest_selection", C215734z.LIZ("customize_interests_page", false).LIZ);
    }

    /* JADX WARNING: type inference failed for: r9v0, types: [X.4Qh, com.ss.android.ugc.aweme.interest.UpdateInterestActivity, X.SNU, android.app.Activity] */
    public final void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.interest.UpdateInterestActivity", "onCreate", true);
        activityConfiguration(AnonymousClass35H.LIZ);
        UpdateInterestActivity.super.onCreate(bundle);
        setContentView(2131560217);
        _$_findCachedViewById(2131370607).setOnTouchListener(AnonymousClass35G.LIZ);
        APJ.LIZ(_$_findCachedViewById(2131369793), 0.5f);
        _$_findCachedViewById(2131369793).setOnClickListener(new AnonymousClass35B(this));
        C16832uR r2 = new C16832uR();
        String string = getString(2131832205);
        n.LIZIZ(string, "");
        AnonymousClass367.LIZ(r2, string, (Ls2<C03012Pr>) new AnonymousClass35F(this));
        ((C30953c7) _$_findCachedViewById(2131371262)).setNavActions(r2);
        Qeg _$_findCachedViewById = _$_findCachedViewById(2131369793);
        n.LIZIZ(_$_findCachedViewById, "");
        _$_findCachedViewById.setEnabled(false);
        RecyclerView _$_findCachedViewById2 = _$_findCachedViewById(2131369756);
        n.LIZIZ(_$_findCachedViewById2, "");
        _$_findCachedViewById2.setItemAnimator((0EB) null);
        _$_findCachedViewById(2131370607).post(new AnonymousClass35E(this));
        LIZIZ();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.interest.UpdateInterestActivity", "onCreate", false);
    }
}
