From 73f81c096570a26d0fa773126680037eac1e0c95 Mon Sep 17 00:00:00 2001 From: cyh Date: Tue, 15 Apr 2025 11:07:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=85=85=E5=80=BC=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recharge/adapter/VIPRechargeAdapter.kt | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/yingmao/clash/fragment/recharge/adapter/VIPRechargeAdapter.kt b/app/src/main/java/com/yingmao/clash/fragment/recharge/adapter/VIPRechargeAdapter.kt index 0527a0c..d0fe8ce 100644 --- a/app/src/main/java/com/yingmao/clash/fragment/recharge/adapter/VIPRechargeAdapter.kt +++ b/app/src/main/java/com/yingmao/clash/fragment/recharge/adapter/VIPRechargeAdapter.kt @@ -67,15 +67,15 @@ class VIPRechargeAdapter : RecyclerView.Adapter { 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 { 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 { 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 { 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 { - 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 0) { holder.clRandomlySend.visibility = View.VISIBLE holder.tvRandomlySend.text = @@ -161,11 +161,11 @@ class VIPRechargeAdapter : RecyclerView.Adapter{ // holder.tvDayTxt.text=context!!.resources.getString(R.string.price30) // } @@ -179,7 +179,7 @@ class VIPRechargeAdapter : RecyclerView.Adapter{ -// 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