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