Skip to content

Commit

Permalink
pref: 简化ItemBind参数名称
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjingkanji committed Aug 6, 2023
1 parent 1bcfac6 commit 1ed0239
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 6 additions & 2 deletions brv/src/main/java/com/drake/brv/BindingAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,9 @@ open class BindingAdapter : RecyclerView.Adapter<BindingAdapter.BindingViewHolde
*/
fun onToggle(block: (position: Int, toggleMode: Boolean, end: Boolean) -> Unit) {
onToggle = block
} //</editor-fold>
}

//</editor-fold>


// <editor-fold desc="选择模式">
Expand Down Expand Up @@ -1318,5 +1320,7 @@ open class BindingAdapter : RecyclerView.Adapter<BindingAdapter.BindingViewHolde
fun isHover(position: Int): Boolean {
val model = getModelOrNull<ItemHover>(position)
return model != null && model.itemHover && hoverEnabled
} //</editor-fold>
}

//</editor-fold>
}
5 changes: 1 addition & 4 deletions brv/src/main/java/com/drake/brv/item/ItemBind.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ package com.drake.brv.item

import com.drake.brv.BindingAdapter

/**
* 实现接口进行UI操作不符合MVVM, 因为Model中不允许出现View引用. 并不是太推荐使用
*/
interface ItemBind {
fun onBind(holder: BindingAdapter.BindingViewHolder)
fun onBind(vh: BindingAdapter.BindingViewHolder)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.drake.brv.item.ItemBind
class SimpleBindingModel() : ItemBind {

// 多类型列表请注意区分类型 https://liangjingkanji.github.io/BRV/multi-type.html#_5
override fun onBind(holder: BindingAdapter.BindingViewHolder) {
override fun onBind(vh: BindingAdapter.BindingViewHolder) {
// val binding = holder.getBinding<ItemViewBindingBinding>()
// binding.tvSimple.text = holder.layoutPosition.toString()
}
Expand Down

0 comments on commit 1ed0239

Please sign in to comment.