From 0c8bcd39bed288fe5986b6fb20093f7395073a7a Mon Sep 17 00:00:00 2001 From: Colin Lee Date: Mon, 12 Aug 2019 13:02:35 -0500 Subject: [PATCH] For #4652: HomeFragment Crash "Can not.. after onSaveInstanceState" --- app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 054de08488..18c2ecc0e4 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -24,6 +24,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.Observer import androidx.lifecycle.OnLifecycleEvent +import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.FragmentNavigator import androidx.navigation.fragment.NavHostFragment.findNavController @@ -677,7 +678,9 @@ class HomeFragment : Fragment(), AccountObserver { val tabs = getListOfSessions().toTabs() - val viewModel: CreateCollectionViewModel by activityViewModels() + val viewModel: CreateCollectionViewModel by activityViewModels { + ViewModelProvider.NewInstanceFactory() // this is a workaround for #4652 + } viewModel.tabs = tabs val selectedTabs = tabs.find { tab -> tab.sessionId == selectedTabId }