Search in sources :

Example 6 with ApiHelpers

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

the class RepositoryActivity method loadStarringState.

private void loadStarringState(boolean force) {
    if (!Gh4Application.get().isAuthorized()) {
        return;
    }
    StarringService service = ServiceFactory.get(StarringService.class, force);
    service.checkIfRepositoryIsStarred(mRepoOwner, mRepoName).map(ApiHelpers::throwOnFailure).map(result -> true).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, false)).compose(makeLoaderSingle(ID_LOADER_STARRING, force)).subscribe(result -> {
        mIsStarring = result;
        supportInvalidateOptionsMenu();
    }, this::handleLoadFailure);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Context(android.content.Context) ContentListContainerFragment(com.gh4a.fragment.ContentListContainerFragment) Repository(com.meisolsson.githubsdk.model.Repository) Bundle(android.os.Bundle) StarringService(com.meisolsson.githubsdk.service.activity.StarringService) Uri(android.net.Uri) ImageView(android.widget.ImageView) RepositoryEventListFragment(com.gh4a.fragment.RepositoryEventListFragment) Intent(android.content.Intent) RepositoryFragment(com.gh4a.fragment.RepositoryFragment) Response(retrofit2.Response) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) UiUtils(com.gh4a.utils.UiUtils) ArrayList(java.util.ArrayList) Commit(com.meisolsson.githubsdk.model.Commit) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) R(com.gh4a.R) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) IntentUtils(com.gh4a.utils.IntentUtils) Subscription(com.meisolsson.githubsdk.model.Subscription) RepositoryBranchService(com.meisolsson.githubsdk.service.repositories.RepositoryBranchService) ApiHelpers(com.gh4a.utils.ApiHelpers) BaseFragmentPagerActivity(com.gh4a.BaseFragmentPagerActivity) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService) TextUtils(android.text.TextUtils) WatchingService(com.meisolsson.githubsdk.service.activity.WatchingService) ViewGroup(android.view.ViewGroup) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) RxUtils(com.gh4a.utils.RxUtils) BaseAdapter(android.widget.BaseAdapter) Gh4Application(com.gh4a.Gh4Application) CommitListFragment(com.gh4a.fragment.CommitListFragment) Pair(android.support.v4.util.Pair) Branch(com.meisolsson.githubsdk.model.Branch) ServiceFactory(com.gh4a.ServiceFactory) BookmarksProvider(com.gh4a.db.BookmarksProvider) SubscriptionRequest(com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest) ApiHelpers(com.gh4a.utils.ApiHelpers) StarringService(com.meisolsson.githubsdk.service.activity.StarringService)

Example 7 with ApiHelpers

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

the class RepositoryActivity method loadWatchingState.

private void loadWatchingState(boolean force) {
    if (!Gh4Application.get().isAuthorized()) {
        return;
    }
    WatchingService service = ServiceFactory.get(WatchingService.class, force);
    service.getRepositorySubscription(mRepoOwner, mRepoName).map(ApiHelpers::throwOnFailure).map(Subscription::subscribed).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, false)).compose(makeLoaderSingle(ID_LOADER_WATCHING, force)).subscribe(result -> {
        mIsWatching = result;
        supportInvalidateOptionsMenu();
    }, this::handleLoadFailure);
}
Also used : WatchingService(com.meisolsson.githubsdk.service.activity.WatchingService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 8 with ApiHelpers

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

the class GistActivity method loadStarredState.

private void loadStarredState(boolean force) {
    GistService service = ServiceFactory.get(GistService.class, force);
    service.checkIfGistIsStarred(mGistId).map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(makeLoaderSingle(ID_LOADER_STARRED, force)).subscribe(result -> {
        mIsStarred = result;
        supportInvalidateOptionsMenu();
    }, this::handleLoadFailure);
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) GistService(com.meisolsson.githubsdk.service.gists.GistService)

Example 9 with ApiHelpers

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

the class GistActivity method updateStarringState.

private void updateStarringState() {
    GistService service = ServiceFactory.get(GistService.class, false);
    Single<Response<Void>> responseSingle = mIsStarred ? service.unstarGist(mGistId) : service.starGist(mGistId);
    responseSingle.map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(RxUtils::doInBackground).subscribe(result -> {
        mIsStarred = !mIsStarred;
        supportInvalidateOptionsMenu();
    }, error -> {
        handleActionFailure("Updating gist starring state failed", error);
        supportInvalidateOptionsMenu();
    });
}
Also used : Response(retrofit2.Response) ApiHelpers(com.gh4a.utils.ApiHelpers) GistService(com.meisolsson.githubsdk.service.gists.GistService)

Example 10 with ApiHelpers

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

the class GistActivity method loadGist.

private void loadGist(boolean force) {
    GistService service = ServiceFactory.get(GistService.class, force);
    service.getGist(mGistId).map(ApiHelpers::throwOnFailure).compose(makeLoaderSingle(ID_LOADER_GIST, force)).subscribe(result -> {
        fillData(result);
        setContentShown(true);
        supportInvalidateOptionsMenu();
    }, this::handleLoadFailure);
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) GistService(com.meisolsson.githubsdk.service.gists.GistService)

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