Loading app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +6 −4 Original line number Diff line number Diff line Loading @@ -186,12 +186,14 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } override fun loadData(authObjectList: List<AuthObject>) { if (homeViewModel.haveSourcesChanged()) { showLoadingUI() homeViewModel.loadData(authObjectList, viewLifecycleOwner) { _ -> clearAndRestartGPlayLogin() true } } } override fun showLoadingUI() { binding.shimmerLayout.startShimmer() Loading app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +20 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.CleanApkException import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch Loading @@ -41,6 +42,8 @@ class HomeViewModel @Inject constructor( private val applicationRepository: ApplicationRepository, ) : LoadingViewModel() { @Inject lateinit var appLoungePreference: AppLoungePreference /* * Hold list of applications, as well as application source type. Loading @@ -52,6 +55,8 @@ class HomeViewModel @Inject constructor( var currentHomes: List<Home>? = null private var previousSources = emptyList<Boolean>() fun loadData( authObjectList: List<AuthObject>, lifecycleOwner: LifecycleOwner, Loading @@ -71,6 +76,21 @@ class HomeViewModel @Inject constructor( }, retryBlock) } fun haveSourcesChanged(): Boolean { val sources = listOf( appLoungePreference.isGplaySelected(), appLoungePreference.isOpenSourceSelected(), appLoungePreference.isPWASelected() ) if (sources == previousSources) { return false } previousSources = sources return true } fun getHomeScreenData( authData: AuthData, lifecycleOwner: LifecycleOwner, Loading Loading @@ -109,8 +129,6 @@ class HomeViewModel @Inject constructor( currentHomes = homeResult.data?.map { it.copy() } return } homeScreenData.value = ResultSupreme.Error("No change is found in homepage") } private fun shouldUpdateResult(homeResult: ResultSupreme<List<Home>>) = Loading Loading
app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +6 −4 Original line number Diff line number Diff line Loading @@ -186,12 +186,14 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } override fun loadData(authObjectList: List<AuthObject>) { if (homeViewModel.haveSourcesChanged()) { showLoadingUI() homeViewModel.loadData(authObjectList, viewLifecycleOwner) { _ -> clearAndRestartGPlayLogin() true } } } override fun showLoadingUI() { binding.shimmerLayout.startShimmer() Loading
app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +20 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.CleanApkException import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch Loading @@ -41,6 +42,8 @@ class HomeViewModel @Inject constructor( private val applicationRepository: ApplicationRepository, ) : LoadingViewModel() { @Inject lateinit var appLoungePreference: AppLoungePreference /* * Hold list of applications, as well as application source type. Loading @@ -52,6 +55,8 @@ class HomeViewModel @Inject constructor( var currentHomes: List<Home>? = null private var previousSources = emptyList<Boolean>() fun loadData( authObjectList: List<AuthObject>, lifecycleOwner: LifecycleOwner, Loading @@ -71,6 +76,21 @@ class HomeViewModel @Inject constructor( }, retryBlock) } fun haveSourcesChanged(): Boolean { val sources = listOf( appLoungePreference.isGplaySelected(), appLoungePreference.isOpenSourceSelected(), appLoungePreference.isPWASelected() ) if (sources == previousSources) { return false } previousSources = sources return true } fun getHomeScreenData( authData: AuthData, lifecycleOwner: LifecycleOwner, Loading Loading @@ -109,8 +129,6 @@ class HomeViewModel @Inject constructor( currentHomes = homeResult.data?.map { it.copy() } return } homeScreenData.value = ResultSupreme.Error("No change is found in homepage") } private fun shouldUpdateResult(homeResult: ResultSupreme<List<Home>>) = Loading