Loading app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +5 −2 Original line number Diff line number Diff line Loading @@ -277,8 +277,6 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { if (appInfoFetchViewModel.isAppInBlockedList(it)) { binding.snackbarLayout.visibility = View.VISIBLE } observeDownloadStatus(view) fetchAppTracker(it) } Loading Loading @@ -373,6 +371,11 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } } override fun onResume() { super.onResume() observeDownloadStatus(binding.root) } private fun handleInstallingIssue( installButton: MaterialButton, fusedApp: FusedApp, Loading app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +4 −4 Original line number Diff line number Diff line Loading @@ -150,10 +150,6 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li layoutManager = LinearLayoutManager(view?.context) } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingItems(recyclerView, it) } viewModel.appListLiveData.observe(viewLifecycleOwner) { listAdapter?.setData(it.first) if (!isDownloadObserverAdded) { Loading Loading @@ -226,6 +222,10 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li } }) } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingItems(binding.recyclerView, it) } } private fun showLoadingUI() { Loading app/src/main/java/foundation/e/apps/home/HomeFragment.kt +5 −5 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import javax.inject.Inject @AndroidEntryPoint class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface { private lateinit var homeParentRVAdapter: HomeParentRVAdapter private var _binding: FragmentHomeBinding? = null private val binding get() = _binding!! Loading Loading @@ -126,7 +127,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface refreshDataOrRefreshToken(mainActivityViewModel) } val homeParentRVAdapter = HomeParentRVAdapter( homeParentRVAdapter = HomeParentRVAdapter( this, pkgManagerModule, pwaManagerModule, Loading Loading @@ -160,10 +161,6 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface onTimeout() } } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it) } } override fun onTimeout() { Loading Loading @@ -259,6 +256,9 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface super.onResume() resetTimeoutDialogLock() binding.shimmerLayout.startShimmer() appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it) } } override fun onPause() { Loading app/src/main/java/foundation/e/apps/manager/download/data/DownloadProgressLD.kt +3 −5 Original line number Diff line number Diff line Loading @@ -31,12 +31,11 @@ class DownloadProgressLD @Inject constructor( override fun observe(owner: LifecycleOwner, observer: Observer<in DownloadProgress>) { job = Job() super.observe(owner, observer) } override fun onActive() { super.onActive() val hasActiveObservers = hasActiveObservers() launch { while (isActive) { while (hasActiveObservers) { val downloads = fusedManagerRepository.getDownloadList() val downloadingList = downloads.map { it.downloadIdMap }.filter { it.values.contains(false) } Loading Loading @@ -80,7 +79,6 @@ class DownloadProgressLD @Inject constructor( } if (downloadingIds.isEmpty()) { clearDownload() cancel() } cursor.moveToNext() Loading app/src/main/java/foundation/e/apps/search/SearchFragment.kt +27 −21 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.application.subFrags.ApplicationDialogFragment import foundation.e.apps.applicationlist.model.ApplicationListRVAdapter import foundation.e.apps.databinding.FragmentSearchBinding import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.ResultStatus import foundation.e.apps.utils.enums.Status Loading Loading @@ -159,28 +160,9 @@ class SearchFragment : layoutManager = LinearLayoutManager(view.context) } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { val adapter = recyclerView?.adapter as ApplicationListRVAdapter lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress = appProgressViewModel.calculateProgress(fusedApp, it) val downloadProgress = ((progress.second / progress.first.toDouble()) * 100).toInt() val viewHolder = recyclerView?.findViewHolderForAdapterPosition( adapter.currentList.indexOf(fusedApp) ) viewHolder?.let { (viewHolder as ApplicationListRVAdapter.ViewHolder).binding.installButton.text = "$downloadProgress%" } } } } } mainActivityViewModel.downloadList.observe(viewLifecycleOwner) { list -> val searchList = searchViewModel.searchResult.value?.first?.toMutableList() ?: emptyList() val searchList = searchViewModel.searchResult.value?.first?.toMutableList() ?: emptyList() searchList.let { mainActivityViewModel.updateStatusOfFusedApps(searchList, list) } Loading Loading @@ -269,10 +251,34 @@ class SearchFragment : binding.recyclerView.visibility = View.VISIBLE } private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { val adapter = recyclerView?.adapter as ApplicationListRVAdapter lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress = appProgressViewModel.calculateProgress(fusedApp, downloadProgress) val downloadProgress = ((progress.second / progress.first.toDouble()) * 100).toInt() val viewHolder = recyclerView?.findViewHolderForAdapterPosition( adapter.currentList.indexOf(fusedApp) ) viewHolder?.let { (viewHolder as ApplicationListRVAdapter.ViewHolder).binding.installButton.text = "$downloadProgress%" } } } } } override fun onResume() { super.onResume() resetTimeoutDialogLock() binding.shimmerLayout.startShimmer() appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfInstallingApps(it) } } override fun onPause() { Loading Loading
app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +5 −2 Original line number Diff line number Diff line Loading @@ -277,8 +277,6 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { if (appInfoFetchViewModel.isAppInBlockedList(it)) { binding.snackbarLayout.visibility = View.VISIBLE } observeDownloadStatus(view) fetchAppTracker(it) } Loading Loading @@ -373,6 +371,11 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } } override fun onResume() { super.onResume() observeDownloadStatus(binding.root) } private fun handleInstallingIssue( installButton: MaterialButton, fusedApp: FusedApp, Loading
app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +4 −4 Original line number Diff line number Diff line Loading @@ -150,10 +150,6 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li layoutManager = LinearLayoutManager(view?.context) } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingItems(recyclerView, it) } viewModel.appListLiveData.observe(viewLifecycleOwner) { listAdapter?.setData(it.first) if (!isDownloadObserverAdded) { Loading Loading @@ -226,6 +222,10 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li } }) } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingItems(binding.recyclerView, it) } } private fun showLoadingUI() { Loading
app/src/main/java/foundation/e/apps/home/HomeFragment.kt +5 −5 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import javax.inject.Inject @AndroidEntryPoint class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface { private lateinit var homeParentRVAdapter: HomeParentRVAdapter private var _binding: FragmentHomeBinding? = null private val binding get() = _binding!! Loading Loading @@ -126,7 +127,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface refreshDataOrRefreshToken(mainActivityViewModel) } val homeParentRVAdapter = HomeParentRVAdapter( homeParentRVAdapter = HomeParentRVAdapter( this, pkgManagerModule, pwaManagerModule, Loading Loading @@ -160,10 +161,6 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface onTimeout() } } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it) } } override fun onTimeout() { Loading Loading @@ -259,6 +256,9 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface super.onResume() resetTimeoutDialogLock() binding.shimmerLayout.startShimmer() appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it) } } override fun onPause() { Loading
app/src/main/java/foundation/e/apps/manager/download/data/DownloadProgressLD.kt +3 −5 Original line number Diff line number Diff line Loading @@ -31,12 +31,11 @@ class DownloadProgressLD @Inject constructor( override fun observe(owner: LifecycleOwner, observer: Observer<in DownloadProgress>) { job = Job() super.observe(owner, observer) } override fun onActive() { super.onActive() val hasActiveObservers = hasActiveObservers() launch { while (isActive) { while (hasActiveObservers) { val downloads = fusedManagerRepository.getDownloadList() val downloadingList = downloads.map { it.downloadIdMap }.filter { it.values.contains(false) } Loading Loading @@ -80,7 +79,6 @@ class DownloadProgressLD @Inject constructor( } if (downloadingIds.isEmpty()) { clearDownload() cancel() } cursor.moveToNext() Loading
app/src/main/java/foundation/e/apps/search/SearchFragment.kt +27 −21 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.application.subFrags.ApplicationDialogFragment import foundation.e.apps.applicationlist.model.ApplicationListRVAdapter import foundation.e.apps.databinding.FragmentSearchBinding import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.ResultStatus import foundation.e.apps.utils.enums.Status Loading Loading @@ -159,28 +160,9 @@ class SearchFragment : layoutManager = LinearLayoutManager(view.context) } appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { val adapter = recyclerView?.adapter as ApplicationListRVAdapter lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress = appProgressViewModel.calculateProgress(fusedApp, it) val downloadProgress = ((progress.second / progress.first.toDouble()) * 100).toInt() val viewHolder = recyclerView?.findViewHolderForAdapterPosition( adapter.currentList.indexOf(fusedApp) ) viewHolder?.let { (viewHolder as ApplicationListRVAdapter.ViewHolder).binding.installButton.text = "$downloadProgress%" } } } } } mainActivityViewModel.downloadList.observe(viewLifecycleOwner) { list -> val searchList = searchViewModel.searchResult.value?.first?.toMutableList() ?: emptyList() val searchList = searchViewModel.searchResult.value?.first?.toMutableList() ?: emptyList() searchList.let { mainActivityViewModel.updateStatusOfFusedApps(searchList, list) } Loading Loading @@ -269,10 +251,34 @@ class SearchFragment : binding.recyclerView.visibility = View.VISIBLE } private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { val adapter = recyclerView?.adapter as ApplicationListRVAdapter lifecycleScope.launch { adapter.currentList.forEach { fusedApp -> if (fusedApp.status == Status.DOWNLOADING) { val progress = appProgressViewModel.calculateProgress(fusedApp, downloadProgress) val downloadProgress = ((progress.second / progress.first.toDouble()) * 100).toInt() val viewHolder = recyclerView?.findViewHolderForAdapterPosition( adapter.currentList.indexOf(fusedApp) ) viewHolder?.let { (viewHolder as ApplicationListRVAdapter.ViewHolder).binding.installButton.text = "$downloadProgress%" } } } } } override fun onResume() { super.onResume() resetTimeoutDialogLock() binding.shimmerLayout.startShimmer() appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) { updateProgressOfInstallingApps(it) } } override fun onPause() { Loading