From 83d3873e884d62d6f5b13874ef43197285ef29e1 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 21 Nov 2022 00:44:16 +0100 Subject: WIP current changes --- .../wireguard/android/fragment/AppListDialogFragment.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt index 1a40a1cd..70321d03 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt @@ -47,12 +47,6 @@ class AppListDialogFragment : DialogFragment() { val appInfo = it.applicationInfo val appData = ApplicationData(appInfo.loadIcon(pm), appInfo.loadLabel(pm).toString(), packageName, currentlySelectedApps.contains(packageName)) applicationData.add(appData) - appData.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() { - override fun onPropertyChanged(sender: Observable?, propertyId: Int) { - if (propertyId == BR.selected) - setButtonText() - } - }) } } applicationData.sortWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name }) @@ -60,6 +54,16 @@ class AppListDialogFragment : DialogFragment() { appData.clear() appData.addAll(applicationData) } + withContext(Dispatchers.IO) { + appData.forEach() { + it.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() { + override fun onPropertyChanged(sender: Observable?, propertyId: Int) { + if (propertyId == BR.selected) + setButtonText() + } + }) + } + } } catch (e: Throwable) { withContext(Dispatchers.Main.immediate) { val error = ErrorMessages[e] -- cgit v1.2.3