Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d384639 authored by Hasib Prince's avatar Hasib Prince
Browse files

fix: lifecycleScope of the coroutine

parent 613aa033
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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)
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -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 =
+1 −1
Original line number Diff line number Diff line
@@ -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)
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -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 =
+7 −3
Original line number Diff line number Diff line
@@ -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,11 +175,13 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI
        WorkManager.getInstance(requireContext())
            .getWorkInfosForUniqueWorkLiveData(INSTALL_WORK_NAME)
            .observe(viewLifecycleOwner) { workInfoList ->
                lifecycleScope.launchWhenResumed {
                viewLifecycleOwner.lifecycleScope.launch {
                    repeatOnLifecycle(Lifecycle.State.RESUMED) {
                        binding.button.isEnabled = shouldUpdateButtonEnable(workInfoList)
                    }
                }
            }
    }

    private fun shouldUpdateButtonEnable(workInfoList: MutableList<WorkInfo>) =
        !updatesViewModel.updatesList.value?.first.isNullOrEmpty() &&
@@ -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 =