Skip to content

Commit 134aad8

Browse files
committed
Upload file
1 parent 6cf4ae9 commit 134aad8

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

common/src/main/java/com/omarea/common/ui/DialogAppChooser.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DialogAppChooser(
2323
private var excludeApps: Array<String> = arrayOf()
2424
private lateinit var adapter: AdapterAppChooser
2525
private var loadingView: View? = null
26+
private var selectAllCheckBox: CompoundButton? = null
2627

2728
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
2829
super.onViewCreated(view, savedInstanceState)
@@ -41,7 +42,8 @@ class DialogAppChooser(
4142
}
4243

4344
// 全选
44-
val selectAll = view.findViewById<CompoundButton?>(R.id.select_all)
45+
selectAllCheckBox = view.findViewById(R.id.select_all)
46+
val selectAll = selectAllCheckBox
4547
if (selectAll != null) {
4648
if (multiple) {
4749
val adapter = absListView.adapter as? AdapterAppChooser
@@ -123,8 +125,17 @@ class DialogAppChooser(
123125
}
124126

125127
fun notifyDataChanged() {
126-
if (::adapter.isInitialized) {
127-
adapter.notifyDataSetChanged()
128+
if (!::adapter.isInitialized) return
129+
130+
adapter.notifyDataSetChanged()
131+
132+
// 🔥 sync lại trạng thái "Chọn tất cả"
133+
if (multiple) {
134+
val allSelected =
135+
adapter.count > 0 &&
136+
adapter.getSelectedItems().size == adapter.count
137+
138+
selectAllCheckBox?.isChecked = allSelected
128139
}
129140
}
130141

0 commit comments

Comments
 (0)