Android Open Source - droidcon Reddit Service






From Project

Back to project page droidcon.

License

The source code is released under:

Apache License

If you think the Android project droidcon listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.timehop.droidcon2014retrofitsample.data.reddit;
/*w  ww  .j a v a  2s . co  m*/

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditListing;
import com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditObject;
import com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditResponse;

import org.joda.time.DateTime;

import java.util.List;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.converter.GsonConverter;
import retrofit.http.GET;
import retrofit.http.Path;

public interface RedditService {
  @GET("/r/{subreddit}/comments/{id}.json")
  List<RedditResponse<RedditListing>> getComments(
      @Path("subreddit") String subreddit,
      @Path("id") String id
  );

  @GET("/r/{subreddit}/comments/{id}.json")
  void getComments(
      @Path("subreddit") String subreddit,
      @Path("id") String id,
      Callback<List<RedditResponse<RedditListing>>> callback
  );

  @GET("/r/{subreddit}.json")
  RedditResponse<RedditListing> getSubreddit(@Path("subreddit") String subreddit);

  @GET("/r/{subreddit}.json")
  void getSubreddit(
      @Path("subreddit") String subreddit,
      Callback<RedditResponse<RedditListing>> callback);

  public static class Implementation {
    public static RedditService get() {
      return getBuilder()
          .build()
          .create(RedditService.class);
    }

    static RestAdapter.Builder getBuilder() {
      return new RestAdapter.Builder()
          .setConverter(new GsonConverter(getGson()))
          .setEndpoint("http://www.reddit.com");
    }

    private static Gson getGson() {
      return new GsonBuilder()
          .registerTypeAdapter(RedditObject.class, new RedditObjectDeserializer())
          .registerTypeAdapter(DateTime.class, new DateTimeDeserializer())
          .create();
    }
  }
}




Java Source Code List

com.timehop.droidcon2014retrofitsample.CommentsActivity.java
com.timehop.droidcon2014retrofitsample.MainActivity.java
com.timehop.droidcon2014retrofitsample.SubredditActivity.java
com.timehop.droidcon2014retrofitsample.VenueSearchActivity.java
com.timehop.droidcon2014retrofitsample.data.SynchronousExecutor.java
com.timehop.droidcon2014retrofitsample.data.foursquare.FoursquareService.java
com.timehop.droidcon2014retrofitsample.data.foursquare.FoursquareTests.java
com.timehop.droidcon2014retrofitsample.data.foursquare.api.FoursquareCredentials.java
com.timehop.droidcon2014retrofitsample.data.foursquare.api.FoursquareErrorHandler.java
com.timehop.droidcon2014retrofitsample.data.foursquare.api.FoursquareException.java
com.timehop.droidcon2014retrofitsample.data.foursquare.api.FoursquareRequestInterceptor.java
com.timehop.droidcon2014retrofitsample.data.foursquare.api.FoursquareResponse.java
com.timehop.droidcon2014retrofitsample.data.foursquare.legacy.VenueSearchTask.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Category.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Contact.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Icon.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Location.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Menu.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Meta.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Price.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.ResponseWrapper.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Stats.java
com.timehop.droidcon2014retrofitsample.data.foursquare.model.Venue.java
com.timehop.droidcon2014retrofitsample.data.reddit.DateTimeDeserializer.java
com.timehop.droidcon2014retrofitsample.data.reddit.MockRedditService.java
com.timehop.droidcon2014retrofitsample.data.reddit.RedditObjectDeserializer.java
com.timehop.droidcon2014retrofitsample.data.reddit.RedditService.java
com.timehop.droidcon2014retrofitsample.data.reddit.RedditTests.java
com.timehop.droidcon2014retrofitsample.data.reddit.RedditType.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.MockModelHelper.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditAccount.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditComment.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditLink.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditListing.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditMore.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditObjectWrapper.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditObject.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditResponse.java
com.timehop.droidcon2014retrofitsample.data.reddit.model.RedditSubmission.java
com.timehop.droidcon2014retrofitsample.ui.CommentsAdapter.java
com.timehop.droidcon2014retrofitsample.ui.LinkAdapter.java
com.timehop.droidcon2014retrofitsample.ui.VenueAdapter.java