Loading app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +3 −20 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ 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.FragmentApplicationListBinding import foundation.e.apps.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Status Loading @@ -52,7 +51,8 @@ import kotlinx.coroutines.launch import javax.inject.Inject @AndroidEntryPoint class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_list), class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_list), FusedAPIInterface { private val args: ApplicationListFragmentArgs by navArgs() Loading Loading @@ -162,7 +162,7 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li onTimeout() } else { val currentList = listAdapter?.currentList if (it.data != null && !currentList.isNullOrEmpty() && !compareOldFusedAppsListWithNewFusedAppsList( if (it.data != null && !currentList.isNullOrEmpty() && !viewModel.hasAnyChangeBetweenOldFusedAppsListAndNewFusedAppsList( it.data!!, currentList ) Loading Loading @@ -266,23 +266,6 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li } } /** * @return returns true if there is changes in data, otherwise false */ fun compareOldFusedAppsListWithNewFusedAppsList( newFusedApps: List<FusedApp>, oldFusedApps: List<FusedApp> ): Boolean { val fusedAppDiffUtil = HomeChildFusedAppDiffUtil() newFusedApps.forEach { val indexOfNewFusedApp = newFusedApps.indexOf(it) if (!fusedAppDiffUtil.areContentsTheSame(it, oldFusedApps[indexOfNewFusedApp])) { return true } } return false } private fun showLoadingUI() { binding.shimmerLayout.startShimmer() binding.shimmerLayout.visibility = View.VISIBLE Loading app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt +23 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.api.ResultSupreme import foundation.e.apps.api.fused.FusedAPIRepository import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.utils.enums.Origin import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading Loading @@ -76,7 +77,7 @@ class ApplicationListViewModel @Inject constructor( private var hasNextStreamCluster = false fun getList(category: String, browseUrl: String, authData: AuthData, source: String) { if (appListLiveData.value?.data?.isNotEmpty() == true || isLoading) { if (isLoading) { return } viewModelScope.launch(Dispatchers.IO) { Loading @@ -97,6 +98,27 @@ class ApplicationListViewModel @Inject constructor( } } /** * @return returns true if there is changes in data, otherwise false */ fun hasAnyChangeBetweenOldFusedAppsListAndNewFusedAppsList( newFusedApps: List<FusedApp>, oldFusedApps: List<FusedApp> ): Boolean { val fusedAppDiffUtil = HomeChildFusedAppDiffUtil() if (newFusedApps.size != oldFusedApps.size) { return true } newFusedApps.forEach { val indexOfNewFusedApp = newFusedApps.indexOf(it) if (!fusedAppDiffUtil.areContentsTheSame(it, oldFusedApps[indexOfNewFusedApp])) { return true } } return false } /** * Add a placeholder app at the end if more data can be loaded. * "Placeholder" app shows a simple progress bar in the RecyclerView, indicating that Loading app/src/main/java/foundation/e/apps/home/HomeFragment.kt +1 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.api.fused.data.FusedHome import foundation.e.apps.application.subFrags.ApplicationDialogFragment import foundation.e.apps.databinding.FragmentHomeBinding import foundation.e.apps.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.home.model.HomeChildRVAdapter import foundation.e.apps.home.model.HomeParentRVAdapter import foundation.e.apps.manager.download.data.DownloadProgress Loading @@ -51,7 +50,6 @@ import foundation.e.apps.utils.modules.CommonUtilsModule.safeNavigate import foundation.e.apps.utils.modules.PWAManagerModule import foundation.e.apps.utils.parentFragment.TimeoutFragment import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint Loading Loading @@ -165,7 +163,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface homeViewModel.homeScreenData.observe(viewLifecycleOwner) { stopLoadingUI() if (it.second == ResultStatus.OK) { if (homeParentRVAdapter?.currentList?.isNotEmpty() == true && !homeViewModel.compareNewHomeDataWithOldHomeData( if (homeParentRVAdapter?.currentList?.isNotEmpty() == true && !homeViewModel.hasAnyChangeBetweenNewHomeDataAndOldHomeData( it.first, homeParentRVAdapter?.currentList as List<FusedHome> ) Loading app/src/main/java/foundation/e/apps/home/HomeViewModel.kt +8 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,17 @@ class HomeViewModel @Inject constructor( } ?: true } fun compareNewHomeDataWithOldHomeData( /** * @return true, if any change is found, otherwise false */ fun hasAnyChangeBetweenNewHomeDataAndOldHomeData( newHomeData: List<FusedHome>, oldHomeData: List<FusedHome> ): Boolean { if (newHomeData.size != oldHomeData.size) { return true } oldHomeData.forEach { val fusedHome = newHomeData[oldHomeData.indexOf(it)] if (!it.title.contentEquals(fusedHome.title) || !areOldAndNewFusedAppListSame(it, fusedHome)) { Loading app/src/main/java/foundation/e/apps/search/SearchFragment.kt +4 −25 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ 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.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Status Loading Loading @@ -167,7 +166,7 @@ class SearchFragment : noAppsFoundLayout?.visibility = View.VISIBLE } else { val currentList = listAdapter?.currentList if (it.data?.first != null && !currentList.isNullOrEmpty() && !compareOldFusedAppsListWithNewFusedAppsList( if (it.data?.first != null && !currentList.isNullOrEmpty() && !searchViewModel.hasAnyChangeBetweenOldFusedAppsListAndNewFusedAppsList( it.data?.first!!, currentList ) Loading Loading @@ -212,27 +211,6 @@ class SearchFragment : } } /** * @return returns true if there is changes in data, otherwise false */ fun compareOldFusedAppsListWithNewFusedAppsList( newFusedApps: List<FusedApp>, oldFusedApps: List<FusedApp> ): Boolean { val fusedAppDiffUtil = HomeChildFusedAppDiffUtil() if (newFusedApps.size != oldFusedApps.size) { return true } newFusedApps.forEach { val indexOfNewFusedApp = newFusedApps.indexOf(it) if (!fusedAppDiffUtil.areContentsTheSame(it, oldFusedApps[indexOfNewFusedApp])) { return true } } return false } private fun observeDownloadList(applicationListRVAdapter: ApplicationListRVAdapter) { mainActivityViewModel.downloadList.observe(viewLifecycleOwner) { list -> val searchList = Loading Loading @@ -267,7 +245,7 @@ class SearchFragment : override fun refreshData(authData: AuthData) { showLoadingUI() searchViewModel.getSearchResults(searchText, authData, this) searchViewModel.getSearchResults(searchText, authData, viewLifecycleOwner) } private fun showLoadingUI() { Loading Loading @@ -366,6 +344,7 @@ class SearchFragment : _binding = null searchView = null shimmerLayout = null recyclerView?.adapter = null recyclerView = null searchHintLayout = null noAppsFoundLayout = null Loading Loading
app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +3 −20 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ 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.FragmentApplicationListBinding import foundation.e.apps.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Status Loading @@ -52,7 +51,8 @@ import kotlinx.coroutines.launch import javax.inject.Inject @AndroidEntryPoint class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_list), class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_list), FusedAPIInterface { private val args: ApplicationListFragmentArgs by navArgs() Loading Loading @@ -162,7 +162,7 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li onTimeout() } else { val currentList = listAdapter?.currentList if (it.data != null && !currentList.isNullOrEmpty() && !compareOldFusedAppsListWithNewFusedAppsList( if (it.data != null && !currentList.isNullOrEmpty() && !viewModel.hasAnyChangeBetweenOldFusedAppsListAndNewFusedAppsList( it.data!!, currentList ) Loading Loading @@ -266,23 +266,6 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li } } /** * @return returns true if there is changes in data, otherwise false */ fun compareOldFusedAppsListWithNewFusedAppsList( newFusedApps: List<FusedApp>, oldFusedApps: List<FusedApp> ): Boolean { val fusedAppDiffUtil = HomeChildFusedAppDiffUtil() newFusedApps.forEach { val indexOfNewFusedApp = newFusedApps.indexOf(it) if (!fusedAppDiffUtil.areContentsTheSame(it, oldFusedApps[indexOfNewFusedApp])) { return true } } return false } private fun showLoadingUI() { binding.shimmerLayout.startShimmer() binding.shimmerLayout.visibility = View.VISIBLE Loading
app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt +23 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.api.ResultSupreme import foundation.e.apps.api.fused.FusedAPIRepository import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.utils.enums.Origin import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading Loading @@ -76,7 +77,7 @@ class ApplicationListViewModel @Inject constructor( private var hasNextStreamCluster = false fun getList(category: String, browseUrl: String, authData: AuthData, source: String) { if (appListLiveData.value?.data?.isNotEmpty() == true || isLoading) { if (isLoading) { return } viewModelScope.launch(Dispatchers.IO) { Loading @@ -97,6 +98,27 @@ class ApplicationListViewModel @Inject constructor( } } /** * @return returns true if there is changes in data, otherwise false */ fun hasAnyChangeBetweenOldFusedAppsListAndNewFusedAppsList( newFusedApps: List<FusedApp>, oldFusedApps: List<FusedApp> ): Boolean { val fusedAppDiffUtil = HomeChildFusedAppDiffUtil() if (newFusedApps.size != oldFusedApps.size) { return true } newFusedApps.forEach { val indexOfNewFusedApp = newFusedApps.indexOf(it) if (!fusedAppDiffUtil.areContentsTheSame(it, oldFusedApps[indexOfNewFusedApp])) { return true } } return false } /** * Add a placeholder app at the end if more data can be loaded. * "Placeholder" app shows a simple progress bar in the RecyclerView, indicating that Loading
app/src/main/java/foundation/e/apps/home/HomeFragment.kt +1 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.api.fused.data.FusedHome import foundation.e.apps.application.subFrags.ApplicationDialogFragment import foundation.e.apps.databinding.FragmentHomeBinding import foundation.e.apps.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.home.model.HomeChildRVAdapter import foundation.e.apps.home.model.HomeParentRVAdapter import foundation.e.apps.manager.download.data.DownloadProgress Loading @@ -51,7 +50,6 @@ import foundation.e.apps.utils.modules.CommonUtilsModule.safeNavigate import foundation.e.apps.utils.modules.PWAManagerModule import foundation.e.apps.utils.parentFragment.TimeoutFragment import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint Loading Loading @@ -165,7 +163,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface homeViewModel.homeScreenData.observe(viewLifecycleOwner) { stopLoadingUI() if (it.second == ResultStatus.OK) { if (homeParentRVAdapter?.currentList?.isNotEmpty() == true && !homeViewModel.compareNewHomeDataWithOldHomeData( if (homeParentRVAdapter?.currentList?.isNotEmpty() == true && !homeViewModel.hasAnyChangeBetweenNewHomeDataAndOldHomeData( it.first, homeParentRVAdapter?.currentList as List<FusedHome> ) Loading
app/src/main/java/foundation/e/apps/home/HomeViewModel.kt +8 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,17 @@ class HomeViewModel @Inject constructor( } ?: true } fun compareNewHomeDataWithOldHomeData( /** * @return true, if any change is found, otherwise false */ fun hasAnyChangeBetweenNewHomeDataAndOldHomeData( newHomeData: List<FusedHome>, oldHomeData: List<FusedHome> ): Boolean { if (newHomeData.size != oldHomeData.size) { return true } oldHomeData.forEach { val fusedHome = newHomeData[oldHomeData.indexOf(it)] if (!it.title.contentEquals(fusedHome.title) || !areOldAndNewFusedAppListSame(it, fusedHome)) { Loading
app/src/main/java/foundation/e/apps/search/SearchFragment.kt +4 −25 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ 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.home.model.HomeChildFusedAppDiffUtil import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Status Loading Loading @@ -167,7 +166,7 @@ class SearchFragment : noAppsFoundLayout?.visibility = View.VISIBLE } else { val currentList = listAdapter?.currentList if (it.data?.first != null && !currentList.isNullOrEmpty() && !compareOldFusedAppsListWithNewFusedAppsList( if (it.data?.first != null && !currentList.isNullOrEmpty() && !searchViewModel.hasAnyChangeBetweenOldFusedAppsListAndNewFusedAppsList( it.data?.first!!, currentList ) Loading Loading @@ -212,27 +211,6 @@ class SearchFragment : } } /** * @return returns true if there is changes in data, otherwise false */ fun compareOldFusedAppsListWithNewFusedAppsList( newFusedApps: List<FusedApp>, oldFusedApps: List<FusedApp> ): Boolean { val fusedAppDiffUtil = HomeChildFusedAppDiffUtil() if (newFusedApps.size != oldFusedApps.size) { return true } newFusedApps.forEach { val indexOfNewFusedApp = newFusedApps.indexOf(it) if (!fusedAppDiffUtil.areContentsTheSame(it, oldFusedApps[indexOfNewFusedApp])) { return true } } return false } private fun observeDownloadList(applicationListRVAdapter: ApplicationListRVAdapter) { mainActivityViewModel.downloadList.observe(viewLifecycleOwner) { list -> val searchList = Loading Loading @@ -267,7 +245,7 @@ class SearchFragment : override fun refreshData(authData: AuthData) { showLoadingUI() searchViewModel.getSearchResults(searchText, authData, this) searchViewModel.getSearchResults(searchText, authData, viewLifecycleOwner) } private fun showLoadingUI() { Loading Loading @@ -366,6 +344,7 @@ class SearchFragment : _binding = null searchView = null shimmerLayout = null recyclerView?.adapter = null recyclerView = null searchHintLayout = null noAppsFoundLayout = null Loading