|
|
@@ -60,6 +60,7 @@ class TextDropDownDialog(
|
|
|
if (item.itemExpand) collapse() else expand()
|
|
|
itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
|
|
|
}
|
|
|
+ itemBinding.checkIv.isVisible = item.isSelected()
|
|
|
itemBinding.rootLayout.setDebouncedClickListener {
|
|
|
if (multiSelect) {
|
|
|
if (item.getChildren().isEmpty() || canSelectedParent) {
|
|
|
@@ -69,6 +70,7 @@ class TextDropDownDialog(
|
|
|
?.filterIsInstance<TextDropDownEntity>()
|
|
|
?.filter { it.isSelected() }
|
|
|
onMultiSelect(selected)
|
|
|
+ adapter.notifyDataSetChanged()
|
|
|
} else {
|
|
|
if (item.itemExpand) collapse() else expand()
|
|
|
itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
|
|
|
@@ -206,6 +208,10 @@ class TextDropDownDialog(
|
|
|
fun getChildren(): List<TextDropDownEntity>
|
|
|
fun setChildren(children: List<TextDropDownEntity>)
|
|
|
fun getLevel(): Int
|
|
|
+
|
|
|
+ fun checkItemSelected(action: (TextDropDownEntity) -> Boolean)
|
|
|
+
|
|
|
+ fun findTreeData(action: (TextDropDownEntity) -> Boolean): List<TextDropDownEntity>
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -244,5 +250,22 @@ class TextDropDownDialog(
|
|
|
}
|
|
|
|
|
|
override fun getLevel() = dataLevel
|
|
|
+
|
|
|
+ override fun checkItemSelected(action: (TextDropDownEntity) -> Boolean) {
|
|
|
+ selected = action(this)
|
|
|
+ children.forEach {
|
|
|
+ it.checkItemSelected(action)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun findTreeData(action: (TextDropDownEntity) -> Boolean): List<TextDropDownEntity> {
|
|
|
+ val result = mutableListOf<TextDropDownEntity>()
|
|
|
+ if (action(this)) {
|
|
|
+ result.add(this)
|
|
|
+ }
|
|
|
+ result += children.flatMap { it.findTreeData(action) }
|
|
|
+ return result
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|