summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt16
1 files 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]