From 45ca30e0eccc15f9419b5dba2c8e09a4d8943562 Mon Sep 17 00:00:00 2001 From: Fs00 Date: Tue, 12 Oct 2021 14:01:12 +0200 Subject: [PATCH] Parallelize PR and review loading requests --- .../java/com/gh4a/activities/PullRequestActivity.java | 11 +++++++---- .../main/java/com/gh4a/fragment/ReviewFragment.java | 7 ++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/gh4a/activities/PullRequestActivity.java b/app/src/main/java/com/gh4a/activities/PullRequestActivity.java index 759a7575f..c61c41444 100644 --- a/app/src/main/java/com/gh4a/activities/PullRequestActivity.java +++ b/app/src/main/java/com/gh4a/activities/PullRequestActivity.java @@ -80,6 +80,7 @@ import java.util.Locale; import io.reactivex.Single; +import io.reactivex.schedulers.Schedulers; public class PullRequestActivity extends BaseFragmentPagerActivity implements View.OnClickListener, ConfirmationDialogFragment.Callback, @@ -497,11 +498,13 @@ private void load(boolean force) { IssueService issueService = ServiceFactory.get(IssueService.class, force); Single prSingle = prService.getPullRequest(mRepoOwner, mRepoName, mPullRequestNumber) - .map(ApiHelpers::throwOnFailure); + .map(ApiHelpers::throwOnFailure) + .subscribeOn(Schedulers.io()); Single issueSingle = issueService.getIssue(mRepoOwner, mRepoName, mPullRequestNumber) - .map(ApiHelpers::throwOnFailure); - Single isCollaboratorSingle = - SingleFactory.isAppUserRepoCollaborator(mRepoOwner, mRepoName, force); + .map(ApiHelpers::throwOnFailure) + .subscribeOn(Schedulers.io()); + Single isCollaboratorSingle = SingleFactory.isAppUserRepoCollaborator(mRepoOwner, mRepoName, force) + .subscribeOn(Schedulers.io()); Single.zip(issueSingle, prSingle, isCollaboratorSingle, Triplet::create) .compose(makeLoaderSingle(0, force)) diff --git a/app/src/main/java/com/gh4a/fragment/ReviewFragment.java b/app/src/main/java/com/gh4a/fragment/ReviewFragment.java index 0245e7c0b..9f76539c5 100644 --- a/app/src/main/java/com/gh4a/fragment/ReviewFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ReviewFragment.java @@ -50,6 +50,7 @@ import java.util.List; import io.reactivex.Single; +import io.reactivex.schedulers.Schedulers; import retrofit2.Response; public class ReviewFragment extends ListDataBaseFragment implements @@ -204,7 +205,11 @@ protected Single> onCreateDataSingle(boolean bypassCache) { .map(Optional::of); }); - return Single.zip(reviewItemSingle, reviewCommentsSingle, filesSingle, commentsSingle, + return Single.zip( + reviewItemSingle.subscribeOn(Schedulers.io()), + reviewCommentsSingle.subscribeOn(Schedulers.io()), + filesSingle.subscribeOn(Schedulers.io()), + commentsSingle.subscribeOn(Schedulers.io()), (reviewItem, reviewComments, filesOpt, commentsOpt) -> { if (!reviewComments.isEmpty()) { HashMap filesByName = new HashMap<>();