package com.ss.android.ugc.aweme.mix.createmix;

import X.0C0;
import X.0CH;
import X.2GO;
import X.2HZ;
import X.2Pr;
import X.46i;
import X.4HR;
import X.4hP;
import X.8gF;
import X.A7H;
import X.ARD;
import X.ARE;
import X.AY0;
import X.AY1;
import X.AY2;
import X.AY3;
import X.AY4;
import X.AY5;
import X.AY6;
import X.AYA;
import X.AYB;
import X.AYC;
import X.C1205AWj;
import X.C1245AXx;
import X.C1246AXy;
import X.C1247AXz;
import X.C1252AYe;
import X.C2188AoK;
import X.Csa;
import X.Css;
import X.Cuh;
import X.Cus;
import X.Cv8;
import X.Cvh;
import X.CwK;
import X.CwU;
import X.Cwc;
import X.Cwf;
import X.D1G;
import X.ISm;
import X.KEM;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.M12;
import X.PHD;
import X.Rc9;
import android.content.Intent;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.bytedance.apm.agent.v2.instrumentation.ActivityAgent;
import com.bytedance.assem.arch.viewModel.AssemViewModel;
import com.bytedance.covode.number.Covode;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.mix.createmix.viewmodel.MixCreateViewModel;
import com.ss.android.ugc.aweme.mix.editname.EditPlayListNameFragment;
import com.ss.android.ugc.aweme.mix.mixdetail.viewmodel.MixVideosManageViewModel;
import com.ss.android.ugc.aweme.mix.pickcandidate.AddMultiVideoFragment;
import com.ss.android.ugc.aweme.mix.services.MixFeedService;
import java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;

public final class CreatePlaylistActivity extends C1205AWj implements ARE, 2HZ, 2GO {
    public static final AYA LIZJ = new AYA((byte) 0);
    public int LIZ = 1;
    public Aweme LIZIZ;
    public final Csa LIZLLL;
    public final Csa LJ;
    public String LJFF = "";
    public String LJI = "";
    public String LJII = "";
    public SparseArray LJIIIIZZ;

    static {
        Covode.recordClassIndex(92346);
    }

    private final MixVideosManageViewModel LIZJ() {
        return (MixVideosManageViewModel) this.LJ.getValue();
    }

    public final MixCreateViewModel LIZIZ() {
        return (MixCreateViewModel) this.LIZLLL.getValue();
    }

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

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

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(435, new Rc9(CreatePlaylistActivity.class, "onCreateMixListSuccess", AYB.class, ThreadMode.POSTING, 0, false));
        return hashMap;
    }

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

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

    /* JADX WARNING: type inference failed for: r3v0, types: [X.SNU, android.app.Activity, com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity] */
    public final void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity", "onResume", true);
        CreatePlaylistActivity.super.onResume();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity", "onResume", false);
    }

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

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

    public final 0CH getActualLifecycleOwner() {
        ARD.LIZIZ(this);
        return this;
    }

    public final Cv8 getActualLifecycleOwnerHolder() {
        ARD.LIZ(this);
        return this;
    }

    public final 4hP getActualReceiver() {
        ARD.LIZLLL(this);
        return this;
    }

    public final Cuh<4hP> getActualReceiverHolder() {
        ARD.LIZJ(this);
        return this;
    }

    public final 0CH getHostLifecycleOwner() {
        M12.LIZ(this);
        return null;
    }

    public final 0CH getOwnLifecycleOwner() {
        ARD.LJ(this);
        return this;
    }

    public final 4hP getReceiverForHostVM() {
        M12.LIZ(this);
        return null;
    }

    public final boolean getUniqueOnlyDefault() {
        return ARD.LJFF(this);
    }

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

    public CreatePlaylistActivity() {
        D1G LIZ2 = KEM.LIZ.LIZ(MixCreateViewModel.class);
        this.LIZLLL = new Csa(LIZ2, new AY0(LIZ2), Css.LIZ, C2188AoK.LIZ((0CH) this, false), C2188AoK.LIZ((0C0) this, false), A7H.LIZ, AY2.INSTANCE);
        D1G LIZ3 = KEM.LIZ.LIZ(MixVideosManageViewModel.class);
        this.LJ = new Csa(LIZ3, new AY1(LIZ3), Css.LIZ, C2188AoK.LIZ((0CH) this, false), C2188AoK.LIZ((0C0) this, false), A7H.LIZ, AY3.INSTANCE);
    }

    public final Fragment LIZ() {
        Fragment LIZ2;
        Fragment LIZ3;
        int i = this.LIZ;
        if (i == 1) {
            LIZIZ().LIZ(true);
            C1252AYe.LIZ.LIZIZ(LIZIZ().LIZIZ, LIZIZ().LIZJ);
            if (MixFeedService.LJIIIIZZ().LIZIZ()) {
                C1252AYe.LIZ.LIZJ(this.LJFF, this.LJI);
                LIZ2 = GuideCreateFragment.LIZLLL.LIZ(this.LJFF, LIZIZ().LIZJ);
            } else {
                C1252AYe.LIZ.LIZLLL(LIZIZ().LIZIZ, LIZIZ().LIZJ);
                LIZ2 = AYC.LIZ(EditPlayListNameFragment.LIZ, 1, (String) null, (String) null, (Aweme) null, (Long) null, (String) null, 62);
            }
            return LIZ2;
        } else if (i == 2) {
            LIZIZ().LIZ(true);
            C1252AYe.LIZ.LIZIZ(LIZIZ().LIZIZ, LIZIZ().LIZJ);
            LIZJ().LIZ(this.LJII, "", this.LJFF);
            LIZIZ().LIZ(this.LJII);
            if (MixFeedService.LJIIIIZZ().LIZIZ()) {
                C1252AYe.LIZ.LIZJ(this.LJFF, this.LJI);
                LIZ3 = GuideCreateFragment.LIZLLL.LIZ(this.LJFF, LIZIZ().LIZJ);
            } else {
                C1252AYe.LIZ.LJ(LIZIZ().LIZIZ, LIZIZ().LIZJ);
                LIZ3 = AddMultiVideoFragment.LIZIZ.LIZ();
            }
            return LIZ3;
        } else if (i != 4) {
            LIZIZ().LIZ(true);
            C1252AYe.LIZ.LIZIZ(LIZIZ().LIZIZ, LIZIZ().LIZJ);
            C1252AYe.LIZ.LIZLLL(LIZIZ().LIZIZ, LIZIZ().LIZJ);
            return AYC.LIZ(EditPlayListNameFragment.LIZ, 3, (String) null, (String) null, this.LIZIZ, (Long) null, (String) null, 54);
        } else {
            LIZJ().LIZ(this.LJII, "", this.LJFF);
            LIZIZ().LIZ(this.LJII);
            LIZIZ().LIZ(false);
            C1252AYe.LIZ.LJ(LIZJ().LIZ, "manage_video");
            return AddMultiVideoFragment.LIZIZ.LIZ();
        }
    }

    public static Bundle LIZ(Intent intent) {
        try {
            return intent.getExtras();
        } catch (Exception unused) {
            return null;
        }
    }

    @ISm
    public final void onCreateMixListSuccess(AYB ayb) {
        M12.LIZ(ayb);
        finish();
    }

    /* JADX WARNING: type inference failed for: r13v0, types: [X.AWj, X.SNU, java.lang.Object, android.app.Activity, com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity] */
    public final void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity", "onCreate", true);
        Intent intent = getIntent();
        if (intent != null && intent.hasExtra("enter_from")) {
            String LIZ2 = LIZ(intent, "enter_from");
            if (LIZ2 == null) {
                LIZ2 = "";
            }
            this.LJFF = LIZ2;
            String LIZ3 = LIZ(intent, "enter_method");
            if (LIZ3 == null) {
                LIZ3 = "";
            }
            this.LJI = LIZ3;
            MixCreateViewModel LIZIZ2 = LIZIZ();
            String str = this.LJFF;
            String str2 = this.LJI;
            M12.LIZ(str, str2);
            LIZIZ2.LIZIZ = str;
            LIZIZ2.LIZJ = str2;
            this.LIZ = intent.getIntExtra("open_fragment_type", 1);
            String LIZ4 = LIZ(intent, "key_manage_mix_id");
            if (LIZ4 == null) {
                LIZ4 = "";
            }
            this.LJII = LIZ4;
            Bundle LIZ5 = LIZ(intent);
            if (!(LIZ5 == null || LIZ5.getSerializable("key_mix_add_aweme_info") == null)) {
                Aweme serializableExtra = intent.getSerializableExtra("key_mix_add_aweme_info");
                if (serializableExtra != null) {
                    this.LIZIZ = serializableExtra;
                } else {
                    NullPointerException nullPointerException = new NullPointerException("null cannot be cast to non-null type com.ss.android.ugc.aweme.feed.model.Aweme");
                    ActivityAgent.onTrace("com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity", "onCreate", false);
                    throw nullPointerException;
                }
            }
        }
        super.onCreate(bundle);
        Cus.LIZ(this, LIZIZ(), AY5.LIZ, (Cvh) null, new C1245AXx(this), 6);
        EventBus.LIZ(EventBus.LIZ(), this);
        46i.LIZ();
        IAccountUserService LJFF2 = 46i.LIZ.LJFF();
        n.LIZIZ(LJFF2, "");
        String curUserId = LJFF2.getCurUserId();
        46i.LIZ();
        IAccountUserService LJFF3 = 46i.LIZ.LJFF();
        n.LIZIZ(LJFF3, "");
        String curSecUserId = LJFF3.getCurSecUserId();
        AssemViewModel.asyncSubscribe$default(LIZIZ(), AY6.LIZ, (Cvh) null, new C1247AXz(this), AY4.LIZ, new C1246AXy(this, curUserId, curSecUserId), 2, (Object) null);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.mix.createmix.CreatePlaylistActivity", "onCreate", false);
    }

    public static String LIZ(Intent intent, String str) {
        try {
            return intent.getStringExtra(str);
        } catch (Exception unused) {
            return null;
        }
    }

    public final <S extends 4HR> void subscribe(AssemViewModel<S> assemViewModel, Cvh<S> cvh, LsC<? super Throwable, 2Pr> lsC, LsD<? super 4hP, ? super S, 2Pr> lsD) {
        M12.LIZ(assemViewModel, cvh, lsD);
        ARD.LIZ(this, assemViewModel, cvh, lsC, lsD);
    }

    public final <S extends 4HR, A> void selectSubscribe(AssemViewModel<S> assemViewModel, PHD<S, ? extends A> phd, Cvh<CwK<A>> cvh, LsC<? super Throwable, 2Pr> lsC, LsD<? super 4hP, ? super A, 2Pr> lsD) {
        M12.LIZ(assemViewModel, phd, cvh, lsD);
        ARD.LIZ(this, assemViewModel, phd, cvh, lsC, lsD);
    }

    public final <S extends 4HR, A> void selectSubscribeOnAsync(AssemViewModel<S> assemViewModel, PHD<S, ? extends A> phd, Cvh<CwK<A>> cvh, LsC<? super Throwable, 2Pr> lsC, LsD<? super 4hP, ? super A, 2Pr> lsD) {
        M12.LIZ(assemViewModel, phd, cvh, lsD);
        ARD.LIZIZ(this, assemViewModel, phd, cvh, lsC, lsD);
    }

    public final <S extends 4HR, A, B> void selectSubscribe(AssemViewModel<S> assemViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, Cvh<CwU<A, B>> cvh, LsC<? super Throwable, 2Pr> lsC, LsE<? super 4hP, ? super A, ? super B, 2Pr> lsE) {
        M12.LIZ(assemViewModel, phd, phd2, cvh, lsE);
        ARD.LIZ(this, assemViewModel, phd, phd2, cvh, lsC, lsE);
    }

    public final <S extends 4HR, A, B, C> void selectSubscribe(AssemViewModel<S> assemViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, Cvh<Cwc<A, B, C>> cvh, LsC<? super Throwable, 2Pr> lsC, LsF<? super 4hP, ? super A, ? super B, ? super C, 2Pr> lsF) {
        LsF<? super 4hP, ? super A, ? super B, ? super C, 2Pr> lsF2 = lsF;
        AssemViewModel<S> assemViewModel2 = assemViewModel;
        PHD<S, ? extends A> phd4 = phd;
        PHD<S, ? extends B> phd5 = phd2;
        PHD<S, ? extends C> phd6 = phd3;
        Cvh<Cwc<A, B, C>> cvh2 = cvh;
        M12.LIZ(assemViewModel2, phd4, phd5, phd6, cvh2, lsF2);
        ARD.LIZ(this, assemViewModel2, phd4, phd5, phd6, cvh2, lsC, lsF2);
    }

    public final <S extends 4HR, A, B, C, D> void selectSubscribe(AssemViewModel<S> assemViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, PHD<S, ? extends D> phd4, Cvh<Cwf<A, B, C, D>> cvh, LsC<? super Throwable, 2Pr> lsC, Lsh<? super 4hP, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh) {
        Lsh<? super 4hP, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh2 = lsh;
        AssemViewModel<S> assemViewModel2 = assemViewModel;
        PHD<S, ? extends A> phd5 = phd;
        PHD<S, ? extends B> phd6 = phd2;
        PHD<S, ? extends C> phd7 = phd3;
        PHD<S, ? extends D> phd8 = phd4;
        Cvh<Cwf<A, B, C, D>> cvh2 = cvh;
        M12.LIZ(assemViewModel2, phd5, phd6, phd7, phd8, cvh2, lsh2);
        ARD.LIZ(this, assemViewModel2, phd5, phd6, phd7, phd8, cvh2, lsC, lsh2);
    }
}
