Loading app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +15 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import foundation.e.apps.ui.MainActivityViewModel import foundation.e.apps.ui.PrivacyInfoViewModel import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment import foundation.e.apps.ui.applicationlist.ApplicationListRVAdapter import foundation.e.apps.utils.isNetworkAvailable import kotlinx.coroutines.launch import javax.inject.Inject Loading @@ -74,7 +75,8 @@ class SearchFragment : private var _binding: FragmentSearchBinding? = null private val binding get() = _binding!! private val searchViewModel: SearchViewModel by viewModels() //To avoid SyntheticAccessor, declared as protected protected val searchViewModel: SearchViewModel by viewModels() private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels() private val appInfoFetchViewModel: AppInfoFetchViewModel by viewModels() private val mainActivityViewModel: MainActivityViewModel by activityViewModels() Loading Loading @@ -126,6 +128,18 @@ class SearchFragment : this.authData = it.authData loadData() } binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) if (!recyclerView.canScrollVertically(1)) { if (!requireContext().isNetworkAvailable()) { return } searchViewModel.loadMore(searchText) } } }) } private fun observeSearchResult(listAdapter: ApplicationListRVAdapter?) { Loading app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +4 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ class SearchViewModel @Inject constructor( isLoading = true val gplaySearchResult = fusedAPIRepository.getGplaySearchResults(query, nextSubBundle) if (!gplaySearchResult.isSuccess()) { EventBus.invokeEvent(AppEvent.DataLoadError(gplaySearchResult)) } val isFirstFetch = nextSubBundle == null nextSubBundle = gplaySearchResult.data?.second Loading Loading
app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +15 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import foundation.e.apps.ui.MainActivityViewModel import foundation.e.apps.ui.PrivacyInfoViewModel import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment import foundation.e.apps.ui.applicationlist.ApplicationListRVAdapter import foundation.e.apps.utils.isNetworkAvailable import kotlinx.coroutines.launch import javax.inject.Inject Loading @@ -74,7 +75,8 @@ class SearchFragment : private var _binding: FragmentSearchBinding? = null private val binding get() = _binding!! private val searchViewModel: SearchViewModel by viewModels() //To avoid SyntheticAccessor, declared as protected protected val searchViewModel: SearchViewModel by viewModels() private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels() private val appInfoFetchViewModel: AppInfoFetchViewModel by viewModels() private val mainActivityViewModel: MainActivityViewModel by activityViewModels() Loading Loading @@ -126,6 +128,18 @@ class SearchFragment : this.authData = it.authData loadData() } binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) if (!recyclerView.canScrollVertically(1)) { if (!requireContext().isNetworkAvailable()) { return } searchViewModel.loadMore(searchText) } } }) } private fun observeSearchResult(listAdapter: ApplicationListRVAdapter?) { Loading
app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +4 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ class SearchViewModel @Inject constructor( isLoading = true val gplaySearchResult = fusedAPIRepository.getGplaySearchResults(query, nextSubBundle) if (!gplaySearchResult.isSuccess()) { EventBus.invokeEvent(AppEvent.DataLoadError(gplaySearchResult)) } val isFirstFetch = nextSubBundle == null nextSubBundle = gplaySearchResult.data?.second Loading