class FirstNodeProvider(
override val itemViewType: Int,
override val layoutId: Int,
val click: (schema_directory_id: Int) -> Unit
) :
BaseNodeProvider() {
override fun convert(helper: BaseViewHolder, item: BaseNode) {
val firstNode = item as? FirstNode
helper.setText(R.id.tv_title, firstNode?.title)
if (firstNode is BaseExpandNode) {
val view = helper.getView(R.id.iv_arrow)
view.rotation = if (firstNode.isExpanded) -180f else 0f
}
}
使用BaseExpandNode作为父节点,BaseNode作为子节点,父节点下的子节点通过接口请求下来动态添加进去,在父节点有个loading,点击父节点请求网络出现loading, 但是数据添加进来之后,loading位置跑到别的父节点上去了
class FirstNodeProvider( override val itemViewType: Int, override val layoutId: Int, val click: (schema_directory_id: Int) -> Unit ) : BaseNodeProvider() { override fun convert(helper: BaseViewHolder, item: BaseNode) { val firstNode = item as? FirstNode helper.setText(R.id.tv_title, firstNode?.title) if (firstNode is BaseExpandNode) { val view = helper.getView(R.id.iv_arrow)
view.rotation = if (firstNode.isExpanded) -180f else 0f
}
}
}
通过这种方法添加数据 nodeReplaceChildData()