From 14b15539a8fbbce1145197993e0c062400174ef1 Mon Sep 17 00:00:00 2001
From: zuoxiao <lf_zuo@163.com>
Date: 星期四, 26 六月 2025 16:51:12 +0800
Subject: [PATCH] docs(baselibrary): 更新 NativeNfcReadHelper 类文档
---
generallibrary/src/main/java/com/dayu/general/activity/CardReplaceActivity.kt | 109 +++---------------------------------------------------
1 files changed, 6 insertions(+), 103 deletions(-)
diff --git a/generallibrary/src/main/java/com/dayu/general/activity/CardReplaceActivity.kt b/generallibrary/src/main/java/com/dayu/general/activity/CardReplaceActivity.kt
index e20cec0..59dfd9b 100644
--- a/generallibrary/src/main/java/com/dayu/general/activity/CardReplaceActivity.kt
+++ b/generallibrary/src/main/java/com/dayu/general/activity/CardReplaceActivity.kt
@@ -3,23 +3,17 @@
import android.content.Context
import android.content.Intent
import android.os.Bundle
-import android.util.TypedValue
-import android.view.View
-import android.widget.RadioButton
-import android.widget.Toast
import com.dayu.baselibrary.net.subscribers.SubscriberListener
import com.dayu.baselibrary.utils.MornyUtil
import com.dayu.baselibrary.utils.ToastUtil
import com.dayu.baselibrary.view.TipDialog
import com.dayu.baselibrary.view.TitleBar
import com.dayu.general.BaseApplication
-import com.dayu.general.R
import com.dayu.general.bean.card.UserCard
-import com.dayu.general.bean.net.CardInfoResult
import com.dayu.general.bean.net.CardInfoByClientResult
+import com.dayu.general.bean.net.CardInfoResult
import com.dayu.general.bean.net.CardReplaceResult
import com.dayu.general.bean.net.PaymentMethod
-import com.dayu.general.bean.net.PaymentMethodResponse
import com.dayu.general.databinding.ActivityCardReplaceBinding
import com.dayu.general.net.ApiManager
import com.dayu.general.net.BaseResponse
@@ -43,7 +37,7 @@
// 鏀粯鏂瑰紡鐩稿叧灞炴��
private var paymentMethod: String = "鐜伴噾"
- private var paymentId: Long = 0
+ private var paymentId: String = ""
private var paymentMethodList: List<PaymentMethod> = listOf()
companion object {
@@ -66,8 +60,6 @@
cardNum = intent.getStringExtra("cardNum")
initView()
- // 鑾峰彇鏀粯鏂瑰紡
- getPaymentMethods()
// 鏃犺鏄惁鏈塩lientNum锛岄兘鍏堟樉绀鸿鍗$晫闈紝绛夊緟鐢ㄦ埛鍒锋柊鍗�
resetToReadingState()
@@ -85,100 +77,8 @@
}
}
- /**
- * 鑾峰彇鏀粯鏂瑰紡鍒楄〃
- */
- private fun getPaymentMethods() {
- ApiManager.getInstance().requestGetLoading(
- this,
- "sell/paymentmethod/get",
- PaymentMethodResponse::class.java,
- null,
- object : SubscriberListener<BaseResponse<PaymentMethodResponse>>() {
- override fun onNext(response: BaseResponse<PaymentMethodResponse>) {
- if (response.success) {
- // 鑾峰彇鏀粯鏂瑰紡鍒楄〃
- val paymentMethods = response.content?.obj ?: listOf()
- if (paymentMethods.isNotEmpty()) {
- paymentMethodList = paymentMethods
- // 鏇存柊鏀粯鏂瑰紡鏄剧ず
- updatePaymentMethodRadioGroup()
- }
- } else {
- Toast.makeText(
- this@CardReplaceActivity,
- "鑾峰彇鏀粯鏂瑰紡澶辫触: ${response.msg}",
- Toast.LENGTH_SHORT
- ).show()
- }
- }
- override fun onError(e: Throwable?) {
- super.onError(e)
- Toast.makeText(
- this@CardReplaceActivity,
- "鑾峰彇鏀粯鏂瑰紡澶辫触: ${e?.message ?: "缃戠粶寮傚父"}",
- Toast.LENGTH_SHORT
- ).show()
- }
- }
- )
- }
- /**
- * 鏇存柊鏀粯鏂瑰紡RadioGroup
- */
- private fun updatePaymentMethodRadioGroup() {
- // 娓呯┖鍘熸湁RadioButton
- binding.paymentMethodGroup.removeAllViews()
-
- // 鍔ㄦ�佹坊鍔燫adioButton
- paymentMethodList.forEachIndexed { index, method ->
- val radioButton = RadioButton(this)
- radioButton.id = View.generateViewId() // 鐢熸垚鍞竴ID
- radioButton.layoutParams = android.widget.LinearLayout.LayoutParams(
- 0,
- resources.getDimensionPixelSize(R.dimen.dimen_40),
- 1.0f
- )
-
- // 濡傛灉涓嶆槸鏈�鍚庝竴涓寜閽紝娣诲姞鍙宠竟璺�
- if (index < paymentMethodList.size - 1) {
- (radioButton.layoutParams as android.widget.LinearLayout.LayoutParams).rightMargin =
- resources.getDimensionPixelSize(R.dimen.dimen_15)
- }
-
- radioButton.text = method.name
- radioButton.background = resources.getDrawable(R.drawable.radio_selector)
- radioButton.buttonDrawable = null
- radioButton.gravity = android.view.Gravity.CENTER
- radioButton.setTextColor(resources.getColorStateList(R.color.radio_button_text_color))
- radioButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
-
- // 娣诲姞鍒癛adioGroup
- binding.paymentMethodGroup.addView(radioButton)
-
- // 榛樿閫変腑绗竴涓�
- if (index == 0) {
- radioButton.isChecked = true
- paymentMethod = method.name
- paymentId = method.id
- }
- }
-
- // 璁剧疆鏀粯鏂瑰紡閫夋嫨鐩戝惉
- binding.paymentMethodGroup.setOnCheckedChangeListener { group, checkedId ->
- // 鏍规嵁閫変腑鐨処D鑾峰彇鏀粯鏂瑰紡
- for (i in 0 until group.childCount) {
- val radioButton = group.getChildAt(i) as RadioButton
- if (radioButton.id == checkedId) {
- paymentMethod = radioButton.text.toString()
- paymentId = paymentMethodList[i].id
- break
- }
- }
- }
- }
/**
* 閲嶇疆鍒拌鍗$姸鎬�
@@ -275,7 +175,9 @@
}
else -> {
-
+ showConfirmDialog("褰撳墠闈炵櫧鍗�") {
+ resetToReadingState()
+ }
}
}
@@ -474,6 +376,7 @@
putExtra("paymentMethod", paymentMethod) // 浼犻�掓敮浠樻柟寮�
putExtra("paymentId", paymentId) // 浼犻�掓敮浠樻柟寮廔D
putExtra("userCard", updatedUserCard as java.io.Serializable)
+ putExtra("cardInfo", cardInfo)
}
startActivity(intent)
finish()
--
Gitblit v1.8.0