summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
index f0eda52..d2138af 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
@@ -42,8 +42,10 @@ import foundation.e.privacycentralapp.features.internetprivacy.InternetPrivacyFr
import foundation.e.privacycentralapp.features.location.FakeLocationFragment
import foundation.e.privacycentralapp.features.trackers.TrackersFragment
import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.launch
@FlowPreview
class DashboardFragment :
@@ -64,9 +66,6 @@ class DashboardFragment :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
lifecycleScope.launchWhenStarted {
- viewModel.dashboardFeature.takeView(this, this@DashboardFragment)
- }
- lifecycleScope.launchWhenStarted {
viewModel.dashboardFeature.singleEvents.collect { event ->
when (event) {
is DashboardFeature.SingleEvent.NavigateToLocationSingleEvent -> {
@@ -129,17 +128,26 @@ class DashboardFragment :
}
}
+ private var updateUIJob: Job? = null
override fun onResume() {
super.onResume()
+ updateUIJob = lifecycleScope.launch {
+ viewModel.dashboardFeature.takeView(this, this@DashboardFragment)
+ }
+
viewModel.submitAction(DashboardFeature.Action.FetchStatistics)
}
+ override fun onPause() {
+ super.onPause()
+ updateUIJob?.cancel()
+ }
+
override fun getTitle(): String {
return getString(R.string.dashboard_title)
}
override fun render(state: State) {
-
binding.stateLabel.text = getString(
if (state.isQuickPrivacyEnabled) R.string.dashboard_state_title_on
else R.string.dashboard_state_title_off