提交 e4234c12 编写于 作者: limuyang2's avatar limuyang2

- add removeAt()

上级 fdf8ab50
buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
......
......@@ -103,8 +103,8 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
*
* @param position Int 整个 data 的 index
*/
override fun remove(position: Int) {
val removeCount = removeAt(position)
override fun removeAt(position: Int) {
val removeCount = removeNodesAt(position)
notifyItemRangeRemoved(position + headerLayoutCount, removeCount)
compatibilityDataSizeChanged(0)
}
......@@ -116,7 +116,7 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
*/
override fun setData(index: Int, data: BaseNode) {
// 先移除,再添加
val removeCount = removeAt(index)
val removeCount = removeNodesAt(index)
val newFlatData = flatData(arrayListOf(data))
this.data.addAll(index, newFlatData)
......@@ -152,7 +152,7 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
* @param position Int
* @return Int 被移除的数量
*/
private fun removeAt(position: Int): Int {
private fun removeNodesAt(position: Int): Int {
if (position >= data.size) {
return 0
}
......
......@@ -18,7 +18,6 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder
* @param T data 数据类型
* @constructor
*/
@Deprecated("please use Class BaseBinderAdapter")
abstract class BaseProviderMultiAdapter<T>(data: MutableList<T>? = null) :
BaseQuickAdapter<T, BaseViewHolder>(0, data) {
......
......@@ -1238,7 +1238,18 @@ abstract class BaseQuickAdapter<T, VH : BaseViewHolder>
*
* @param position
*/
@Deprecated("Please use removeAt()", replaceWith = ReplaceWith("removeAt(position)"))
open fun remove(@IntRange(from = 0) position: Int) {
removeAt(position)
}
/**
* remove the item associated with the specified position of adapter
* 删除指定位置的数据
*
* @param position
*/
open fun removeAt(@IntRange(from = 0) position: Int) {
if (position >= data.size) {
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册