From 0aef6f67506ad774000aa1741bec261d9a17c718 Mon Sep 17 00:00:00 2001 From: Fs00 Date: Wed, 8 Sep 2021 08:54:38 +0200 Subject: [PATCH 1/5] Remove preview header for checks API --- app/src/main/java/com/gh4a/ServiceFactory.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/java/com/gh4a/ServiceFactory.java b/app/src/main/java/com/gh4a/ServiceFactory.java index 3235e5aa0..256e1a2ca 100644 --- a/app/src/main/java/com/gh4a/ServiceFactory.java +++ b/app/src/main/java/com/gh4a/ServiceFactory.java @@ -7,7 +7,6 @@ import com.meisolsson.githubsdk.core.GitHubPaginationInterceptor; import com.meisolsson.githubsdk.core.ServiceGenerator; import com.meisolsson.githubsdk.core.StringResponseConverterFactory; -import com.meisolsson.githubsdk.service.checks.ChecksService; import java.io.File; import java.util.HashMap; @@ -37,9 +36,6 @@ public class ServiceFactory { private static final String DEFAULT_HEADER_ACCEPT = "application/vnd.github.squirrel-girl-preview," // reactions API preview + "application/vnd.github.v3.full+json"; - private static final String CHECKS_API_HEADER_ACCEPT = - "application/vnd.github.antiope-preview," // checks API preview - + "application/vnd.github.v3.full+json"; private final static HttpLoggingInterceptor LOGGING_INTERCEPTOR = new HttpLoggingInterceptor() .setLevel(HttpLoggingInterceptor.Level.BASIC); @@ -173,8 +169,6 @@ private static S createService(Class serviceClass, final boolean bypassCa final String header; if (acceptHeader != null) { header = acceptHeader; - } else if (serviceClass == ChecksService.class) { - header = CHECKS_API_HEADER_ACCEPT; } else { header = DEFAULT_HEADER_ACCEPT; } From 63d40324ff44fe2d98b0e58279a8438eaaf2adba Mon Sep 17 00:00:00 2001 From: Fs00 Date: Wed, 8 Sep 2021 18:46:48 +0200 Subject: [PATCH 2/5] Parallelize API requests needed to load a PR conversation --- .../main/java/com/gh4a/fragment/PullRequestFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java b/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java index 392b73646..0c168f66b 100644 --- a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java +++ b/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java @@ -77,6 +77,7 @@ import io.reactivex.Observable; import io.reactivex.Single; +import io.reactivex.schedulers.Schedulers; import retrofit2.Response; public class PullRequestFragment extends IssueFragmentBase { @@ -313,10 +314,10 @@ protected Single> onCreateDataSingle(boolean bypassCache) { }); return Single.zip( - issueCommentItemSingle, - eventItemSingle, - reviewTimelineSingle, - commitCommentWithoutReviewSingle, + issueCommentItemSingle.subscribeOn(Schedulers.newThread()), + eventItemSingle.subscribeOn(Schedulers.newThread()), + reviewTimelineSingle.subscribeOn(Schedulers.newThread()), + commitCommentWithoutReviewSingle.subscribeOn(Schedulers.newThread()), (comments, events, reviewItems, commentsWithoutReview) -> { ArrayList result = new ArrayList<>(); result.addAll(comments); From c03a487a83641322565fdc993dc20685cde5a40c Mon Sep 17 00:00:00 2001 From: Fs00 Date: Wed, 8 Sep 2021 18:56:17 +0200 Subject: [PATCH 3/5] Use Schedulers.io instead of newThread --- .../main/java/com/gh4a/fragment/PullRequestFragment.java | 8 ++++---- app/src/main/java/com/gh4a/utils/RxUtils.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java b/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java index 0c168f66b..b2da0ab44 100644 --- a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java +++ b/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java @@ -314,10 +314,10 @@ protected Single> onCreateDataSingle(boolean bypassCache) { }); return Single.zip( - issueCommentItemSingle.subscribeOn(Schedulers.newThread()), - eventItemSingle.subscribeOn(Schedulers.newThread()), - reviewTimelineSingle.subscribeOn(Schedulers.newThread()), - commitCommentWithoutReviewSingle.subscribeOn(Schedulers.newThread()), + issueCommentItemSingle.subscribeOn(Schedulers.io()), + eventItemSingle.subscribeOn(Schedulers.io()), + reviewTimelineSingle.subscribeOn(Schedulers.io()), + commitCommentWithoutReviewSingle.subscribeOn(Schedulers.io()), (comments, events, reviewItems, commentsWithoutReview) -> { ArrayList result = new ArrayList<>(); result.addAll(comments); diff --git a/app/src/main/java/com/gh4a/utils/RxUtils.java b/app/src/main/java/com/gh4a/utils/RxUtils.java index 8fc0c40b4..cae8bc861 100644 --- a/app/src/main/java/com/gh4a/utils/RxUtils.java +++ b/app/src/main/java/com/gh4a/utils/RxUtils.java @@ -86,7 +86,7 @@ public static SingleTransformer mapFailureToValue(int code, T value) { } public static Single doInBackground(Single upstream) { - return upstream.subscribeOn(Schedulers.newThread()) + return upstream.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } From ff17c68ac2c544c82ab1dc1e0d7bfe0941f252fe Mon Sep 17 00:00:00 2001 From: Fs00 Date: Thu, 9 Sep 2021 08:47:45 +0200 Subject: [PATCH 4/5] Parallelize issue loading API requests --- .../main/java/com/gh4a/fragment/IssueFragment.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/gh4a/fragment/IssueFragment.java b/app/src/main/java/com/gh4a/fragment/IssueFragment.java index 9cca597f2..46265cec7 100644 --- a/app/src/main/java/com/gh4a/fragment/IssueFragment.java +++ b/app/src/main/java/com/gh4a/fragment/IssueFragment.java @@ -24,6 +24,7 @@ import java.util.List; import io.reactivex.Single; +import io.reactivex.schedulers.Schedulers; import retrofit2.Response; public class IssueFragment extends IssueFragmentBase { @@ -77,13 +78,15 @@ protected Single> onCreateDataSingle(boolean bypassCache) { final IssueCommentService commentService = ServiceFactory.get(IssueCommentService.class, bypassCache); - Single> commentSingle = ApiHelpers.PageIterator + Single> commentSingle = ApiHelpers.PageIterator .toSingle(page -> commentService.getIssueComments(mRepoOwner, mRepoName, issueNumber, page)) - .compose(RxUtils.mapList(TimelineItem.TimelineComment::new)); - Single> eventSingle = ApiHelpers.PageIterator + .compose(RxUtils.mapList(TimelineItem.TimelineComment::new)) + .subscribeOn(Schedulers.io()); + Single> eventSingle = ApiHelpers.PageIterator .toSingle(page -> eventService.getIssueEvents(mRepoOwner, mRepoName, issueNumber, page)) .compose(RxUtils.filter(event -> INTERESTING_EVENTS.contains(event.event()))) - .compose((RxUtils.mapList(TimelineItem.TimelineEvent::new))); + .compose((RxUtils.mapList(TimelineItem.TimelineEvent::new))) + .subscribeOn(Schedulers.io()); return Single.zip(commentSingle, eventSingle, (comments, events) -> { ArrayList result = new ArrayList<>(); From a27c5e7e93f891dda3a8bef7b50d7f91f977f021 Mon Sep 17 00:00:00 2001 From: Fs00 Date: Thu, 9 Sep 2021 09:41:37 +0200 Subject: [PATCH 5/5] Rename PullRequestFragment to PullRequestConversationFragment --- .../gh4a/activities/PullRequestActivity.java | 30 +++++++++---------- ...a => PullRequestConversationFragment.java} | 6 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) rename app/src/main/java/com/gh4a/fragment/{PullRequestFragment.java => PullRequestConversationFragment.java} (98%) diff --git a/app/src/main/java/com/gh4a/activities/PullRequestActivity.java b/app/src/main/java/com/gh4a/activities/PullRequestActivity.java index c831ca5d1..c4c76aeb1 100644 --- a/app/src/main/java/com/gh4a/activities/PullRequestActivity.java +++ b/app/src/main/java/com/gh4a/activities/PullRequestActivity.java @@ -55,7 +55,7 @@ import com.gh4a.fragment.CommitCompareFragment; import com.gh4a.fragment.ConfirmationDialogFragment; import com.gh4a.fragment.PullRequestFilesFragment; -import com.gh4a.fragment.PullRequestFragment; +import com.gh4a.fragment.PullRequestConversationFragment; import com.gh4a.utils.ApiHelpers; import com.gh4a.utils.IntentUtils; import com.gh4a.utils.RxUtils; @@ -118,7 +118,7 @@ public static Intent makeIntent(Context context, String repoOwner, String repoNa private Issue mIssue; private PullRequest mPullRequest; - private PullRequestFragment mPullRequestFragment; + private PullRequestConversationFragment mConversationFragment; private IssueStateTrackingFloatingActionButton mEditFab; private Review mPendingReview; private boolean mPendingReviewLoaded; @@ -129,8 +129,8 @@ public static Intent makeIntent(Context context, String repoOwner, String repoNa private final ActivityResultLauncher mCreateReviewLauncher = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), new ActivityResultHelpers.ActivityResultSuccessCallback(() -> { - if (mPullRequestFragment != null) { - mPullRequestFragment.reloadEvents(false); + if (mConversationFragment != null) { + mConversationFragment.reloadEvents(false); } loadPendingReview(true); }) @@ -295,16 +295,16 @@ protected int[] getHeaderColorAttrs() { @Override protected Fragment makeFragment(int position) { - if (position == 1) { + if (position == PAGE_COMMITS) { PullRequestMarker base = mPullRequest.base(); PullRequestMarker head = mPullRequest.head(); return CommitCompareFragment.newInstance(mRepoOwner, mRepoName, mPullRequestNumber, base.label(), base.sha(), head.label(), head.sha()); - } else if (position == 2) { + } else if (position == PAGE_FILES) { return PullRequestFilesFragment.newInstance(mRepoOwner, mRepoName, mPullRequestNumber, mPullRequest.head().sha()); } else { - Fragment f = PullRequestFragment.newInstance(mPullRequest, + Fragment f = PullRequestConversationFragment.newInstance(mPullRequest, mIssue, mIsCollaborator, mInitialComment); mInitialComment = null; return f; @@ -313,15 +313,15 @@ protected Fragment makeFragment(int position) { @Override protected void onFragmentInstantiated(Fragment f, int position) { - if (position == 0) { - mPullRequestFragment = (PullRequestFragment) f; + if (position == PAGE_CONVERSATION) { + mConversationFragment = (PullRequestConversationFragment) f; } } @Override protected void onFragmentDestroyed(Fragment f) { - if (f == mPullRequestFragment) { - mPullRequestFragment = null; + if (f == mConversationFragment) { + mConversationFragment = null; } } @@ -337,8 +337,8 @@ protected Intent navigateUp() { @Override public void onCommentsUpdated() { - if (mPullRequestFragment != null) { - mPullRequestFragment.reloadEvents(true); + if (mConversationFragment != null) { + mConversationFragment.reloadEvents(true); } } @@ -433,8 +433,8 @@ private void fillHeader() { } private void handlePullRequestUpdate() { - if (mPullRequestFragment != null) { - mPullRequestFragment.updateState(mPullRequest); + if (mConversationFragment != null) { + mConversationFragment.updateState(mPullRequest); } if (mIssue != null) { Issue.Builder builder = mIssue.toBuilder().state(mPullRequest.state()); diff --git a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java b/app/src/main/java/com/gh4a/fragment/PullRequestConversationFragment.java similarity index 98% rename from app/src/main/java/com/gh4a/fragment/PullRequestFragment.java rename to app/src/main/java/com/gh4a/fragment/PullRequestConversationFragment.java index b2da0ab44..a42e992bd 100644 --- a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java +++ b/app/src/main/java/com/gh4a/fragment/PullRequestConversationFragment.java @@ -80,7 +80,7 @@ import io.reactivex.schedulers.Schedulers; import retrofit2.Response; -public class PullRequestFragment extends IssueFragmentBase { +public class PullRequestConversationFragment extends IssueFragmentBase { private static final int ID_LOADER_STATUS = 1; private static final int ID_LOADER_HEAD_REF = 2; @@ -88,9 +88,9 @@ public class PullRequestFragment extends IssueFragmentBase { private GitReference mHeadReference; private boolean mHasLoadedHeadReference; - public static PullRequestFragment newInstance(PullRequest pr, Issue issue, + public static PullRequestConversationFragment newInstance(PullRequest pr, Issue issue, boolean isCollaborator, IntentUtils.InitialCommentMarker initialComment) { - PullRequestFragment f = new PullRequestFragment(); + PullRequestConversationFragment f = new PullRequestConversationFragment(); Repository repo = pr.base().repo(); Bundle args = buildArgs(repo.owner().login(), repo.name(),