package com.tencent.mm.plugin.appbrand.ui.autofill;

import android.content.Intent;
import android.os.Bundle;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.protocal.protobuf.bzo;
import com.tencent.mm.protocal.protobuf.gd;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.MMFragment;
import com.tencent.mm.ui.base.a;
import com.tencent.mm.ui.base.h;
import com.tencent.mm.ui.base.p;
import com.tencent.ytcommon.BuildConfig;
import java.util.LinkedList;
import org.json.JSONArray;
import org.json.JSONException;

@a(3)
public class AppBrandIDCardUI extends MMActivity {
    public static final int iKc = 2131820557;
    private String appId;
    private int flQ;
    private a iJN = new 1(this);
    public MMFragment iKd;
    private bzo iKe;
    private gd iKf;
    private LinkedList<Integer> iKg;
    private String iKh;
    private String iKi;
    private p ifC;

    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        AppMethodBeat.at(this, z);
    }

    public AppBrandIDCardUI() {
        AppMethodBeat.i(133238);
        AppMethodBeat.o(133238);
    }

    static /* synthetic */ void e(AppBrandIDCardUI appBrandIDCardUI) {
        AppMethodBeat.i(133246);
        appBrandIDCardUI.aMD();
        AppMethodBeat.o(133246);
    }

    static /* synthetic */ void f(AppBrandIDCardUI appBrandIDCardUI) {
        AppMethodBeat.i(133247);
        appBrandIDCardUI.back();
        AppMethodBeat.o(133247);
    }

    public final void onCreateBeforeSetContentView() {
        AppMethodBeat.i(133239);
        super.onCreateBeforeSetContentView();
        getWindow().requestFeature(10);
        getWindow().getDecorView().setFitsSystemWindows(true);
        supportRequestWindowFeature(10);
        supportRequestWindowFeature(1);
        AppMethodBeat.o(133239);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(133240);
        super.onCreate(bundle);
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            ab.e("MicroMsg.AppBrandIDCardUI", "bundle is null, return");
            finish();
            AppMethodBeat.o(133240);
            return;
        }
        this.appId = extras.getString("intent_appid", BuildConfig.FLAVOR);
        if (bo.isNullOrNil(this.appId)) {
            ab.e("MicroMsg.AppBrandIDCardUI", "appId is null, return");
            finish();
            AppMethodBeat.o(133240);
            return;
        }
        this.iKg = D(extras);
        if (bo.ek(this.iKg) || this.iKg.size() <= 0) {
            ab.e("MicroMsg.AppBrandIDCardUI", "categoryId is null, return");
            Intent intent = new Intent();
            intent.putExtra("intent_err_code", 40003);
            intent.putExtra("intent_err_msg", "category_id is null");
            setResult(1, intent);
            finish();
            AppMethodBeat.o(133240);
            return;
        }
        this.flQ = extras.getInt("intent_auth_type", 1);
        this.mController.contentView.setBackgroundColor(getResources().getColor(2131690310));
        LayoutParams layoutParams = new LayoutParams(-1, -1);
        FrameLayout frameLayout = new FrameLayout(this);
        frameLayout.setId(iKc);
        ((ViewGroup) this.mController.contentView).addView(frameLayout, layoutParams);
        setBackBtn(new 2(this));
        getString(2131297061);
        this.ifC = h.b(this, getString(2131300968), true, new 3(this));
        this.ifC.show();
        this.iJN.aME();
        if (isSupportNavigationSwipeBack()) {
            getSwipeBackLayout().setEnableGesture(false);
        }
        AppMethodBeat.o(133240);
    }

    public void onBackPressed() {
        AppMethodBeat.i(133241);
        back();
        AppMethodBeat.o(133241);
    }

    private void back() {
        AppMethodBeat.i(133242);
        if (this.iKd instanceof AppBrandIDCardVerifyPwdFrag) {
            aMD();
            AppMethodBeat.o(133242);
            return;
        }
        finish();
        AppMethodBeat.o(133242);
    }

    public void onSwipeBack() {
        AppMethodBeat.i(133243);
        back();
        AppMethodBeat.o(133243);
    }

    private static LinkedList<Integer> D(Bundle bundle) {
        AppMethodBeat.i(133244);
        LinkedList linkedList = new LinkedList();
        try {
            ab.i("MicroMsg.AppBrandIDCardUI", "[processCategoryId] categoryIdStr:%s", new Object[]{bundle.getString("intent_category_id")});
            JSONArray jSONArray = new JSONArray(r1);
            for (int i = 0; i < jSONArray.length(); i++) {
                linkedList.add(Integer.valueOf(jSONArray.optInt(i)));
            }
            AppMethodBeat.o(133244);
            return linkedList;
        } catch (JSONException e) {
            ab.printErrStackTrace("MicroMsg.AppBrandIDCardUI", e, BuildConfig.FLAVOR, new Object[0]);
            AppMethodBeat.o(133244);
            return null;
        }
    }

    public final boolean noActionBar() {
        return true;
    }

    private void aMD() {
        AppMethodBeat.i(133245);
        ab.i("MicroMsg.AppBrandIDCardUI", "switchToShowFragment");
        this.iKd = new AppBrandIDCardShowFrag();
        ((AppBrandIDCardShowFrag) this.iKd).iJN = this.iJN;
        getSupportFragmentManager().beginTransaction().b(iKc, this.iKd).commitAllowingStateLoss();
        AppMethodBeat.o(133245);
    }

    public final int getLayoutId() {
        return -1;
    }

    static /* synthetic */ void h(AppBrandIDCardUI appBrandIDCardUI) {
        AppMethodBeat.i(133248);
        ab.i("MicroMsg.AppBrandIDCardUI", "switchToVerifyFragment");
        appBrandIDCardUI.iKd = new AppBrandIDCardVerifyPwdFrag();
        ((AppBrandIDCardVerifyPwdFrag) appBrandIDCardUI.iKd).iJN = appBrandIDCardUI.iJN;
        appBrandIDCardUI.getSupportFragmentManager().beginTransaction().b(iKc, appBrandIDCardUI.iKd).commitAllowingStateLoss();
        AppMethodBeat.o(133248);
    }
}
