summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt1
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt17
2 files changed, 18 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
index f50f65e410..e4d19ebf9e 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
@@ -48,6 +48,7 @@ class AdvancedFragment : ServiceDependentFragment(OnNoService.GoBack) {
}
override fun onSafelyDestroyView() {
+ customDnsAdapter.onDestroy()
titleController.onDestroy()
settingsListener.unsubscribe(this)
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
index 3abe3c59f5..429a6f98fa 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
@@ -5,8 +5,21 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.service.CustomDns
+import net.mullvad.mullvadvpn.util.JobTracker
class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>() {
+ private val jobTracker = JobTracker()
+
+ private var enabled = false
+
+ init {
+ customDns.onEnabledChanged.subscribe(this) { value ->
+ jobTracker.newUiJob("updateEnabled") {
+ enabled = value
+ }
+ }
+ }
+
override fun getItemCount() = 1
override fun onCreateViewHolder(parentView: ViewGroup, type: Int): CustomDnsItemHolder {
@@ -17,4 +30,8 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
}
override fun onBindViewHolder(holder: CustomDnsItemHolder, position: Int) {}
+
+ fun onDestroy() {
+ customDns.onEnabledChanged.unsubscribe(this)
+ }
}