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

import X.2Rh;
import X.2UX;
import X.2nK;
import X.3BB;
import X.4TL;
import X.4ZZ;
import X.7lW;
import X.8gF;
import X.C3574JbR;
import X.C3575JbS;
import X.C3576JbT;
import X.C3578JbV;
import X.C3579JbW;
import X.C3582JbZ;
import X.C3600Jbr;
import X.C3602Jbt;
import X.C3603Jbu;
import X.C3613Jc4;
import X.JJZ;
import X.SNU;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.SeekBar;
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.livewallpaper.model.LiveWallPaperBean;

public class LiveWallPaperPreviewActivity extends SNU implements SurfaceHolder.Callback {
    public SurfaceView LIZ;
    public 4ZZ LIZIZ;
    public 4ZZ LIZJ;
    public LiveWallPaperBean LIZLLL;
    public C3582JbZ LJ;
    public float LJFF;
    public String LJI;
    public boolean LJII;

    static {
        Covode.recordClassIndex(91493);
    }

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

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

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

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

    /* JADX WARNING: type inference failed for: r2v0, types: [com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity, X.SNU, android.app.Activity] */
    public void onDestroy() {
        8gF.LJ(this);
        LiveWallPaperPreviewActivity.super.onDestroy();
        C3574JbR.LJ.LIZ("paper_set");
    }

    public void LIZ() {
        float f;
        LiveWallPaperBean liveWallPaperBean = this.LIZLLL;
        if (liveWallPaperBean != null) {
            if (liveWallPaperBean.isShouldMute()) {
                f = 0.0f;
            } else {
                f = this.LJFF;
            }
            liveWallPaperBean.setVolume(f);
        }
    }

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

    public void exit(View view) {
        finish();
    }

    public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
        C3582JbZ jbZ = this.LJ;
        if (jbZ != null) {
            jbZ.LIZ();
        }
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [android.content.Context, com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity] */
    public void showSettingDialog(View view) {
        boolean z;
        LiveWallPaperBean liveWallPaperBean = this.LIZLLL;
        if (liveWallPaperBean == null || !liveWallPaperBean.isShouldMute()) {
            z = false;
        } else {
            z = true;
        }
        new JJZ().LIZ(this, z, "Preview", new SeekBar.OnSeekBarChangeListener() {
            static {
                Covode.recordClassIndex(91497);
            }

            public final void onStartTrackingTouch(SeekBar seekBar) {
            }

            public final void onStopTrackingTouch(SeekBar seekBar) {
            }

            public final void onProgressChanged(SeekBar seekBar, int i, boolean z) {
                if (z) {
                    LiveWallPaperPreviewActivity.this.LJFF = C3575JbS.LIZ(i);
                    if (LiveWallPaperPreviewActivity.this.LJ != null) {
                        LiveWallPaperPreviewActivity.this.LJ.LIZ(LiveWallPaperPreviewActivity.this.LJFF);
                    }
                }
            }
        });
    }

    public void surfaceCreated(SurfaceHolder surfaceHolder) {
        C3582JbZ jbZ;
        LiveWallPaperBean liveWallPaperBean = this.LIZLLL;
        if (liveWallPaperBean != null && (jbZ = this.LJ) != null) {
            jbZ.LIZ(surfaceHolder, liveWallPaperBean.getVideoPath(), this.LIZLLL.getWidth(), this.LIZLLL.getHeight());
        }
    }

    /* JADX WARNING: type inference failed for: r7v0, types: [android.content.Context, com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity, android.view.SurfaceHolder$Callback, X.1oX, X.SNU, android.app.Activity] */
    public void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity", "onCreate", true);
        4TL r1 = new 4TL((byte) 0);
        r1.LIZ = false;
        r1.LJIIIIZZ = false;
        r1.LJII = 2131100577;
        activityConfiguration(new C3600Jbr(r1));
        LiveWallPaperPreviewActivity.super.onCreate(bundle);
        this.LIZLLL = (LiveWallPaperBean) getIntent().getParcelableExtra("live_wall_paper");
        this.LJII = getIntent().getBooleanExtra("hide_more_button", false);
        this.LJI = LIZ(getIntent(), "from");
        if (this.LIZLLL == null) {
            finish();
            ActivityAgent.onTrace("com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity", "onCreate", false);
            return;
        }
        setContentView(2131562338);
        this.LIZ = (SurfaceView) findViewById(2131370153);
        this.LIZIZ = findViewById(2131366542);
        this.LIZJ = findViewById(2131368769);
        View findViewById = findViewById(2131362572);
        if (findViewById != null) {
            findViewById.setOnClickListener(new C3602Jbt(this));
        }
        View findViewById2 = findViewById(2131372312);
        if (findViewById2 != null) {
            findViewById2.setOnClickListener(new C3576JbT(this));
        }
        View findViewById3 = findViewById(2131366542);
        if (findViewById3 != null) {
            findViewById3.setOnClickListener(new C3579JbW(this));
        }
        View findViewById4 = findViewById(2131368769);
        if (findViewById4 != null) {
            findViewById4.setOnClickListener(new C3603Jbu(this));
        }
        2Rh.LIZIZ(findViewById(2131370610));
        this.LIZ.getHolder().addCallback(this);
        C3582JbZ LIZ2 = C3575JbS.LIZ((Context) this, (C3613Jc4) null);
        this.LJ = LIZ2;
        LIZ2.LIZ(this.LIZLLL);
        if (this.LJII) {
            this.LIZIZ.setVisibility(8);
        }
        this.LJFF = C3575JbS.LIZ(C3578JbV.LIZ.LJI());
        LIZ();
        String str = this.LJI;
        2UX r12 = new 2UX();
        r12.LIZ("enter_from", str);
        2nK.LIZ("enter_wallpaper_preview", r12.LIZ);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity", "onCreate", false);
    }

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

    /* JADX WARNING: type inference failed for: r3v0, types: [android.content.Context, com.ss.android.ugc.aweme.livewallpaper.ui.LiveWallPaperPreviewActivity, X.SNU] */
    public void onActivityResult(int i, int i2, Intent intent) {
        LiveWallPaperPreviewActivity.super.onActivityResult(i, i2, intent);
        if (i == 100 && C3575JbS.LIZ((Context) this, getPackageName())) {
            Context applicationContext = getApplicationContext();
            if (7lW.LIZJ && applicationContext == null) {
                applicationContext = 7lW.LIZ;
            }
            3BB r2 = new 3BB(applicationContext);
            r2.LIZIZ(2131834934);
            r2.LIZIZ();
            C3575JbS.LIZ(this.LIZLLL.getId(), this.LJI);
            C3575JbS.LIZ(0, "");
            finish();
        }
    }

    public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
        C3582JbZ jbZ = this.LJ;
        if (jbZ != null) {
            jbZ.LIZ(surfaceHolder, i2, i3);
        }
    }
}
