lmw
7 小时以前 b6d14ec6c19cddb1c8caf1d024e77d250a203929
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
36
37
package com.dollearn.student.ui.home.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.gone
import cn.sinata.xldutils.visible
import com.dollearn.student.R
import com.dollearn.student.network.entity.SortBean
import org.jetbrains.anko.backgroundColorResource
import org.jetbrains.anko.backgroundResource
import org.jetbrains.anko.textColorResource
import java.util.ArrayList
 
class IndexAdapter(indexList: ArrayList<SortBean>):HFRecyclerAdapter<SortBean>(indexList, R.layout.item_index) {
    override fun onBind(holder: ViewHolder, position: Int, data: SortBean) {
        val tv_sort = holder.bind<TextView>(R.id.tv_sort)
        val bg = holder.bind<View>(R.id.bg)
        tv_sort.text = (position+1).toString()
        tv_sort.textColorResource = if (data.status == 2) R.color.textColorGreen else if (data.status == 3) R.color.colorOrange else R.color.textColor99
        when(data.status){
            2->{
                tv_sort.textColorResource = R.color.textColorGreen
                bg.backgroundResource = R.drawable.bg_white_green_line_1
            }
            3->{
                tv_sort.textColorResource = R.color.colorOrange
                bg.backgroundResource = R.drawable.bg_white_orange_line_1
            }
            else->{
                tv_sort.textColorResource = R.color.textColor99
                bg.backgroundResource = R.drawable.bg_white_grey_line_1
            }
        }
    }
}