<commit_before>package community.revteltech.nfc;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.TagLostException;
import android.nfc.tech.TagTechnology;
import android.nfc.tech.Ndef;
import android.nfc.tech.NfcA;
import android.nfc.tech.MifareClassic;
import android.nfc.tech.IsoDep;
import android.util.Log;
import com.facebook.react.bridge.*;

class TagTechnologyRequest {
    static String LOG_TAG = "NfcManager-tech";
    Tag mTag;
    TagTechnology mTech;
    String mTechType;
    Callback mJsCallback;

    TagTechnologyRequest(String techType, Callback cb) {
        mTechType = techType;
        mJsCallback = cb;
    }

    String getTechType() {
        return mTechType;
    }

    Callback getPendingCallback() {
        return mJsCallback;
    }

    TagTechnology getTechHandle() {
        return mTech;
    }

    boolean isConnected() {
        return mTag != null;
    }

    boolean connect(Tag tag) {
        mTech = null;
        mTag = tag;
        if (mTechType.equals("Ndef")) {
            mTech = Ndef.get(tag);
        } else if (mTechType.equals("NfcA")) {
            mTech = NfcA.get(tag);
        } else if (mTechType.equals("IsoDep")) {
            mTech = IsoDep.get(tag);
        } else if (mTechType.equals("MifareClassic")) {
            mTech = MifareClassic.get(tag);
        }

        if (mTech == null) {
            return false;
        }

        try {
            Log.d(LOG_TAG, "connect to " + mTechType);
            mTech.connect();
            return true;
        } catch (Exception ex) {
            Log.d(LOG_TAG, "fail to connect tech");
            return false;
        }<commit_msg>Fix a bugfix that sometimes occurs when the tag is a null object<commit_after>package community.revteltech.nfc;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.TagLostException;
import android.nfc.tech.TagTechnology;
import android.nfc.tech.Ndef;
import android.nfc.tech.NfcA;
import android.nfc.tech.MifareClassic;
import android.nfc.tech.IsoDep;
import android.util.Log;
import com.facebook.react.bridge.*;

class TagTechnologyRequest {
    static String LOG_TAG = "NfcManager-tech";
    Tag mTag;
    TagTechnology mTech;
    String mTechType;
    Callback mJsCallback;

    TagTechnologyRequest(String techType, Callback cb) {
        mTechType = techType;
        mJsCallback = cb;
    }

    String getTechType() {
        return mTechType;
    }

    Callback getPendingCallback() {
        return mJsCallback;
    }

    TagTechnology getTechHandle() {
        return mTech;
    }

    boolean isConnected() {
        return mTag != null;
    }

    boolean connect(Tag tag) {
        if (tag == null) {
            Log.d(LOG_TAG, "received null tag at connect()");
            return false;
        }

        mTech = null;
        mTag = tag;
        if (mTechType.equals("Ndef")) {
            mTech = Ndef.get(tag);
        } else if (mTechType.equals("NfcA")) {
            mTech = NfcA.get(tag);
        } else if (mTechType.equals("IsoDep")) {
            mTech = IsoDep.get(tag);
        } else if (mTechType.equals("MifareClassic")) {
            mTech = MifareClassic.get(tag);
        }

        if (mTech == null) {
            return false;
        }

        try {
            Log.d(LOG_TAG, "connect to " + mTechType);
            mTech.connect();
            return true;
        } catch (Exception ex) {
            Log.d(LOG_TAG, "fail to connect tech");
            return false;
        }
{'fraction_non_alphanumeric': 0.10815354441019893, 'fraction_numerical': 0.0, 'mean_word_length': 2.162090345438441, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1374799', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1123, 'n_words': 247}