Search in sources :

Example 61 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class ContentListContainerFragment method loadModuleMap.

private void loadModuleMap() {
    RepositoryContentService service = ServiceFactory.get(RepositoryContentService.class, false);
    String repoOwner = mRepository.owner().login();
    String repoName = mRepository.name();
    service.getContents(repoOwner, repoName, ".gitmodules", mSelectedRef).map(ApiHelpers::throwOnFailure).map(Optional::of).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, Optional.<Content>absent())).map(contentOpt -> contentOpt.map(content -> StringUtils.fromBase64(content.content()))).map(this::parseModuleMap).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(mRxLoader.makeSingleTransformer(ID_LOADER_MODULEMAP, true)).subscribe(resultOpt -> {
        mGitModuleMap = resultOpt.orNull();
        if (mContentListFragment != null) {
            mContentListFragment.onSubModuleNamesChanged(getSubModuleNames(mContentListFragment));
        }
    }, ((BaseActivity) getActivity())::handleLoadFailure);
}
Also used : PathBreadcrumbs(com.gh4a.widget.PathBreadcrumbs) HttpURLConnection(java.net.HttpURLConnection) Context(android.content.Context) Repository(com.meisolsson.githubsdk.model.Repository) Bundle(android.os.Bundle) FileViewerActivity(com.gh4a.activities.FileViewerActivity) Uri(android.net.Uri) HashMap(java.util.HashMap) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Stack(java.util.Stack) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Commit(com.meisolsson.githubsdk.model.Commit) SwipeRefreshLayout(com.gh4a.widget.SwipeRefreshLayout) RxLoader(com.philosophicalhacker.lib.RxLoader) Content(com.meisolsson.githubsdk.model.Content) Map(java.util.Map) R(com.gh4a.R) ContentType(com.meisolsson.githubsdk.model.ContentType) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) StringUtils(com.gh4a.utils.StringUtils) ApiHelpers(com.gh4a.utils.ApiHelpers) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) Set(java.util.Set) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) FragmentManager(android.support.v4.app.FragmentManager) List(java.util.List) RepositoryActivity(com.gh4a.activities.RepositoryActivity) RxUtils(com.gh4a.utils.RxUtils) Optional(com.gh4a.utils.Optional) Nullable(android.support.annotation.Nullable) ServiceFactory(com.gh4a.ServiceFactory) FragmentTransaction(android.support.v4.app.FragmentTransaction) BaseActivity(com.gh4a.BaseActivity) Content(com.meisolsson.githubsdk.model.Content) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 62 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class EditIssueCommentActivity method createComment.

@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
    int issueNumber = getIntent().getIntExtra("issue", 0);
    IssueCommentService service = ServiceFactory.get(IssueCommentService.class, false);
    CommentRequest request = CommentRequest.builder().body(body).build();
    return service.createIssueComment(repoOwner, repoName, issueNumber, request).map(ApiHelpers::throwOnFailure);
}
Also used : CommentRequest(com.meisolsson.githubsdk.model.request.CommentRequest) IssueCommentService(com.meisolsson.githubsdk.service.issues.IssueCommentService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 63 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class CommitDiffViewerActivity method addReaction.

@Override
public Single<Reaction> addReaction(ReactionBar.Item item, String content) {
    CommitCommentWrapper comment = (CommitCommentWrapper) item;
    final ReactionService service = ServiceFactory.get(ReactionService.class, false);
    ReactionRequest request = ReactionRequest.builder().content(content).build();
    return service.createCommitCommentReaction(mRepoOwner, mRepoName, comment.comment.id(), request).map(ApiHelpers::throwOnFailure);
}
Also used : ReactionRequest(com.meisolsson.githubsdk.model.request.ReactionRequest) ReactionService(com.meisolsson.githubsdk.service.reactions.ReactionService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 64 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class EditPullRequestCommentActivity method editComment.

@Override
protected Single<GitHubCommentBase> editComment(String repoOwner, String repoName, long commentId, String body) {
    PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
    CommentRequest request = CommentRequest.builder().body(body).build();
    return service.editReviewComment(repoOwner, repoName, commentId, request).map(ApiHelpers::throwOnFailure);
}
Also used : CommentRequest(com.meisolsson.githubsdk.model.request.CommentRequest) ApiHelpers(com.gh4a.utils.ApiHelpers) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)

Example 65 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class EditPullRequestDiffCommentActivity method createComment.

@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
    Bundle extras = getIntent().getExtras();
    int prNumber = extras.getInt("pull_request_number", 0);
    PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
    CreateReviewComment.Builder builder = CreateReviewComment.builder().body(body);
    if (replyToCommentId != 0) {
        builder.inReplyTo(replyToCommentId);
    } else {
        builder.commitId(extras.getString("commit_id")).path(extras.getString("path")).position(extras.getInt("position"));
    }
    return service.createReviewComment(repoOwner, repoName, prNumber, builder.build()).map(ApiHelpers::throwOnFailure);
}
Also used : Bundle(android.os.Bundle) ApiHelpers(com.gh4a.utils.ApiHelpers) CreateReviewComment(com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)68 Response (retrofit2.Response)13 RxUtils (com.gh4a.utils.RxUtils)12 ServiceFactory (com.gh4a.ServiceFactory)11 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 Optional (com.gh4a.utils.Optional)10 PullRequestReviewCommentService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)10 Single (io.reactivex.Single)9 Context (android.content.Context)7 LayoutInflater (android.view.LayoutInflater)7 CommentRequest (com.meisolsson.githubsdk.model.request.CommentRequest)7 List (java.util.List)7 View (android.view.View)6 R (com.gh4a.R)6 IntentUtils (com.gh4a.utils.IntentUtils)6 User (com.meisolsson.githubsdk.model.User)6 ReactionRequest (com.meisolsson.githubsdk.model.request.ReactionRequest)6 CreateReviewComment (com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment)6 ReactionService (com.meisolsson.githubsdk.service.reactions.ReactionService)6