Search in sources :

Example 1 with StoryResponse

use of io.plaidapp.data.api.designernews.model.StoryResponse in project sbt-android by scala-android.

the class UpvoteStoryService method handleActionUpvote.

private void handleActionUpvote(long storyId) {
    if (storyId == 0l)
        return;
    DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
    if (!designerNewsPrefs.isLoggedIn()) {
        // TODO prompt for login
        return;
    }
    DesignerNewsService designerNewsService = new RestAdapter.Builder().setEndpoint(DesignerNewsService.ENDPOINT).setRequestInterceptor(new ClientAuthInterceptor(designerNewsPrefs.getAccessToken(), BuildConfig.DESIGNER_NEWS_CLIENT_ID)).build().create(DesignerNewsService.class);
    designerNewsService.upvoteStory(storyId, "", new Callback<StoryResponse>() {

        @Override
        public void success(StoryResponse storyResponse, Response response) {
            int newVotesCount = storyResponse.story.vote_count;
        // TODO report success
        }

        @Override
        public void failure(RetrofitError error) {
        // TODO report failure
        }
    });
}
Also used : StoryResponse(io.plaidapp.data.api.designernews.model.StoryResponse) Response(retrofit.client.Response) StoryResponse(io.plaidapp.data.api.designernews.model.StoryResponse) ClientAuthInterceptor(io.plaidapp.data.api.ClientAuthInterceptor) DesignerNewsPrefs(io.plaidapp.data.prefs.DesignerNewsPrefs) RetrofitError(retrofit.RetrofitError)

Aggregations

ClientAuthInterceptor (io.plaidapp.data.api.ClientAuthInterceptor)1 StoryResponse (io.plaidapp.data.api.designernews.model.StoryResponse)1 DesignerNewsPrefs (io.plaidapp.data.prefs.DesignerNewsPrefs)1 RetrofitError (retrofit.RetrofitError)1 Response (retrofit.client.Response)1