package com.ss.android.ugc.aweme.ttsvoice.ui;

import X.0AA;
import X.0AP;
import X.2UX;
import X.2nK;
import X.4Bm;
import X.8gF;
import X.B1S;
import X.B1T;
import X.EIE;
import X.M12;
import X.SNU;
import android.content.Intent;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
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.music.model.Music;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import kotlin.h.b.n;

public final class TTSVoiceDetailsActivity extends SNU implements 4Bm, EIE {
    public long LIZ;
    public final ArrayList<B1S> LIZIZ = new ArrayList<>();
    public SparseArray LIZJ;

    static {
        Covode.recordClassIndex(120706);
    }

    public final String LJII() {
        return "tts_page";
    }

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

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

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

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

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

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

    /* JADX WARNING: type inference failed for: r0v0, types: [android.app.Activity] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void finish() {
        /*
            r1 = this;
            com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsActivity.super.finish()
            r0 = r1
            X.FNd.LIZ(r0)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsActivity.finish():void");
    }

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

    /* JADX WARNING: type inference failed for: r5v0, types: [com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsActivity, X.SNU, android.app.Activity] */
    public final void onDestroy() {
        8gF.LJ(this);
        TTSVoiceDetailsActivity.super.onDestroy();
        2UX r4 = new 2UX();
        r4.LIZ("anchor_type", LIZ(getIntent(), "anchor_type"));
        r4.LIZ("anchor_id", LIZ(getIntent(), "anchor_id"));
        r4.LIZ("anchor_name", LIZ(getIntent(), "anchor_name"));
        r4.LIZ("main_anchor_type", LIZ(getIntent(), "main_anchor_type"));
        r4.LIZ("main_anchor_id", LIZ(getIntent(), "main_anchor_id"));
        r4.LIZ("main_anchor_name", LIZ(getIntent(), "main_anchor_name"));
        r4.LIZ("tone_list", LIZ(getIntent(), "anchor_id"));
        r4.LIZ("duration", System.currentTimeMillis() - this.LIZ);
        n.LIZIZ(r4, "");
        2nK.LIZ("multi_anchor_stay_time", r4.LIZ);
    }

    public final void registerActivityOnKeyDownListener(B1S b1s) {
        M12.LIZ(b1s);
        ArrayList<B1S> arrayList = this.LIZIZ;
        if (!arrayList.contains(b1s)) {
            arrayList.add(b1s);
        }
    }

    public final void unRegisterActivityOnKeyDownListener(B1S b1s) {
        M12.LIZ(b1s);
        this.LIZIZ.remove(b1s);
    }

    /* JADX WARNING: type inference failed for: r12v0, types: [com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsActivity, X.1hK, X.1oX, X.SNU, android.app.Activity] */
    public final void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsActivity", "onCreate", true);
        activityConfiguration(B1T.LIZ);
        TTSVoiceDetailsActivity.super.onCreate(bundle);
        setContentView(2131560534);
        View findViewById = findViewById(2131363673);
        n.LIZIZ(findViewById, "");
        findViewById.setFitsSystemWindows(false);
        this.LIZ = System.currentTimeMillis();
        String LIZ2 = LIZ(getIntent(), "anchor_id");
        Serializable serializableExtra = getIntent().getSerializableExtra("music_model");
        if (!(serializableExtra instanceof Music)) {
            serializableExtra = null;
        }
        0AA supportFragmentManager = getSupportFragmentManager();
        n.LIZIZ(supportFragmentManager, "");
        M12.LIZ(supportFragmentManager);
        Bundle bundle2 = new Bundle();
        bundle2.putString("anchor_id", LIZ2);
        bundle2.putSerializable("music_model", (Music) serializableExtra);
        TTSVoiceDetailsFragment tTSVoiceDetailsFragment = new TTSVoiceDetailsFragment();
        tTSVoiceDetailsFragment.setUserVisibleHint(true);
        tTSVoiceDetailsFragment.setArguments(bundle2);
        0AP LIZ3 = supportFragmentManager.LIZ();
        LIZ3.LIZIZ(2131363673, tTSVoiceDetailsFragment, "ttsvoice_detail_fragment_tag");
        LIZ3.LIZIZ();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsActivity", "onCreate", false);
    }

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

    public final boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (isDestroyed()) {
            return false;
        }
        Iterator<B1S> it = this.LIZIZ.iterator();
        while (it.hasNext()) {
            if (it.next().onKeyDown(i, keyEvent)) {
                return true;
            }
        }
        return TTSVoiceDetailsActivity.super.onKeyDown(i, keyEvent);
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        TTSVoiceDetailsActivity.super.onActivityResult(i, i2, intent);
        if (i2 == -1) {
            setResult(-1, intent);
            finish();
            overridePendingTransition(0, 0);
        }
    }
}
