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 3ff38c4f0a349b5f81313fda8dd818546b84e533..11685cc0918094d95cf64b2a309b4a62bc567a41 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 @@ -186,7 +186,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } override fun loadData(authObjectList: List) { - if (homeViewModel.haveSourcesChanged()) { + if (shouldLoadData()) { showLoadingUI() homeViewModel.loadData(authObjectList, viewLifecycleOwner) { _ -> clearAndRestartGPlayLogin() @@ -195,6 +195,8 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } } + private fun shouldLoadData() = homeViewModel.haveSourcesChanged() || !homeViewModel.hasData() + override fun showLoadingUI() { binding.shimmerLayout.startShimmer() binding.shimmerLayout.visibility = View.VISIBLE diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index 30ecfb9bdd16241121af253c2f44b2e5c42c965d..861527a7379b5d5a800fc978a9bc93a931a4d893 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -57,6 +57,10 @@ class HomeViewModel @Inject constructor( private var previousSources = emptyList() + fun hasData(): Boolean { + return homeScreenData.value?.data?.isNotEmpty() ?: false + } + fun loadData( authObjectList: List, lifecycleOwner: LifecycleOwner,