From cece79bf75a9b672b33b772acffca209eecfc8f2 Mon Sep 17 00:00:00 2001 From: zuoxiao <lf_zuo@163.com> Date: 星期四, 26 六月 2025 08:27:25 +0800 Subject: [PATCH] refactor(generallibrary):优化补卡界面布局和样式- 调整了卡片信息展示区域的样式,包括背景色、文字颜色等 - 优化了输入区域的布局结构,减小了控件间距和尺寸- 更新了确认补卡按钮的样式 - 统一了文字大小和颜色,提高了可读性 --- generallibrary/src/main/java/com/dayu/general/activity/CardReplaceActivity.kt | 108 ++--------------------------------------------------- 1 files changed, 5 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..fd354f1 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() + } } } -- Gitblit v1.8.0