diff --git a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt index 210a4aa1199b004e2de40ee65647947477eeb268..2540de6f306ca78f764948c0f9428efda4003cc0 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt @@ -503,7 +503,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } private fun collectShareVisibilityState() { - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.RESUMED) { applicationViewModel.shareButtonVisibilityState.collectLatest { state -> when (state) { @@ -516,7 +516,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } private fun collectAppContentRatingState() { - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.RESUMED) { applicationViewModel.appContentRatingState .collectLatest(::updateContentRatingUi) @@ -759,7 +759,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB.visibility = View.VISIBLE appSize.visibility = View.GONE applicationViewModel.downloadProgress.observe(viewLifecycleOwner) { - lifecycleScope.launch(Dispatchers.Main) { + viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) { updateProgress(it) } } diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt index 01ecf4c07885e752b06eb3b184dfbf2234b0672c..909c6a89665ffd47323d059e665c4b13dc68e708 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt @@ -307,7 +307,7 @@ class ApplicationListFragment : downloadProgress: DownloadProgress ) { val adapter = recyclerView.adapter as ApplicationListRVAdapter - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress = diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt index e086de665be320f3c643a57a306f110a8f63533d..91ac8ad0ecbb3e775c0119ee75f75c6b2baf2423 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt @@ -227,7 +227,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall downloadProgress: DownloadProgress, childRV: RecyclerView ) { - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { updateDownloadProgressOfAppList(adapter, downloadProgress, childRV) } } diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt index e3db9336cefb9a30f13fa2defd8edf9e6f4c7745..f813834094475c954945873169f8a15c5cf000af 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt @@ -384,7 +384,7 @@ class SearchFragment : private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { val adapter = recyclerView?.adapter as ApplicationListRVAdapter - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress = diff --git a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt index f22b69256ffa5ce458140afddbec29ea6ff5f2d2..9ba5a6fee90445908456bbaa051122858cbb0e5d 100644 --- a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt @@ -23,8 +23,10 @@ import android.view.View import androidx.appcompat.app.AlertDialog import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import androidx.navigation.findNavController import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager @@ -173,8 +175,10 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI WorkManager.getInstance(requireContext()) .getWorkInfosForUniqueWorkLiveData(INSTALL_WORK_NAME) .observe(viewLifecycleOwner) { workInfoList -> - lifecycleScope.launchWhenResumed { - binding.button.isEnabled = shouldUpdateButtonEnable(workInfoList) + viewLifecycleOwner.lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.RESUMED) { + binding.button.isEnabled = shouldUpdateButtonEnable(workInfoList) + } } } } @@ -353,7 +357,7 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI downloadProgress: DownloadProgress ) { val adapter = recyclerView.adapter as ApplicationListRVAdapter - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress =