Skip to content

Instantly share code, notes, and snippets.

@hboregio
Created May 16, 2014 18:38
Show Gist options
  • Save hboregio/276715ccafbc5cf94f33 to your computer and use it in GitHub Desktop.
Save hboregio/276715ccafbc5cf94f33 to your computer and use it in GitHub Desktop.
import com.loopj.android.http.AsyncHttpResponseHandler;
/**
* Singleton RestClient
*/
public class RestClient {
private static RestClient sInstance = null;
public static RestClient getInstance() {
return RestClient.getInstance();
}
public static RestClient getInstance() {
if (sInstance == null) {
sInstance = new RestClient();
}
return sInstance;
}
public void getFeed(final ResultsListener<String> aListener) {
ChoosyAPI.get("feed/", null, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, String content) {
if (statusCode == 200) {
aListener.onSuccess(content);
}
}
@Override
public void onFailure(Throwable e, String response) {
aListener.onFailure(e);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment