mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +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
|
* fetched from the network
|
||||||
*/
|
*/
|
||||||
override fun onItemAtEndLoaded(itemAtEnd: Contribution) {
|
override fun onItemAtEndLoaded(itemAtEnd: Contribution) {
|
||||||
|
Timber.tag("PRINT").e("fetching2")
|
||||||
fetchContributions()
|
fetchContributions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,12 +214,12 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
||||||
|
|
||||||
contributionsListPresenter.setup(userName,
|
contributionsListPresenter.setup(userName,
|
||||||
Objects.equals(sessionManager.getUserName(), userName));
|
Objects.equals(sessionManager.getUserName(), userName));
|
||||||
contributionsListPresenter.getPendingContributions(userName);
|
contributionsListPresenter.getPendingContributions();
|
||||||
contributionsListPresenter.pendingContributionList.observe(getViewLifecycleOwner(), list -> {
|
contributionsListPresenter.pendingContributionList.observe(getViewLifecycleOwner(), list -> {
|
||||||
pendingUploadsCount = list.size();
|
pendingUploadsCount = list.size();
|
||||||
callback.updatePendingIcon(pendingUploadsCount);
|
callback.updatePendingIcon(pendingUploadsCount);
|
||||||
});
|
});
|
||||||
contributionsListPresenter.getFailedContributions(userName);
|
contributionsListPresenter.getFailedContributions();
|
||||||
contributionsListPresenter.failedContributionList.observe(getViewLifecycleOwner(), list -> {
|
contributionsListPresenter.failedContributionList.observe(getViewLifecycleOwner(), list -> {
|
||||||
uploadErrorCount = list.size();
|
uploadErrorCount = list.size();
|
||||||
callback.updateErrorIcon(uploadErrorCount);
|
callback.updateErrorIcon(uploadErrorCount);
|
||||||
|
|
|
||||||
|
|
@ -95,44 +95,32 @@ public class ContributionsListPresenter implements UserActionListener {
|
||||||
contributionBoundaryCallback.dispose();
|
contributionBoundaryCallback.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void getPendingContributions(String userName) {
|
void getPendingContributions() {
|
||||||
final PagedList.Config pagedListConfig =
|
final PagedList.Config pagedListConfig =
|
||||||
(new PagedList.Config.Builder())
|
(new PagedList.Config.Builder())
|
||||||
.setPrefetchDistance(50)
|
.setPrefetchDistance(50)
|
||||||
.setPageSize(10).build();
|
.setPageSize(10).build();
|
||||||
Factory<Integer, Contribution> factory;
|
Factory<Integer, Contribution> factory;
|
||||||
boolean shouldSetBoundaryCallback;
|
|
||||||
contributionBoundaryCallback.setUserName(userName);
|
|
||||||
shouldSetBoundaryCallback = true;
|
|
||||||
|
|
||||||
factory = repository.fetchContributionsWithStates(
|
factory = repository.fetchContributionsWithStates(
|
||||||
Arrays.asList(Contribution.STATE_IN_PROGRESS, Contribution.STATE_QUEUED,
|
Arrays.asList(Contribution.STATE_IN_PROGRESS, Contribution.STATE_QUEUED,
|
||||||
Contribution.STATE_PAUSED));
|
Contribution.STATE_PAUSED));
|
||||||
|
|
||||||
LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory,
|
LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory,
|
||||||
pagedListConfig);
|
pagedListConfig);
|
||||||
if (shouldSetBoundaryCallback) {
|
|
||||||
livePagedListBuilder.setBoundaryCallback(contributionBoundaryCallback);
|
|
||||||
}
|
|
||||||
pendingContributionList = livePagedListBuilder.build();
|
pendingContributionList = livePagedListBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
void getFailedContributions(String userName) {
|
void getFailedContributions() {
|
||||||
final PagedList.Config pagedListConfig =
|
final PagedList.Config pagedListConfig =
|
||||||
(new PagedList.Config.Builder())
|
(new PagedList.Config.Builder())
|
||||||
.setPrefetchDistance(50)
|
.setPrefetchDistance(50)
|
||||||
.setPageSize(10).build();
|
.setPageSize(10).build();
|
||||||
Factory<Integer, Contribution> factory;
|
Factory<Integer, Contribution> factory;
|
||||||
boolean shouldSetBoundaryCallback;
|
|
||||||
contributionBoundaryCallback.setUserName(userName);
|
|
||||||
shouldSetBoundaryCallback = true;
|
|
||||||
factory = repository.fetchContributionsWithStates(
|
factory = repository.fetchContributionsWithStates(
|
||||||
Collections.singletonList(Contribution.STATE_FAILED));
|
Collections.singletonList(Contribution.STATE_FAILED));
|
||||||
|
|
||||||
LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory,
|
LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory,
|
||||||
pagedListConfig);
|
pagedListConfig);
|
||||||
if (shouldSetBoundaryCallback) {
|
|
||||||
livePagedListBuilder.setBoundaryCallback(contributionBoundaryCallback);
|
|
||||||
}
|
|
||||||
failedContributionList = livePagedListBuilder.build();
|
failedContributionList = livePagedListBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue