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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cn.flightfeather.thirdapp.view.recyclerview
 
import android.content.res.ColorStateList
import android.os.Build
import android.support.annotation.DrawableRes
import android.support.annotation.IdRes
import android.support.annotation.RequiresApi
import android.support.design.widget.FloatingActionButton
import android.support.v4.content.ContextCompat
import android.view.View
import com.chad.library.adapter.base.BaseViewHolder
 
/**
 * @author riku
 * Date: 2019/4/19
 * 扩展viewHolder,之后可能添加databinding,以及扩展view的属性设置方法
 */
class BaseCustomViewHolder(view: View?) : BaseViewHolder(view) {
 
//    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
//    fun setBackgroundTint(@IdRes viewId: Int, colorStateList: ColorStateList?): BaseCustomViewHolder {
//        val view = getView<View>(viewId)
//        view.backgroundTintList = colorStateList
//        return this
//    }
 
    fun setSelected(@IdRes viewId: Int, selected: Boolean): BaseCustomViewHolder {
        val view = getView<View>(viewId)
        view.isSelected = selected
        return this
    }
 
    fun setClickable(@IdRes viewId: Int, clickable: Boolean): BaseCustomViewHolder {
        val view = getView<View>(viewId)
        view.isClickable = clickable
        return this
    }
 
//    fun setMyProgress(@IdRes viewId: Int, progress: Long, max: Long): BaseCustomViewHolder {
//        val view = getView<CircularProgressBar>(viewId)
//        view.apply {
//            this.progress = progress.toFloat()
//            this.progressMax = max.toFloat()
//        }
//        return this
//    }
 
    fun setMyVisible(@IdRes viewId: Int, visible: Int): BaseCustomViewHolder {
        val view = getView<View>(viewId)
        view.visibility = visible
        return this
    }
}