For #14543 - Prevents IllegalStateException by not moving to another thread

pull/90/head
Jeff Boek 4 years ago
parent 4de80a0493
commit 66ecc15b40

@ -15,11 +15,14 @@ import kotlinx.android.synthetic.main.fragment_delete_browsing_data.*
import kotlinx.android.synthetic.main.fragment_delete_browsing_data.view.* import kotlinx.android.synthetic.main.fragment_delete_browsing_data.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import mozilla.components.lib.state.ext.flowScoped import mozilla.components.lib.state.ext.flowScoped
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
import org.mozilla.fenix.R import org.mozilla.fenix.R
@ -139,7 +142,7 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
private fun deleteSelected() { private fun deleteSelected() {
startDeletion() startDeletion()
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) { viewLifecycleOwner.lifecycleScope.launch(IO) {
getCheckboxes().mapIndexed { i, v -> getCheckboxes().mapIndexed { i, v ->
if (v.isChecked) { if (v.isChecked) {
when (i) { when (i) {
@ -152,7 +155,7 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
} }
} }
launch(Dispatchers.Main) { withContext(Main) {
finishDeletion() finishDeletion()
requireComponents.analytics.metrics.track(Event.ClearedPrivateData) requireComponents.analytics.metrics.track(Event.ClearedPrivateData)
} }

Loading…
Cancel
Save