lmw
16 小时以前 b6d14ec6c19cddb1c8caf1d024e77d250a203929
app/src/main/java/com/dollearn/student/ui/home/adapter/IndexAdapter.kt
@@ -1,17 +1,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
            }
        }
    }
}