|
|
@@ -29,6 +29,7 @@ class TextDropDownDialog(
|
|
|
private val multiSelect: Boolean,
|
|
|
private val treeSelect: Boolean,
|
|
|
private val showSearchView: Boolean = false,
|
|
|
+ private val canSelectedParent: Boolean = false,
|
|
|
private val onSelect: (TextDropDownEntity) -> Unit,
|
|
|
private val onMultiSelect: (List<TextDropDownEntity>?) -> Unit
|
|
|
) : OnBindView<CustomDialog>(R.layout.dialog_drop_down_list) {
|
|
|
@@ -49,15 +50,19 @@ class TextDropDownDialog(
|
|
|
onBind {
|
|
|
val item = getModel<TextDropDownEntity>()
|
|
|
val itemBinding = getBinding<ItemHomeTextDropDownBinding>()
|
|
|
- itemBinding.arrowIv.isVisible = item.getChildren().isNotEmpty()
|
|
|
+ itemBinding.arrowIv.isVisible = true
|
|
|
// 缩进
|
|
|
itemBinding.rootLayout.setPadding(indentPx * item.getLevel(), 0, 0, 0)
|
|
|
itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
|
|
|
// 文本和选中
|
|
|
itemBinding.dropDownText.text = item.getShowText()
|
|
|
+ itemBinding.arrowIv.setDebouncedClickListener {
|
|
|
+ if (item.itemExpand) collapse() else expand()
|
|
|
+ itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
|
|
|
+ }
|
|
|
itemBinding.rootLayout.setDebouncedClickListener {
|
|
|
if (multiSelect) {
|
|
|
- if (item.getChildren().isEmpty()) {
|
|
|
+ if (item.getChildren().isEmpty() || canSelectedParent) {
|
|
|
item.setSelected(!item.isSelected())
|
|
|
itemBinding.checkIv.isVisible = item.isSelected()
|
|
|
val selected = binding.dropDownRv.models
|
|
|
@@ -115,7 +120,7 @@ class TextDropDownDialog(
|
|
|
onSelect: (TextDropDownEntity) -> Unit
|
|
|
) {
|
|
|
CustomDialog.show(
|
|
|
- TextDropDownDialog(data, false, false, showSearchView, onSelect) { }
|
|
|
+ TextDropDownDialog(data, false, false, showSearchView, false, onSelect) { }
|
|
|
).setAlignBaseViewGravity(view, Gravity.BOTTOM or Gravity.CENTER).setWidth(view.width)
|
|
|
}
|
|
|
|
|
|
@@ -130,7 +135,7 @@ class TextDropDownDialog(
|
|
|
onMultiSelect: (List<TextDropDownEntity>?) -> Unit
|
|
|
) {
|
|
|
CustomDialog.show(
|
|
|
- TextDropDownDialog(data, true, false, showSearchView, {}) { selected ->
|
|
|
+ TextDropDownDialog(data, true, false, showSearchView, false, {}) { selected ->
|
|
|
onMultiSelect(
|
|
|
selected
|
|
|
)
|
|
|
@@ -146,10 +151,18 @@ class TextDropDownDialog(
|
|
|
data: List<TextDropDownEntity>,
|
|
|
view: View,
|
|
|
showSearchView: Boolean = false,
|
|
|
+ canSelectedParent: Boolean = true,
|
|
|
onSelect: (TextDropDownEntity) -> Unit
|
|
|
) {
|
|
|
CustomDialog.show(
|
|
|
- TextDropDownDialog(data, false, true, showSearchView, onSelect) { }
|
|
|
+ TextDropDownDialog(
|
|
|
+ data,
|
|
|
+ false,
|
|
|
+ true,
|
|
|
+ showSearchView,
|
|
|
+ canSelectedParent,
|
|
|
+ onSelect
|
|
|
+ ) { }
|
|
|
).setAlignBaseViewGravity(view, Gravity.BOTTOM or Gravity.CENTER).setWidth(view.width)
|
|
|
}
|
|
|
|
|
|
@@ -161,10 +174,17 @@ class TextDropDownDialog(
|
|
|
data: List<TextDropDownEntity>,
|
|
|
view: View,
|
|
|
showSearchView: Boolean = false,
|
|
|
+ canSelectedParent: Boolean = false,
|
|
|
onMultiSelect: (List<TextDropDownEntity>?) -> Unit
|
|
|
) {
|
|
|
CustomDialog.show(
|
|
|
- TextDropDownDialog(data, true, true, showSearchView, {}) { selected ->
|
|
|
+ TextDropDownDialog(
|
|
|
+ data,
|
|
|
+ true,
|
|
|
+ true,
|
|
|
+ showSearchView,
|
|
|
+ canSelectedParent,
|
|
|
+ {}) { selected ->
|
|
|
onMultiSelect(
|
|
|
selected
|
|
|
)
|