左晓为主开发手持机充值管理机
zuoxiao
3 天以前 4ceacd9e21e09989287e8dc4e526d182091af282
generallibrary/src/main/java/com/dayu/general/activity/ManagerReadActivity.kt
@@ -5,6 +5,7 @@
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import com.dayu.baselibrary.net.subscribers.SubscriberListener
import com.dayu.baselibrary.utils.BaseCommon
@@ -18,6 +19,7 @@
import com.dayu.general.tool.BaseCommon.Companion.protocol
import com.dayu.general.tool.CardCommon
import com.dayu.general.tool.NfcReadHelper
import com.dayu.general.tool.NfcWreatHelper
class ManagerReadActivity : BaseNfcActivity() {
@@ -196,8 +198,19 @@
    fun getRemark(): String = viewModel.remark.get() ?: ""
    override fun onNfcBack(intent: Intent) {
        // 处理NFC读取结果
        NfcReadHelper.getInstance(intent, this).getCardNumber().let { cardNumber ->
        val cardNumber = NfcReadHelper.getInstance(intent, this).getCardNumberNoClose()
        if (cardNumber.isNotEmpty()) {
            val keyList = ArrayList(NfcReadHelper.getInstance(intent, this).getKeyList())
            val nfcHelper = NfcWreatHelper.getInstance(intent, this)
            nfcHelper.setLoadingView(binding.loadingContainer, binding.nfcProgressWheel)
            // 异步修改密码
            nfcHelper.changePSAsync(
                keyList,
                true,  // 修改为true,确保建立NFC连接
                true
            ) { success: Boolean, msg: String? ->
                if (success) {
                    // 隐藏NFC读卡界面
            if (cardNumber.isNotEmpty() && !cardNumber.contains(BaseCommon.CARD_TYPE_ERROR2)) {
                binding.btnNext.visibility = View.VISIBLE
                binding.dataLayout.visibility = View.VISIBLE
@@ -206,6 +219,21 @@
            } else if (cardNumber.contains(BaseCommon.CARD_TYPE_ERROR2)) {
                ToastUtil.show("当前卡密码错误,不是本公司卡")
            }
                } else {
                    // 密码修改失败,处理错误情况
                    Toast.makeText(
                        this@ManagerReadActivity,
                        "卡片初始化失败:$msg",
                        Toast.LENGTH_LONG
                    ).show()
                }
            }
        }
        // 创建密钥列表的副本,避免ConcurrentModificationException
        // 处理NFC读取结果
        NfcReadHelper.getInstance(intent, this).getCardNumber().let { cardNumber ->
        }
    }