Skip to content

Instantly share code, notes, and snippets.

@ctcarrier
Last active January 1, 2016 18:29
Show Gist options
  • Save ctcarrier/8183925 to your computer and use it in GitHub Desktop.
Save ctcarrier/8183925 to your computer and use it in GitHub Desktop.
private BallHttpClient<Ball> httpClient = new BallHttpClient<Ball>(SCHEME, HOST, PORT){
@Override
public ResponseHandler<Ball> createResponseHandler() {
return new ResponseHandler<Ball>(){
@Override
public Ball handleResponse(HttpResponse resp)
throws ClientProtocolException, IOException, NoResourceFoundException, ErrorAccessingResourceException {
handleErrors(resp);
return gson.fromJson(new InputStreamReader(resp.getEntity().getContent()), Ball.class);
}
};
}
@Override
public ResponseHandler<List<Ball>> createListResponseHandler() {
return new ResponseHandler<List<Ball>>(){
@Override
public List<Ball> handleResponse(HttpResponse resp)
throws ClientProtocolException, IOException, NoResourceFoundException, ErrorAccessingResourceException {
handleErrors(resp);
return gson.fromJson(new InputStreamReader(resp.getEntity().getContent()), new TypeToken<List<Ball>>(){}.getType());
}
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment