mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixed irrelevant network call
This commit is contained in:
parent
33897bbdc0
commit
91affcf63e
3 changed files with 6 additions and 17 deletions
|
|
@ -47,6 +47,7 @@ class ContributionBoundaryCallback @Inject constructor(
|
|||
* fetched from the network
|
||||
*/
|
||||
override fun onItemAtEndLoaded(itemAtEnd: Contribution) {
|
||||
Timber.tag("PRINT").e("fetching2")
|
||||
fetchContributions()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue