summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation/e
diff options
context:
space:
mode:
authorGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2022-03-23 21:23:31 +0000
committerGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2022-03-23 21:23:31 +0000
commit4d00377e9e20a781d8719e7b1b68a200809a4019 (patch)
treea29eeb95467957a04e81560dbad7acaeb20aa292 /app/src/main/java/foundation/e
parent82a45020557916da2a133df297eafc92f9f7c3db (diff)
parent1dc975428dfbb46f987687c6fb7ef47a101ffe70 (diff)
Merge branch 'fix_dashboard_not_resumed' into 'main'
Fix dashboard not refreshed on restart app See merge request e/privacy-central/privacycentralapp!30
Diffstat (limited to 'app/src/main/java/foundation/e')
-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