package com.ss.android.ugc.aweme.choosemusic.activity;

import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.0HH;
import X.1hK;
import X.2GD;
import X.2OR;
import X.2UX;
import X.2nK;
import X.4Ek;
import X.8gF;
import X.B9U;
import X.CAC;
import X.OOJ;
import X.OOK;
import X.OSU;
import X.Qeg;
import X.SNU;
import X.Sx2;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.TextView;
import com.bytedance.apm.agent.v2.instrumentation.ActivityAgent;
import com.bytedance.covode.number.Covode;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.ss.android.ugc.aweme.AccountService;
import com.ss.android.ugc.aweme.analysis.Analysis;
import com.ss.android.ugc.aweme.base.opensourcemodified.android.support.design.widget.ViewPagerBottomSheetBehavior;
import com.ss.android.ugc.aweme.base.utils.KeyboardUtils;
import com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel;
import com.ss.android.ugc.aweme.out.AVExternalServiceImpl;
import com.ss.android.ugc.aweme.performance.OpenMusicPanelPerformanceMonitor;
import com.ss.android.ugc.aweme.performance.PerformanceMonitor;
import com.ss.android.ugc.aweme.services.BaseUserService;
import com.ss.android.ugc.aweme.services.performance.IAVPerformance;
import com.ss.android.ugc.aweme.shortvideo.model.MusicModel;

public class ChooseMusicActivity extends SNU implements B9U {
    public Qeg LIZ;
    public ViewPagerBottomSheetBehavior LIZIZ;
    public int LIZJ;
    public boolean LIZLLL;
    public CAC LJ;
    public TextView LJFF;
    public boolean LJI;
    public IAVPerformance LJII = AVExternalServiceImpl.LIZ().provideAVPerformance();

    static {
        Covode.recordClassIndex(55978);
    }

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

    public void onWindowFocusChanged(boolean z) {
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity", "onWindowFocusChanged", true);
        ChooseMusicActivity.super.onWindowFocusChanged(z);
    }

    public void onBackPressed() {
        LIZIZ();
        ChooseMusicActivity.super.onBackPressed();
    }

    public final Analysis cU_() {
        Analysis analysis = new Analysis();
        analysis.setLabelName("music_homepage");
        return analysis;
    }

    public void finish() {
        ChooseMusicActivity.super.finish();
        KeyboardUtils.LIZJ(this.LIZ);
        overridePendingTransition(0, 2130772013);
    }

    public void onEnterAnimationComplete() {
        ChooseMusicActivity.super.onEnterAnimationComplete();
        this.LJII.end((PerformanceMonitor) OpenMusicPanelPerformanceMonitor.LIZ, "animation_finished");
    }

    private boolean LIZJ() {
        if (AccountService.LIZ().LJFF().isChildrenMode() || this.LJI) {
            return false;
        }
        try {
            if (!2OR.LIZ.LIZIZ.getEnableLocalMusicEntrance().booleanValue()) {
                return false;
            }
            return true;
        } catch (4Ek e) {
            0HH.LIZ(e);
        }
    }

    public final void LIZIZ() {
        if (LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LIZIZ) {
            AVExternalServiceImpl.LIZ().publishService().setCurMusic((MusicModel) null);
            Intent intent = new Intent();
            intent.putExtra("is_cancel_current_choose_music", true);
            setResult(-1, intent);
        }
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [android.content.Context, com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity, X.SNU, android.app.Activity] */
    public void onPause() {
        8gF.LIZJ(this);
        ChooseMusicActivity.super.onPause();
        this.LJII.pause(this, "music_select", LIZ(getIntent(), "creation_id"), LIZ(getIntent(), "shoot_way"));
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity, X.SNU, android.app.Activity] */
    public void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity", "onResume", true);
        ChooseMusicActivity.super.onResume();
        if (this.LIZJ == 2) {
            OSU.LIZIZ("video_shoot_page");
        } else {
            OSU.LIZIZ("video_edit_page");
        }
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity", "onResume", false);
    }

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

    public final void LIZ() {
        this.LJFF = (TextView) findViewById(2131372279);
        if (!LIZJ() || !this.LJ.LIZ()) {
            this.LJFF.setVisibility(8);
            return;
        }
        this.LJFF.setVisibility(0);
        if (this.LIZLLL) {
            this.LJFF.setAlpha(0.5f);
            this.LJFF.setOnClickListener(Sx2.LIZ(new OOK(this)));
            return;
        }
        this.LJFF.setOnClickListener(Sx2.LIZ(new OOJ(this)));
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [android.content.Context, com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity, X.1hK, X.SNU, android.app.Activity] */
    public void onDestroy() {
        String str;
        String str2;
        8gF.LJ(this);
        String str3 = LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LIZLLL;
        MusicModel curMusic = AVExternalServiceImpl.LIZ().publishService().getCurMusic();
        if (curMusic != null) {
            str = String.valueOf(curMusic.getId());
        } else {
            str = null;
        }
        if (!TextUtils.isEmpty(str3) && !TextUtils.equals(str, str3)) {
            2UX r3 = new 2UX();
            r3.LIZ("value", 1);
            r3.LIZ("mission_id", LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LJ);
            r3.LIZ("page_source", LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LJFF);
            r3.LIZ("creator_followers", BaseUserService.createIUserServicebyMonsterPlugin(false).getCurrentUser().getFollowerCount());
            if (AVExternalServiceImpl.LIZ().commerceToolsService().isTcm()) {
                str2 = "0";
            } else {
                str2 = "1";
            }
            r3.LIZ("creator_type", str2);
            2nK.LIZ("mission_requirement_modified", r3.LIZ);
            LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LIZLLL = null;
            LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LJ = null;
            LIZ(this).LIZ(ChooseMusicWithSceneViewModel.class).LJFF = null;
        }
        ChooseMusicActivity.super.onDestroy();
        this.LJII.leave(this, "music_select");
    }

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

    /* JADX WARNING: type inference failed for: r3v1, types: [android.content.Context, com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity, X.1hK, X.1oX, X.SNU, android.app.Activity] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* JADX WARNING: Unknown variable types count: 1 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void onCreate(android.os.Bundle r23) {
        /*
            r22 = this;
            r3 = r22
            r3 = r3
            r0 = r23
            X.8gF.LIZ(r3, r0)
            java.lang.String r2 = "com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity"
            java.lang.String r1 = "onCreate"
            r8 = 1
            com.bytedance.apm.agent.v2.instrumentation.ActivityAgent.onTrace(r2, r1, r8)
            com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity.super.onCreate(r0)
            com.ss.android.ugc.aweme.services.performance.IAVPerformance r5 = r3.LJII
            com.ss.android.ugc.aweme.performance.OpenMusicPanelPerformanceMonitor r4 = com.ss.android.ugc.aweme.performance.OpenMusicPanelPerformanceMonitor.LIZ
            java.lang.String r0 = "choose_music_created"
            r5.step((com.ss.android.ugc.aweme.performance.PerformanceMonitor) r4, (java.lang.String) r0)
            com.ss.android.ugc.aweme.services.performance.IAVPerformance r4 = r3.LJII
            java.lang.String r0 = "music_select"
            r4.enter(r3, r0)
            r0 = 2130772011(0x7f01002b, float:1.7147128E38)
            r6 = 0
            r3.overridePendingTransition(r0, r6)
            r0 = 2131558475(0x7f0d004b, float:1.8742267E38)
            r3.setContentView(r0)
            r0 = 2131372426(0x7f0a298a, float:1.8364915E38)
            android.view.View r5 = r3.findViewById(r0)
            X.Qeg r5 = (X.Qeg) r5
            r3.LIZ = r5
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "title"
            java.lang.String r0 = LIZ(r4, r0)
            r5.setText(r0)
            X.CAC r4 = new X.CAC
            r0 = 2131369737(0x7f0a1f09, float:1.835946E38)
            android.view.View r0 = r3.findViewById(r0)
            r4.<init>(r3, r0)
            r3.LJ = r4
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "hide_local_music"
            boolean r0 = r4.getBooleanExtra(r0, r6)
            r3.LJI = r0
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "long_video"
            boolean r0 = r4.getBooleanExtra(r0, r6)
            r3.LIZLLL = r0
            r3.LIZ()
            r0 = 2131362572(0x7f0a030c, float:1.8344928E38)
            android.view.View r4 = r3.findViewById(r0)
            X.OOL r0 = new X.OOL
            r0.<init>(r3)
            r4.setOnClickListener(r0)
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "arguments"
            android.os.Bundle r14 = r4.getBundleExtra(r0)
            android.content.Context r0 = com.bytedance.sysoptimizer.BadParcelableCrashOptimizer.getContext()
            if (r14 == 0) goto L_0x00d5
            if (r0 == 0) goto L_0x0099
            java.lang.ClassLoader r0 = r0.getClassLoader()
            r14.setClassLoader(r0)
        L_0x0099:
            X.0Bx r4 = LIZ(r3)
            java.lang.Class<com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel> r0 = com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel.class
            X.0Bt r4 = r4.LIZ(r0)
            com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel r4 = (com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel) r4
            java.lang.String r0 = "mission_music_id"
            java.lang.String r0 = r14.getString(r0)
            r4.LIZLLL = r0
            X.0Bx r4 = LIZ(r3)
            java.lang.Class<com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel> r0 = com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel.class
            X.0Bt r4 = r4.LIZ(r0)
            com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel r4 = (com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel) r4
            java.lang.String r0 = "mission_id"
            java.lang.String r0 = r14.getString(r0)
            r4.LJ = r0
            X.0Bx r4 = LIZ(r3)
            java.lang.Class<com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel> r0 = com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel.class
            X.0Bt r4 = r4.LIZ(r0)
            com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel r4 = (com.ss.android.ugc.aweme.choosemusic.model.ChooseMusicWithSceneViewModel) r4
            java.lang.String r0 = "enter_from"
            java.lang.String r0 = r14.getString(r0)
            r4.LJFF = r0
        L_0x00d5:
            r0 = 2131370485(0x7f0a21f5, float:1.8360978E38)
            android.view.View r4 = r3.findViewById(r0)
            X.0Bf r4 = (X.0Bf) r4
            int r0 = X.3G1.LIZLLL()
            r4.setMinimumHeight(r0)
            r0 = 2131364037(0x7f0a08c5, float:1.83479E38)
            android.view.View r0 = r3.findViewById(r0)
            com.ss.android.ugc.aweme.base.opensourcemodified.android.support.design.widget.ViewPagerBottomSheetBehavior r4 = com.ss.android.ugc.aweme.base.opensourcemodified.android.support.design.widget.ViewPagerBottomSheetBehavior.LIZIZ(r0)
            r3.LIZIZ = r4
            com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity$1 r0 = new com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity$1
            r0.<init>()
            r4.LJIIJ = r0
            com.ss.android.ugc.aweme.base.opensourcemodified.android.support.design.widget.ViewPagerBottomSheetBehavior r0 = r3.LIZIZ
            r0.LIZLLL = r8
            com.ss.android.ugc.aweme.base.opensourcemodified.android.support.design.widget.ViewPagerBottomSheetBehavior r5 = r3.LIZIZ
            int r4 = X.3G1.LIZ(r3)
            int r0 = X.3G1.LIZLLL(r3)
            int r4 = r4 + r0
            r5.LIZ(r4)
            X.0AA r7 = r3.getSupportFragmentManager()
            r0 = 2131365158(0x7f0a0d26, float:1.8350173E38)
            androidx.fragment.app.Fragment r0 = r7.LIZ(r0)
            if (r0 != 0) goto L_0x01d1
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "com.ss.android.ugc.aweme.intent.extra.EXTRA_MUSIC_TYPE"
            int r0 = r4.getIntExtra(r0, r8)
            r3.LIZJ = r0
            com.ss.android.ugc.aweme.services.IExternalService r0 = com.ss.android.ugc.aweme.out.AVExternalServiceImpl.LIZ()
            com.ss.android.ugc.aweme.services.video.IAVPublishService r4 = r0.publishService()
            int r0 = r3.LIZJ
            r4.setMusicChooseType(r0)
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "challenge"
            java.lang.String r9 = LIZ(r4, r0)
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "creation_id"
            java.lang.String r16 = LIZ(r4, r0)
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "shoot_way"
            java.lang.String r15 = LIZ(r4, r0)
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "reuse_original_sound_id"
            java.lang.String r19 = LIZ(r4, r0)
            android.content.Intent r4 = r3.getIntent()
            java.lang.String r0 = "reuse_original_sound_url"
            java.io.Serializable r0 = r4.getSerializableExtra(r0)
            com.ss.android.ugc.aweme.base.model.UrlModel r0 = (com.ss.android.ugc.aweme.base.model.UrlModel) r0
            android.content.Intent r5 = r3.getIntent()
            java.lang.String r4 = "reuse_original_sound_length"
            int r21 = r5.getIntExtra(r4, r6)
            android.content.Intent r5 = r3.getIntent()
            java.lang.String r4 = "music_model"
            java.io.Serializable r10 = r5.getSerializableExtra(r4)
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel r10 = (com.ss.android.ugc.aweme.shortvideo.model.MusicModel) r10
            android.content.Intent r5 = r3.getIntent()
            java.lang.String r4 = "music_allow_clear"
            boolean r12 = r5.getBooleanExtra(r4, r6)
            android.content.Intent r5 = r3.getIntent()
            java.lang.String r4 = "music_allow_cut"
            boolean r18 = r5.getBooleanExtra(r4, r6)
            android.content.Intent r5 = r3.getIntent()
            java.lang.String r4 = "music_is_photomv"
            boolean r13 = r5.getBooleanExtra(r4, r6)
            X.0AP r6 = r7.LIZ()
            int r8 = r3.LIZJ
            X.BJk r11 = X.BJk.BtnConfirm
            boolean r4 = r3.LIZLLL
            r20 = r0
            r17 = r4
            com.ss.android.ugc.aweme.choosemusic.fragment.ChooseMusicFragment r5 = com.ss.android.ugc.aweme.choosemusic.fragment.ChooseMusicFragment.LIZ(r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21)
            r4 = 2131365158(0x7f0a0d26, float:1.8350173E38)
            r6.LIZ(r4, r5)
            r6.LIZIZ()
            X.CAC r4 = r3.LJ
            X.OOI r5 = new X.OOI
            r5 = r5
            r6 = r3
            r7 = r7
            r8 = r9
            r9 = r10
            r10 = r12
            r11 = r13
            r12 = r14
            r13 = r15
            r14 = r16
            r15 = r18
            r16 = r19
            r17 = r0
            r18 = r21
            r5.<init>(r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18)
            r4.LIZ(r5)
        L_0x01d1:
            r0 = 0
            com.bytedance.apm.agent.v2.instrumentation.ActivityAgent.onTrace(r2, r1, r0)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.choosemusic.activity.ChooseMusicActivity.onCreate(android.os.Bundle):void");
    }

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

    public void onActivityResult(int i, int i2, Intent intent) {
        ChooseMusicActivity.super.onActivityResult(i, i2, intent);
        if (i == 10086 && i2 == -1) {
            setResult(-1, intent);
            finish();
        }
    }
}
