package com.ss.android.ugc.aweme.ecommerce.pdp;

import X.0AP;
import X.8gF;
import X.C5972CJs;
import X.C6489CbV;
import X.CG9;
import X.CJZ;
import X.CSU;
import X.CWJ;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.SparseArray;
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.ecommerce.pdp.IPdpStarter;
import com.ss.android.ugc.aweme.ecommerce.pdp.repository.dto.ProductPackStruct;
import com.ss.android.ugc.aweme.live.ILiveOuterService;
import com.ss.android.ugc.aweme.live.LiveOuterService;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import java.io.Serializable;
import kotlin.h.b.n;

public final class PdpActivity extends CWJ {
    public boolean LIZ;
    public long LIZIZ = -1;
    public String LIZJ;
    public SparseArray LIZLLL;

    static {
        Covode.recordClassIndex(71019);
    }

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

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

    public final String ck_() {
        return "product_detail";
    }

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

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

    public final void onWindowFocusChanged(boolean z) {
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity", "onWindowFocusChanged", true);
        PdpActivity.super.onWindowFocusChanged(z);
    }

    /* JADX WARNING: type inference failed for: r5v0, types: [X.SNU, android.app.Activity, com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity] */
    public final void onPause() {
        8gF.LIZJ(this);
        PdpActivity.super.onPause();
        ILiveOuterService LJJI = LiveOuterService.LJJI();
        n.LIZIZ(LJJI, "");
        LJJI.LJ().LIZIZ(SystemClock.elapsedRealtime() - this.LIZIZ);
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [X.SNU, android.app.Activity, com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity] */
    public final void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity", "onResume", true);
        PdpActivity.super.onResume();
        this.LIZIZ = SystemClock.elapsedRealtime();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity", "onResume", false);
    }

    /* JADX WARNING: type inference failed for: r2v0, types: [X.SNU, android.app.Activity, com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity] */
    public final void onStop() {
        8gF.LIZLLL(this);
        PdpActivity.super.onStop();
        if (!this.LIZ && !ActivityStack.isAppBackGround()) {
            CG9 LIZ2 = CG9.LJJIZ.LIZ(this);
            if (LIZ2 != null) {
                LIZ2.LIZ(CJZ.NEXT);
            }
            String str = this.LIZJ;
            if (str == null) {
                str = "";
            }
            C5972CJs cJs = new C5972CJs(str);
            cJs.LIZ(CJZ.NEXT);
            cJs.LIZIZ();
        }
        this.LIZ = false;
        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: r0v1, types: [android.content.Context] */
    /* JADX WARNING: type inference failed for: r0v9, types: [android.content.Context] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void onBackPressed() {
        /*
            r6 = this;
            X.0AA r0 = r6.getSupportFragmentManager()
            java.lang.String r2 = ""
            kotlin.h.b.n.LIZIZ(r0, r2)
            int r5 = r0.LJ()
            java.lang.String r3 = "return"
            r4 = 1
            if (r5 <= 0) goto L_0x0062
            X.0AA r1 = r6.getSupportFragmentManager()
            int r0 = r5 + -1
            X.0A7 r0 = r1.LIZJ(r0)
            kotlin.h.b.n.LIZIZ(r0, r2)
            java.lang.String r1 = r0.LJII()
            X.0AA r0 = r6.getSupportFragmentManager()
            androidx.fragment.app.Fragment r1 = r0.LIZ(r1)
            boolean r0 = r1 instanceof X.CVK
            if (r0 == 0) goto L_0x0037
            X.CVK r1 = (X.CVK) r1
            boolean r0 = r1.LIZJ()
            if (r0 != 0) goto L_0x0089
        L_0x0037:
            if (r5 != r4) goto L_0x005e
            r6.LIZ = r4
            X.2RV r1 = X.CG9.LJJIZ
            r0 = r6
            X.CG9 r0 = r1.LIZ(r0)
            if (r0 == 0) goto L_0x0047
            r0.LIZ((java.lang.String) r3)
        L_0x0047:
            X.CJs r1 = new X.CJs
            java.lang.String r0 = r6.LIZJ
            if (r0 != 0) goto L_0x005c
        L_0x004d:
            r1.<init>(r2)
            X.CJZ r0 = X.CJZ.RETURN
            r1.LIZ(r0)
            r1.LIZIZ()
            r6.finish()
            return
        L_0x005c:
            r2 = r0
            goto L_0x004d
        L_0x005e:
            com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity.super.onBackPressed()
            return
        L_0x0062:
            r6.LIZ = r4
            X.2RV r1 = X.CG9.LJJIZ
            r0 = r6
            X.CG9 r1 = r1.LIZ(r0)
            if (r1 == 0) goto L_0x0075
            r1.LIZ((java.lang.String) r3)
            X.CJZ r0 = X.CJZ.RETURN
            r1.LIZ((X.CJZ) r0)
        L_0x0075:
            X.CJs r1 = new X.CJs
            java.lang.String r0 = r6.LIZJ
            if (r0 != 0) goto L_0x008a
        L_0x007b:
            r1.<init>(r2)
            X.CJZ r0 = X.CJZ.RETURN
            r1.LIZ(r0)
            r1.LIZIZ()
            com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity.super.onBackPressed()
        L_0x0089:
            return
        L_0x008a:
            r2 = r0
            goto L_0x007b
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity.onBackPressed():void");
    }

    /* JADX WARNING: type inference failed for: r14v0, types: [X.1hK, X.SNU, android.app.Activity, com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity, X.CWJ] */
    public final void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity", "onCreate", true);
        activityConfiguration(CSU.LIZ);
        super.onCreate(bundle);
        setContentView(2131559111);
        Serializable serializableExtra = getIntent().getSerializableExtra("ENTER_PARAMS");
        if (!(serializableExtra instanceof IPdpStarter.PdpEnterParam)) {
            serializableExtra = null;
        }
        IPdpStarter.PdpEnterParam pdpEnterParam = (IPdpStarter.PdpEnterParam) serializableExtra;
        if (pdpEnterParam == null) {
            finish();
            ActivityAgent.onTrace("com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity", "onCreate", false);
            return;
        }
        this.LIZJ = pdpEnterParam.getProductId();
        ProductPackStruct productPackStruct = (ProductPackStruct) getIntent().getParcelableExtra("PREFETCH_RESULT");
        int intExtra = getIntent().getIntExtra("ERROR_CODE", 0);
        CG9 cg9 = new CG9(this, pdpEnterParam);
        cg9.LJIJI = getIntent().getLongExtra("CLICK_TIMESTAMP", SystemClock.elapsedRealtime());
        cg9.LJIJ = getIntent().getLongExtra("CLICK_TIMESTAMP", SystemClock.elapsedRealtime());
        PdpFullFragment pdpFullFragment = new PdpFullFragment();
        Bundle bundle2 = new Bundle();
        bundle2.putSerializable("ENTER_PARAMS", pdpEnterParam);
        bundle2.putBoolean("full_screen", pdpEnterParam.getFullScreen());
        if (productPackStruct != null) {
            if (intExtra != 0) {
                bundle2.putInt("ERROR_CODE", intExtra);
            }
            bundle2.putParcelable("PREFETCH_RESULT", productPackStruct);
            bundle2.putLong("PREFETCH_FINISH_TIME", getIntent().getLongExtra("PREFETCH_FINISH_TIME", 0));
        }
        pdpFullFragment.setArguments(bundle2);
        0AP LIZ2 = getSupportFragmentManager().LIZ();
        LIZ2.LIZ(2131365158, pdpFullFragment, "pdp_fragment");
        LIZ2.LIZ("pdp_fragment");
        LIZ2.LIZJ();
        C6489CbV.LIZ(this).LIZIZ();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.ecommerce.pdp.PdpActivity", "onCreate", false);
    }
}
