Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Last active December 30, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvinsj/7824270 to your computer and use it in GitHub Desktop.
Save alvinsj/7824270 to your computer and use it in GitHub Desktop.
new APIRequest( new APIClient(HomeActivity.this), APP_SERVER+"/latest_news", APIRequest.GET)
.withDefaultParams(defaultParamsHashMap())
.addParam("format", "json")
.addParam("limit", 10)
.addHeaderParam("Referer", APP_REFERER);
.startWithCache(CacheStategy.RESPONSE_VERSION, CACHE_GROUP_KEY, CACHE_KEY,new JSONRequestHandler(){
@Override
public String getVersion(HttpEntity response){
return versionFromResponse(response);
}
public boolean hasVersionChanged(HttpEntity response, String version){
return getVersion(response)v == version;
}
@Override
public void before(){
showProgressBar();
}
@Override
public void after(){
updateView();
hideProgressBar();
}
@Override
public void onException(Exception e) {
e.printStackTrace();
}
@Override
public void onResponse(HttpEntity response, JSONObject jsonResponse) {
createModelFromResponse(jsonResponse)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment