use of com.meisolsson.githubsdk.model.PullRequestMarker in project gh4a by slapperwan.
the class PullRequestFragment method deletePullRequestBranch.
private void deletePullRequestBranch() {
GitService service = ServiceFactory.get(GitService.class, false);
PullRequestMarker head = mPullRequest.head();
String owner = head.repo().owner().login();
String repo = head.repo().name();
service.deleteGitReference(owner, repo, "heads/" + head.ref()).map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(RxUtils.wrapForBackgroundTask(getBaseActivity(), R.string.deleting_msg, R.string.delete_branch_error)).subscribe(result -> {
mHeadReference = null;
onHeadReferenceUpdated();
}, error -> handleActionFailure("Deleting PR branch failed", error));
}
use of com.meisolsson.githubsdk.model.PullRequestMarker in project gh4a by slapperwan.
the class PullRequestFragment method restorePullRequestBranch.
private void restorePullRequestBranch() {
PullRequestMarker head = mPullRequest.head();
if (head.repo() == null) {
return;
}
String owner = head.repo().owner().login();
String repo = head.repo().name();
GitService service = ServiceFactory.get(GitService.class, false);
CreateGitReference request = CreateGitReference.builder().ref("refs/heads/" + head.ref()).sha(head.sha()).build();
service.createGitReference(owner, repo, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(getBaseActivity(), R.string.saving_msg, R.string.restore_branch_error)).subscribe(result -> {
mHeadReference = result;
onHeadReferenceUpdated();
}, error -> handleActionFailure("Restoring PR branch failed", error));
}
use of com.meisolsson.githubsdk.model.PullRequestMarker in project gh4a by slapperwan.
the class PullRequestBranchInfoView method onClick.
@Override
public void onClick(View v) {
PullRequestMarker marker = v.getId() == R.id.tv_pr_from ? mSourceMarker : mTargetMarker;
if (marker.repo() != null) {
Intent intent = RepositoryActivity.makeIntent(getContext(), marker.repo(), marker.ref());
getContext().startActivity(intent);
}
}
use of com.meisolsson.githubsdk.model.PullRequestMarker in project gh4a by slapperwan.
the class PullRequestFragment method loadHeadReference.
private void loadHeadReference(boolean force) {
GitService service = ServiceFactory.get(GitService.class, force);
PullRequestMarker head = mPullRequest.head();
Repository repo = head.repo();
Single<Optional<GitReference>> refSingle = repo == null ? Single.just(Optional.absent()) : service.getGitReference(repo.owner().login(), repo.name(), head.ref()).map(ApiHelpers::throwOnFailure).map(Optional::of).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, Optional.<GitReference>absent())).compose(makeLoaderSingle(ID_LOADER_HEAD_REF, force));
refSingle.subscribe(refOpt -> {
mHeadReference = refOpt.orNull();
mHasLoadedHeadReference = true;
getActivity().invalidateOptionsMenu();
bindSpecialViews(mListHeaderView);
}, this::handleLoadFailure);
}
use of com.meisolsson.githubsdk.model.PullRequestMarker in project gh4a by slapperwan.
the class PullRequestActivity method makeFragment.
@Override
protected Fragment makeFragment(int position) {
if (position == 1) {
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) {
return PullRequestFilesFragment.newInstance(mRepoOwner, mRepoName, mPullRequestNumber, mPullRequest.head().sha());
} else {
Fragment f = PullRequestFragment.newInstance(mPullRequest, mIssue, mIsCollaborator, mInitialComment);
mInitialComment = null;
return f;
}
}
Aggregations