package com.ss.android.ugc.aweme.share.gif.ui;

import X.0Gf;
import X.0Gp;
import X.1oX;
import X.2ma;
import X.2nK;
import X.3i8;
import X.805;
import X.8gF;
import X.C3341JUm;
import X.C3342JUn;
import X.C3343JUo;
import X.C3344JUp;
import X.C3443JYk;
import X.C3526Jaf;
import X.JT1;
import X.M12;
import X.SNU;
import X.Swm;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
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.out.AVExternalServiceImpl;
import com.ss.android.ugc.aweme.services.AsyncAVService;
import com.ss.android.ugc.aweme.services.SimpleServiceLoadCallback;
import com.ss.android.ugc.aweme.share.gif.VideoShare2GifEditContext;
import java.io.File;
import java.util.HashMap;
import kotlin.h.b.n;

public class VideoShare2GifEditActivity extends SNU {
    public boolean LIZ = true;
    public VideoShare2GifEditContext LIZIZ;

    static {
        Covode.recordClassIndex(107091);
    }

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

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

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

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

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

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

    public void resolveUiClickEvent(View view) {
        if (view.getId() == 2131362569) {
            2nK.LIZ("gif_quit_editing", new HashMap());
            finish();
        }
    }

    /* JADX WARNING: type inference failed for: r0v8, types: [android.view.View$OnClickListener, com.ss.android.ugc.aweme.share.gif.ui.VideoShare2GifEditActivity$2] */
    public void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.share.gif.ui.VideoShare2GifEditActivity", "onCreate", true);
        activityConfiguration(C3344JUp.LIZ);
        VideoShare2GifEditActivity.super.onCreate(bundle);
        setContentView(2131558534);
        View findViewById = findViewById(2131362569);
        if (findViewById != null) {
            findViewById.setOnClickListener(new C3343JUo(this));
        }
        VideoShare2GifEditContext videoShare2GifEditContext = (VideoShare2GifEditContext) getIntent().getParcelableExtra("extra_data");
        this.LIZIZ = videoShare2GifEditContext;
        if (videoShare2GifEditContext == null || !805.LIZIZ(videoShare2GifEditContext.LIZ)) {
            finish();
        }
        findViewById(2131367997).setOnClickListener(new Swm() {
            static {
                Covode.recordClassIndex(107093);
            }

            public final void LIZ(View view) {
                1oX r5 = VideoShare2GifEditActivity.this;
                if (r5.LIZ && r5.LIZIZ != null && !TextUtils.isEmpty(r5.LIZIZ.LIZ)) {
                    r5.LIZ = false;
                    r5.LIZIZ.LJFF = JT1.LIZIZ.LIZ();
                    VideoShare2GifEditContext videoShare2GifEditContext = r5.LIZIZ;
                    JT1 jt1 = JT1.LIZIZ;
                    String str = r5.LIZIZ.LIZIZ;
                    M12.LIZ(str);
                    String LIZ2 = jt1.LIZ();
                    String path = new File(LIZ2, str + ".gif").getPath();
                    n.LIZIZ(path, "");
                    videoShare2GifEditContext.LJ = path;
                    C3526Jaf LIZ3 = C3526Jaf.LIZ(r5, r5.getResources().getString(2131825402));
                    LIZ3.setIndeterminate(false);
                    AVExternalServiceImpl.LIZ().abilityService().transformService().video2gif(r5.LIZIZ, new C3342JUn(LIZ3), new C3341JUm(r5, LIZ3));
                }
            }
        });
        if (getSupportFragmentManager().LIZ(2131364961) == null) {
            AVExternalServiceImpl.LIZ().asyncService(this, "Share2Gif", new SimpleServiceLoadCallback() {
                static {
                    Covode.recordClassIndex(107092);
                }

                public final void onFailed() {
                    VideoShare2GifEditActivity.this.finish();
                }

                public final void onLoad(AsyncAVService asyncAVService, long j) {
                    0Gp.LIZ(new C3443JYk(this, asyncAVService), 2ma.LIZ, (0Gf) null);
                }
            });
        }
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.share.gif.ui.VideoShare2GifEditActivity", "onCreate", false);
    }

    public static void LIZ(Context context, Intent intent) {
        3i8.LIZ(intent, context);
        context.startActivity(intent);
    }

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

    public static void LIZ(Context context, String str, String str2, boolean z, String str3, String str4, String str5) {
        Intent intent = new Intent(context, VideoShare2GifEditActivity.class);
        VideoShare2GifEditContext videoShare2GifEditContext = new VideoShare2GifEditContext();
        videoShare2GifEditContext.LIZIZ = str;
        videoShare2GifEditContext.LJIIZILJ = str5;
        videoShare2GifEditContext.LJIILLIIL = str4;
        videoShare2GifEditContext.LJIILL = str2;
        videoShare2GifEditContext.LIZ = str3;
        videoShare2GifEditContext.LIZJ = z;
        intent.putExtra("extra_data", videoShare2GifEditContext);
        LIZ(context, intent);
    }
}
