Skip to content

Commit

Permalink
- add removeAt()
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang committed Apr 11, 2020
1 parent fdf8ab5 commit e4234c1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e4234c1

Please sign in to comment.