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

import X.0AA;
import X.0AP;
import X.0HH;
import X.0Q5;
import X.0Q6;
import X.2or;
import X.4Bm;
import X.4jG;
import X.4kE;
import X.6mb;
import X.7he;
import X.8gF;
import X.B1S;
import X.B9U;
import X.C2358Ar4;
import X.C2949B1l;
import X.C2950B1m;
import X.Crj;
import X.EIE;
import X.M12;
import X.SNU;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
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.router.arg.RouteArgExtension;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.ss.android.ugc.aweme.analysis.Analysis;
import com.ss.android.ugc.aweme.challenge.model.ChallengeDetailParam;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import kotlin.h.b.n;
import org.json.JSONException;
import org.json.JSONObject;

public final class ChallengeDetailActivity extends SNU implements 0Q6, B9U, 4Bm, EIE {
    public static final C2950B1m LIZJ = new C2950B1m((byte) 0);
    public final Crj LIZ = RouteArgExtension.INSTANCE.navArg(this);
    public String LIZIZ = "";
    public final Crj LIZLLL = 7he.LIZ(new C2949B1l(this));
    public final ArrayList<B1S> LJ = new ArrayList<>();
    public SparseArray LJFF;

    static {
        Covode.recordClassIndex(55764);
    }

    private final ChallengeDetailParam LIZ() {
        return (ChallengeDetailParam) this.LIZLLL.getValue();
    }

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

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

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

    public final String getBtmPageCode() {
        return "b3953";
    }

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

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

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

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

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

    public final String aB_() {
        return 0Q5.LIZ(this);
    }

    public final Map<String, String> aE_() {
        M12.LIZ(this);
        return null;
    }

    /* 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.challenge.ui.ChallengeDetailActivity.super.finish()
            r0 = r1
            X.FNd.LIZ(r0)
            X.C3654BSo.LIZ(r0)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.challenge.ui.ChallengeDetailActivity.finish():void");
    }

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

    public final Analysis cU_() {
        long j;
        long j2 = 0;
        try {
            String cid = LIZ().getCid();
            if (cid == null) {
                n.LIZIZ();
            }
            j = Long.parseLong(cid);
        } catch (Exception e) {
            0HH.LIZ(e);
            j = 0;
        }
        try {
            String awemeId = LIZ().getAwemeId();
            if (awemeId == null) {
                n.LIZIZ();
            }
            j2 = Long.parseLong(awemeId);
        } catch (Exception e2) {
            0HH.LIZ(e2);
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("process_id", LIZ().getProcessId());
            jSONObject.put("challenge_id", this.LIZIZ);
            jSONObject.put("page_model", "detail");
        } catch (JSONException unused) {
        }
        Analysis analysis = new Analysis();
        analysis.setLabelName("challenge");
        analysis.setExt_value(j);
        analysis.setValue(j2);
        analysis.setExt_json(jSONObject);
        n.LIZIZ(analysis, "");
        return analysis;
    }

    public final void unRegisterActivityOnKeyDownListener(B1S b1s) {
        M12.LIZ(b1s);
        ArrayList<B1S> arrayList = this.LJ;
        if (arrayList != null) {
            arrayList.remove(b1s);
        }
    }

    public final void registerActivityOnKeyDownListener(B1S b1s) {
        M12.LIZ(b1s);
        if (!this.LJ.contains(b1s)) {
            this.LJ.add(b1s);
        }
    }

    /* JADX WARNING: type inference failed for: r10v0, types: [X.1hK, com.ss.android.ugc.aweme.challenge.ui.ChallengeDetailActivity, X.1oX, X.SNU, android.app.Activity] */
    public final void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.challenge.ui.ChallengeDetailActivity", "onCreate", true);
        2or.LIZ("challenge_detail");
        activityConfiguration(4kE.LIZ);
        if (4jG.LIZ()) {
            getWindow().setDecorFitsSystemWindows(false);
        }
        ChallengeDetailActivity.super.onCreate(bundle);
        setContentView(2131560534);
        View findViewById = findViewById(2131363673);
        n.LIZIZ(findViewById, "");
        findViewById.setFitsSystemWindows(false);
        if (TextUtils.isEmpty(LIZ().getCid())) {
            finish();
        } else {
            LIZ().setShootEnterFrom(LIZ(getIntent(), "shoot_enter_from"));
            LIZ().setBundled(Integer.valueOf(getIntent().getIntExtra("is_bundled", 0)));
            if (n.LIZ(LIZ().getEnterFrom(), "collection_tag")) {
                6mb.LIZ = true;
            }
            0AA supportFragmentManager = getSupportFragmentManager();
            n.LIZIZ(supportFragmentManager, "");
            ChallengeDetailParam LIZ2 = LIZ();
            M12.LIZ(supportFragmentManager, LIZ2);
            0AP LIZ3 = supportFragmentManager.LIZ();
            n.LIZIZ(LIZ3, "");
            ChallengeDetailFragment LIZ4 = supportFragmentManager.LIZ("challenge_detail_fragment_tag");
            if (LIZ4 == null) {
                LIZ4 = ChallengeDetailFragment.LJIL.LIZ(LIZ2);
            }
            LIZ4.setUserVisibleHint(true);
            LIZ3.LIZIZ(2131363673, LIZ4, "challenge_detail_fragment_tag");
            LIZ3.LIZIZ();
            if (LIZ4 instanceof ChallengeDetailFragment) {
                LIZ4.LJIJ = new C2358Ar4(this);
            }
        }
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.challenge.ui.ChallengeDetailActivity", "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.LJ.iterator();
        while (it.hasNext()) {
            if (it.next().onKeyDown(i, keyEvent)) {
                return true;
            }
        }
        return ChallengeDetailActivity.super.onKeyDown(i, keyEvent);
    }

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