Skip to content

Commit

Permalink
feat: 可能的崩溃问题
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang2 committed Oct 20, 2022
1 parent 234b856 commit f5ffeba
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ open class BaseBinderAdapter(list: MutableList<Any>? = null) : BaseQuickAdapter<
val itemViewType = viewHolder.itemViewType
val binder = getItemBinder(itemViewType)

val item = data.getOrNull(position) ?: return@setOnClickListener
binder.onClick(viewHolder, it, data[position], position)
}
}
Expand All @@ -145,7 +146,9 @@ open class BaseBinderAdapter(list: MutableList<Any>? = null) : BaseQuickAdapter<

val itemViewType = viewHolder.itemViewType
val binder = getItemBinder(itemViewType)
binder.onLongClick(viewHolder, it, data[position], position)

val item = data.getOrNull(position) ?: return@setOnLongClickListener false
binder.onLongClick(viewHolder, it, item, position)
}
}
}
Expand All @@ -165,7 +168,8 @@ open class BaseBinderAdapter(list: MutableList<Any>? = null) : BaseQuickAdapter<
return@setOnClickListener
}
position -= headerLayoutCount
provider.onChildClick(viewHolder, v, data[position], position)
val item = data.getOrNull(position) ?: return@setOnClickListener
provider.onChildClick(viewHolder, v, item, position)
}
}
}
Expand All @@ -184,7 +188,8 @@ open class BaseBinderAdapter(list: MutableList<Any>? = null) : BaseQuickAdapter<
return@setOnLongClickListener false
}
position -= headerLayoutCount
provider.onChildLongClick(viewHolder, v, data[position], position)
val item = data.getOrNull(position) ?: return@setOnLongClickListener false
provider.onChildLongClick(viewHolder, v, item, position)
}
}
}
Expand Down

0 comments on commit f5ffeba

Please sign in to comment.