Skip to content

Commit

Permalink
add notes
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang committed Jan 3, 2020
1 parent 2f6888d commit ef16c3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ abstract class BaseNodeAdapter(data: MutableList<BaseNode>? = null)
super.setNewData(flatData(data ?: arrayListOf()))
}

/**
* 如果需要对某节点下的子节点进行数据操作,请使用[nodeAddData]!
*
* @param position Int 整个 data 的 index
* @param data BaseNode
*/
override fun addData(position: Int, data: BaseNode) {
addData(position, arrayListOf(data))
}
Expand All @@ -102,12 +108,22 @@ abstract class BaseNodeAdapter(data: MutableList<BaseNode>? = null)
super.addData(nodes)
}

/**
* 如果需要对某节点下的子节点进行数据操作,请使用[nodeRemoveData]!
*
* @param position Int 整个 data 的 index
*/
override fun remove(position: Int) {
val removeCount = removeAt(position)
notifyItemRangeRemoved(position + getHeaderLayoutCount(), removeCount)
compatibilityDataSizeChanged(0)
}

/**
* 如果需要对某节点下的子节点进行数据操作,请使用[nodeSetData]!
* @param index Int
* @param data BaseNode
*/
override fun setData(index: Int, data: BaseNode) {
// 先移除,再添加
val removeCount = removeAt(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ abstract class BaseNode {

/**
* 重写此方法,获取子节点。如果没有子节点,返回 null 或者 空数组
*
* 如果返回 null,则无法对子节点的数据进行新增和删除等操作
*/
abstract val childNode: MutableList<BaseNode>?

Expand Down

0 comments on commit ef16c3a

Please sign in to comment.