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
|
}
|
}
|