| | |
| | | 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 |
| | |
| | | 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() { |
| | | |
| | |
| | | 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 |
| | |
| | | } 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 -> |
| | | |
| | | } |
| | | } |
| | | |