Search in sources :

Example 1 with NewsDetailBean

use of com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean in project LookLook by xinghongfei.

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) {
    }
    return newsDetailBean;
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) NewsDetailBean(com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean) JsonParser(com.google.gson.JsonParser)

Example 2 with NewsDetailBean

use of com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean in project LookLook by xinghongfei.

the class TopNewsDesPresenterImpl method getDescrible.

@Override
public void getDescrible(final String docid) {
    mITopNewsFragment.showProgressDialog();
    String url = getDetailUrl(docid);
    OkHttpUtils.ResultCallback<String> loadNewsCallback = new OkHttpUtils.ResultCallback<String>() {

        @Override
        public void onSuccess(String response) {
            NewsDetailBean newsDetailBean = NewsJsonUtils.readJsonNewsDetailBeans(response, docid);
            mITopNewsFragment.upListItem(newsDetailBean);
        }

        @Override
        public void onFailure(Exception e) {
            mITopNewsFragment.showError(e.toString());
        }
    };
    OkHttpUtils.get(url, loadNewsCallback);
}
Also used : NewsDetailBean(com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean) OkHttpUtils(com.looklook.xinghongfei.looklook.util.OkHttpUtils)

Aggregations

NewsDetailBean (com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 OkHttpUtils (com.looklook.xinghongfei.looklook.util.OkHttpUtils)1