Search in sources :

Example 1 with RepositoryStatusService

use of com.meisolsson.githubsdk.service.repositories.RepositoryStatusService in project gh4a by slapperwan.

the class PullRequestFragment method loadCommitStatusesIfOpen.

private void loadCommitStatusesIfOpen(boolean force) {
    if (mPullRequest.state() != IssueState.Open) {
        return;
    }
    RepositoryStatusService service = ServiceFactory.get(RepositoryStatusService.class, force);
    String sha = mPullRequest.head().sha();
    ApiHelpers.PageIterator.toSingle(page -> service.getStatuses(mRepoOwner, mRepoName, sha, page)).compose(RxUtils.sortList(STATUS_TIMESTAMP_COMPARATOR)).map(statuses -> {
        Set<String> seenContexts = new HashSet<>();
        Iterator<Status> iter = statuses.iterator();
        while (iter.hasNext()) {
            Status status = iter.next();
            if (seenContexts.contains(status.context())) {
                iter.remove();
            } else {
                seenContexts.add(status.context());
            }
        }
        return statuses;
    }).compose(RxUtils.sortList(STATUS_AND_CONTEXT_COMPARATOR)).compose(makeLoaderSingle(ID_LOADER_STATUS, force)).subscribe(this::fillStatus, this::handleLoadFailure);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) IssueCommentService(com.meisolsson.githubsdk.service.issues.IssueCommentService) Bundle(android.os.Bundle) PullRequestReviewService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService) Status(com.meisolsson.githubsdk.model.Status) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) RepositoryStatusService(com.meisolsson.githubsdk.service.repositories.RepositoryStatusService) PullRequest(com.meisolsson.githubsdk.model.PullRequest) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService) IssueState(com.meisolsson.githubsdk.model.IssueState) Map(java.util.Map) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) AttrRes(android.support.annotation.AttrRes) PullRequestBranchInfoView(com.gh4a.widget.PullRequestBranchInfoView) IntentUtils(com.gh4a.utils.IntentUtils) Review(com.meisolsson.githubsdk.model.Review) Set(java.util.Set) EditPullRequestCommentActivity(com.gh4a.activities.EditPullRequestCommentActivity) List(java.util.List) RxUtils(com.gh4a.utils.RxUtils) GitService(com.meisolsson.githubsdk.service.git.GitService) Optional(com.gh4a.utils.Optional) EditIssueCommentActivity(com.gh4a.activities.EditIssueCommentActivity) TimelineItem(com.gh4a.model.TimelineItem) ReviewState(com.meisolsson.githubsdk.model.ReviewState) Repository(com.meisolsson.githubsdk.model.Repository) LongSparseArray(android.support.v4.util.LongSparseArray) Pair(android.util.Pair) GitHubCommentBase(com.meisolsson.githubsdk.model.GitHubCommentBase) Intent(android.content.Intent) HashMap(java.util.HashMap) GitReference(com.meisolsson.githubsdk.model.git.GitReference) Response(retrofit2.Response) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) MenuInflater(android.view.MenuInflater) CommitStatusBox(com.gh4a.widget.CommitStatusBox) IssueEventService(com.meisolsson.githubsdk.service.issues.IssueEventService) Menu(android.view.Menu) R(com.gh4a.R) Observable(io.reactivex.Observable) CreateGitReference(com.meisolsson.githubsdk.model.request.git.CreateGitReference) ApiHelpers(com.gh4a.utils.ApiHelpers) Iterator(java.util.Iterator) PullRequestMarker(com.meisolsson.githubsdk.model.PullRequestMarker) ReviewComment(com.meisolsson.githubsdk.model.ReviewComment) TextUtils(android.text.TextUtils) AlertDialog(android.support.v7.app.AlertDialog) ServiceFactory(com.gh4a.ServiceFactory) Comparator(java.util.Comparator) Collections(java.util.Collections) Status(com.meisolsson.githubsdk.model.Status) Set(java.util.Set) HashSet(java.util.HashSet) RepositoryStatusService(com.meisolsson.githubsdk.service.repositories.RepositoryStatusService) Iterator(java.util.Iterator)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 AttrRes (android.support.annotation.AttrRes)1 LongSparseArray (android.support.v4.util.LongSparseArray)1 AlertDialog (android.support.v7.app.AlertDialog)1 TextUtils (android.text.TextUtils)1 Pair (android.util.Pair)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 R (com.gh4a.R)1 ServiceFactory (com.gh4a.ServiceFactory)1 EditIssueCommentActivity (com.gh4a.activities.EditIssueCommentActivity)1 EditPullRequestCommentActivity (com.gh4a.activities.EditPullRequestCommentActivity)1 TimelineItem (com.gh4a.model.TimelineItem)1 ApiHelpers (com.gh4a.utils.ApiHelpers)1 IntentUtils (com.gh4a.utils.IntentUtils)1 Optional (com.gh4a.utils.Optional)1 RxUtils (com.gh4a.utils.RxUtils)1