fix 充值界面

This commit is contained in:
cyh 2025-04-15 11:07:40 +08:00
parent c0b7d7e9d0
commit 73f81c0965
1 changed files with 28 additions and 28 deletions

View File

@ -67,15 +67,15 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
holder.cyn.text = context!!.resources.getString(R.string.everyDay)
if (rechargeInfo.grade!![position].days != null) {
val giftDay = rechargeInfo.grade!![position].giftDay ?: 0
val firstPayGiftDay = rechargeInfo.firstPayGiftDay!!.toInt()
val notFirstPayGiftDay = rechargeInfo.notFirstPayGiftDay!!.toInt()
val giftDay = rechargeInfo.grade?.getOrNull(position)?.giftDay ?: 0
val firstPayGiftDay = rechargeInfo.firstPayGiftDay?.toInt()?:0
val notFirstPayGiftDay = rechargeInfo.notFirstPayGiftDay?.toInt()?:0
val totalGiftAmount = giftDay + firstPayGiftDay + notFirstPayGiftDay
when (rechargeInfo.grade!![position].days) {
when (rechargeInfo.grade?.getOrNull(position)?.days) {
30 -> {
holder.tvDayTxt.text = context!!.resources.getString(R.string.price30)
if (rechargeInfo.grade!![position].amount != null) {
val data = rechargeInfo.grade!![position].amount!!.toDouble()
if (rechargeInfo.grade?.getOrNull(position)?.amount != null) {
val data = rechargeInfo.grade?.getOrNull(position)?.amount!!.toDouble()
.div(30 + totalGiftAmount)
val tempStr = String.format("%.2f", data)
holder.tvDayAverage.text =
@ -86,8 +86,8 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
90 -> {
holder.tvDayTxt.text = context!!.resources.getString(R.string.price90)
if (rechargeInfo.grade!![position].amount != null) {
val data = rechargeInfo.grade!![position].amount!!.toDouble()
if (rechargeInfo.grade?.getOrNull(position)?.amount != null) {
val data = rechargeInfo.grade?.getOrNull(position)?.amount!!.toDouble()
.div(90 + totalGiftAmount)
val tempStr = String.format("%.2f", data)
holder.tvDayAverage.text =
@ -97,8 +97,8 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
180 -> {
holder.tvDayTxt.text = context!!.resources.getString(R.string.price180)
if (rechargeInfo.grade!![position].amount != null) {
val data = rechargeInfo.grade!![position].amount!!.toDouble()
if (rechargeInfo.grade?.getOrNull(position)?.amount != null) {
val data = rechargeInfo.grade?.getOrNull(position)?.amount!!.toDouble()
.div(180 + totalGiftAmount)
val tempStr = String.format("%.2f", data)
holder.tvDayAverage.text =
@ -108,8 +108,8 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
365 -> {
holder.tvDayTxt.text = context!!.resources.getString(R.string.price365)
if (rechargeInfo.grade!![position].amount != null) {
val data = rechargeInfo.grade!![position].amount!!.toDouble()
if (rechargeInfo.grade?.getOrNull(position)?.amount != null) {
val data = rechargeInfo.grade?.getOrNull(position)?.amount!!.toDouble()
.div(365 + totalGiftAmount)
val tempStr = String.format("%.2f", data)
holder.tvDayAverage.text =
@ -118,10 +118,10 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
}
else -> {
val days = rechargeInfo.grade!![position].days
val days = rechargeInfo.grade?.getOrNull(position)?.days
holder.tvDayTxt.text = "$days" + context!!.resources.getString(R.string.day)
if (rechargeInfo.grade!![position].amount != null) {
val data = rechargeInfo.grade!![position].amount!!.toDouble()
if (rechargeInfo.grade?.getOrNull(position)?.amount != null) {
val data = rechargeInfo.grade?.getOrNull(position)?.amount!!.toDouble()
.div(days!! + totalGiftAmount)
val tempStr = String.format("%.2f", data)
holder.tvDayAverage.text =
@ -133,19 +133,19 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
if (selectorPosition == position) {
holder.rechargeItemRl.isSelected = true
if (selectorPosition == 0) {
listener?.onItemClick(rechargeInfo.grade!![position])
listener?.onItemClick(rechargeInfo.grade?.getOrNull(position))
}
} else {
holder.rechargeItemRl.isSelected = false
}
holder.rechargeItemRl.setOnClickListener {
Log.i("TESSS position:${position}")
listener?.onItemClick(rechargeInfo.grade!![position])
listener?.onItemClick(rechargeInfo.grade?.getOrNull(position))
selectorPosition = position
notifyDataSetChanged()
}
if (rechargeInfo.grade!![position].giftDay != null && rechargeInfo.firstPayGiftDay != null && rechargeInfo.notFirstPayGiftDay != null) {
if (rechargeInfo.grade?.getOrNull(position)?.giftDay != null && rechargeInfo.firstPayGiftDay != null && rechargeInfo.notFirstPayGiftDay != null) {
if (totalGiftAmount > 0) {
holder.clRandomlySend.visibility = View.VISIBLE
holder.tvRandomlySend.text =
@ -161,11 +161,11 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
}
// if(rechargeInfo.grade!=null){
// holder.tvDayAverage.text=" ¥${rechargeInfo.grade!![position].amount}"
// if(rechargeInfo.grade!![position].days!=null){
// holder.tvDiscount.text=" ¥"+context!!.resources.getString(R.string.Discount).replace("$","${rechargeInfo.grade!![position].monthlyAmount}")
// holder.tvDayAverage.text=" ¥${rechargeInfo.grade?.getOrNull(position)?.amount}"
// if(rechargeInfo.grade?.getOrNull(position)?.days!=null){
// holder.tvDiscount.text=" ¥"+context!!.resources.getString(R.string.Discount).replace("$","${rechargeInfo.grade?.getOrNull(position)?.monthlyAmount}")
// if(context!=null){
// when(rechargeInfo.grade!![position].days){
// when(rechargeInfo.grade?.getOrNull(position)?.days){
// 30->{
// holder.tvDayTxt.text=context!!.resources.getString(R.string.price30)
// }
@ -179,7 +179,7 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
// holder.tvDayTxt.text=context!!.resources.getString(R.string.price365)
// }
// else->{
// holder.tvDayTxt.text="${rechargeInfo.grade!![position].days}"+ context!!.resources.getString(R.string.day)
// holder.tvDayTxt.text="${rechargeInfo.grade?.getOrNull(position)?.days}"+ context!!.resources.getString(R.string.day)
// }
// }
// }
@ -188,19 +188,19 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
// if(selectorPosition == position){
// holder.rechargeItemRl.isSelected = true
// if(selectorPosition==0){
// listener?.onItemClick(rechargeInfo.grade!![position])
// listener?.onItemClick(rechargeInfo.grade?.getOrNull(position))
// }
// }else{
// holder.rechargeItemRl.isSelected = false
// }
// holder.rechargeItemRl.setOnClickListener {
// Log.i("TESSS position:${position}")
// listener?.onItemClick(rechargeInfo.grade!![position])
// listener?.onItemClick(rechargeInfo.grade?.getOrNull(position))
// selectorPosition=position
// notifyDataSetChanged()
// }
// if(rechargeInfo.grade!![position].giftDay!=null&&rechargeInfo.firstPayGiftDay!=null&&rechargeInfo.notFirstPayGiftDay!=null){
// val giftDay =rechargeInfo.grade!![position].giftDay?:0
// if(rechargeInfo.grade?.getOrNull(position)?.giftDay!=null&&rechargeInfo.firstPayGiftDay!=null&&rechargeInfo.notFirstPayGiftDay!=null){
// val giftDay =rechargeInfo.grade?.getOrNull(position)?.giftDay?:0
// val firstPayGiftDay =rechargeInfo.firstPayGiftDay!!.toInt()
// val notFirstPayGiftDay =rechargeInfo.notFirstPayGiftDay!!.toInt()
// val totalGiftAmount=giftDay+firstPayGiftDay+notFirstPayGiftDay
@ -219,6 +219,6 @@ class VIPRechargeAdapter : RecyclerView.Adapter<VIPRechargeAdapter.VIPRechargeVi
* 内置监听回调
* */
interface VIPRechargeItemClickListener {
fun onItemClick(noteItem: Grade)
fun onItemClick(noteItem: Grade?)
}
}