Last active
December 30, 2015 11:39
-
-
Save alvinsj/7824270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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