lmw
2025-04-24 718f31c92e2029d05260810435a2c70cef6e6ce5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.sinata.xqmuse.ui.mine.adapter
 
import android.view.View
import android.widget.TextView
import cn.sinata.xldutils.adapter.HFRecyclerAdapter
import cn.sinata.xldutils.adapter.util.ViewHolder
import cn.sinata.xldutils.utils.SpanBuilder
import com.sinata.xqmuse.R
import org.jetbrains.anko.backgroundResource
import org.jetbrains.anko.textColorResource
import java.util.ArrayList
 
class VipPriceAdapter(price: ArrayList<Double>):HFRecyclerAdapter<Double>(price, R.layout.item_vip) {
    var checked = 0
    override fun onBind(holder: ViewHolder, position: Int, data: Double) {
        holder.setText(R.id.tv_name,if (position == 0) "月度会员" else if (position == 1) "季度会员" else "年度会员")
        holder.setText(R.id.tv_price,SpanBuilder("¥%.2f".format(data)).size(0,1,15).build())
        holder.setText(R.id.tv_daily_price,"¥%.2f/天".format(data/(if (position == 0)30 else if (position == 1) 90 else 365)))
        val bg = holder.bind<View>(R.id.cl_bg)
        val tvName = holder.bind<TextView>(R.id.tv_name)
        val tvPrice = holder.bind<TextView>(R.id.tv_price)
        val tvDaily = holder.bind<TextView>(R.id.tv_daily_price)
        if (position == checked){
            bg.backgroundResource = R.drawable.bg_light_green_10dp
            tvName.textColorResource = R.color.white
            tvPrice.textColorResource = R.color.white
            tvDaily.textColorResource = R.color.white
        }else{
            bg.backgroundResource = R.drawable.bg_grey_10dp
            tvName.textColorResource = R.color.textColor
            tvPrice.textColorResource = R.color.textColor
            tvDaily.textColorResource = R.color.textColor99
        }
    }
}