use of com.lauren.simplenews.beans.NewsDetailBean in project SimpleNews by liuling07.
the class NewsJsonUtils method readJsonNewsDetailBeans.
public static NewsDetailBean readJsonNewsDetailBeans(String res, String docId) {
NewsDetailBean newsDetailBean = null;
try {
JsonParser parser = new JsonParser();
JsonObject jsonObj = parser.parse(res).getAsJsonObject();
JsonElement jsonElement = jsonObj.get(docId);
if (jsonElement == null) {
return null;
}
newsDetailBean = JsonUtils.deserialize(jsonElement.getAsJsonObject(), NewsDetailBean.class);
} catch (Exception e) {
LogUtils.e(TAG, "readJsonNewsBeans error", e);
}
return newsDetailBean;
}
use of com.lauren.simplenews.beans.NewsDetailBean in project SimpleNews by liuling07.
the class NewsModelImpl method loadNewsDetail.
/**
* 加载新闻详情
* @param docid
* @param listener
*/
@Override
public void loadNewsDetail(final String docid, final OnLoadNewsDetailListener listener) {
String url = getDetailUrl(docid);
OkHttpUtils.ResultCallback<String> loadNewsCallback = new OkHttpUtils.ResultCallback<String>() {
@Override
public void onSuccess(String response) {
NewsDetailBean newsDetailBean = NewsJsonUtils.readJsonNewsDetailBeans(response, docid);
listener.onSuccess(newsDetailBean);
}
@Override
public void onFailure(Exception e) {
listener.onFailure("load news detail info failure.", e);
}
};
OkHttpUtils.get(url, loadNewsCallback);
}
Aggregations