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

- add removeAt()

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