File tree Expand file tree Collapse file tree
common/src/main/java/com/omarea/common/ui Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments