package com.tencent.mm.plugin.appbrand.jsapi;

import android.content.Intent;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.bp.d;
import com.tencent.mm.plugin.appbrand.s;
import com.tencent.mm.ui.MMActivity;
import java.util.HashSet;
import org.json.JSONArray;
import org.json.JSONObject;

public final class JsApiScanCode extends a<s> {
    public static final int CTRL_INDEX = 148;
    public static final String NAME = "scanCode";
    private static volatile boolean hyh = false;

    public final /* synthetic */ void a(c cVar, JSONObject jSONObject, int i) {
        AppMethodBeat.i(130566);
        s sVar = (s) cVar;
        if (hyh) {
            sVar.M(i, j("cancel", null));
            AppMethodBeat.o(130566);
            return;
        }
        hyh = true;
        MMActivity mMActivity = (MMActivity) sVar.ad(MMActivity.class);
        if (mMActivity == null) {
            sVar.M(i, j("fail", null));
            AppMethodBeat.o(130566);
            return;
        }
        mMActivity.ifE = new 1(this, sVar, i);
        Intent intent = new Intent();
        intent.putExtra("BaseScanUI_select_scan_mode", 1);
        intent.putExtra("BaseScanUI_only_scan_qrcode_with_zbar", true);
        intent.putExtra("key_is_finish_on_scanned", true);
        intent.putExtra("key_is_hide_right_btn", jSONObject.optBoolean("onlyFromCamera", false));
        JSONArray optJSONArray = jSONObject.optJSONArray("scanType");
        HashSet<Integer> hashSet = new HashSet();
        if (optJSONArray != null && optJSONArray.length() > 0) {
            hashSet.add(Integer.valueOf(2));
            hashSet.add(Integer.valueOf(4));
            hashSet.add(Integer.valueOf(5));
            hashSet.add(Integer.valueOf(3));
            hashSet.add(Integer.valueOf(1));
            int[] iArr = new int[hashSet.size()];
            int i2 = 0;
            for (Integer intValue : hashSet) {
                int i3 = i2 + 1;
                iArr[i2] = intValue.intValue();
                i2 = i3;
            }
            intent.putExtra("key_support_scan_code_type", iArr);
        }
        d.a(mMActivity, "scanner", ".ui.SingleTopScanUI", intent, hashCode() & 65535, false);
        AppMethodBeat.o(130566);
    }
}
