Fixed irrelevant network call

This commit is contained in:
Kanahia 2024-07-16 14:10:18 +05:30
parent 33897bbdc0
commit 91affcf63e
3 changed files with 6 additions and 17 deletions

View file

@ -47,6 +47,7 @@ class ContributionBoundaryCallback @Inject constructor(
* fetched from the network
*/
override fun onItemAtEndLoaded(itemAtEnd: Contribution) {
Timber.tag("PRINT").e("fetching2")
fetchContributions()
}

View file

@ -214,12 +214,12 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
contributionsListPresenter.setup(userName,
Objects.equals(sessionManager.getUserName(), userName));
contributionsListPresenter.getPendingContributions(userName);
contributionsListPresenter.getPendingContributions();
contributionsListPresenter.pendingContributionList.observe(getViewLifecycleOwner(), list -> {
pendingUploadsCount = list.size();
callback.updatePendingIcon(pendingUploadsCount);
});
contributionsListPresenter.getFailedContributions(userName);
contributionsListPresenter.getFailedContributions();
contributionsListPresenter.failedContributionList.observe(getViewLifecycleOwner(), list -> {
uploadErrorCount = list.size();
callback.updateErrorIcon(uploadErrorCount);

View file

@ -95,44 +95,32 @@ public class ContributionsListPresenter implements UserActionListener {
contributionBoundaryCallback.dispose();
}
void getPendingContributions(String userName) {
void getPendingContributions() {
final PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setPrefetchDistance(50)
.setPageSize(10).build();
Factory<Integer, Contribution> factory;
boolean shouldSetBoundaryCallback;
contributionBoundaryCallback.setUserName(userName);
shouldSetBoundaryCallback = true;
factory = repository.fetchContributionsWithStates(
Arrays.asList(Contribution.STATE_IN_PROGRESS, Contribution.STATE_QUEUED,
Contribution.STATE_PAUSED));
LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory,
pagedListConfig);
if (shouldSetBoundaryCallback) {
livePagedListBuilder.setBoundaryCallback(contributionBoundaryCallback);
}
pendingContributionList = livePagedListBuilder.build();
}
void getFailedContributions(String userName) {
void getFailedContributions() {
final PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setPrefetchDistance(50)
.setPageSize(10).build();
Factory<Integer, Contribution> factory;
boolean shouldSetBoundaryCallback;
contributionBoundaryCallback.setUserName(userName);
shouldSetBoundaryCallback = true;
factory = repository.fetchContributionsWithStates(
Collections.singletonList(Contribution.STATE_FAILED));
LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory,
pagedListConfig);
if (shouldSetBoundaryCallback) {
livePagedListBuilder.setBoundaryCallback(contributionBoundaryCallback);
}
failedContributionList = livePagedListBuilder.build();
}