Search in sources :

Example 1 with BlogSearchJson

use of cn.eoe.app.entity.BlogSearchJson in project android-app by eoecn.

the class SearchDao method mapperJson.

/**
 * 这里的逻辑判断得优化 目前仅为实现功能编写的代码 不妥
 *
 * @return
 */
public List<Object> mapperJson() {
    categorys.clear();
    tabs.clear();
    hasChild = false;
    try {
        if (mTag.equals("news")) {
            NewsSearchJson newsSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord + Utility.getScreenParams(mActivity)), new TypeReference<NewsSearchJson>() {
            });
            categorys.add(newsSearchJson.getResponse());
            cate_name = newsSearchJson.getResponse().getName();
            if (newsSearchJson.getResponse().getItems() != null) {
                hasChild = true;
            }
        } else if (mTag.equals("wiki")) {
            WikiSearchJson wikiSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord), new TypeReference<WikiSearchJson>() {
            });
            categorys.add(wikiSearchJson.getResponse());
            cate_name = wikiSearchJson.getResponse().getName();
            if (wikiSearchJson.getResponse().getItems() != null) {
                hasChild = true;
            }
        } else if (mTag.equals("blog")) {
            BlogSearchJson blogSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord), new TypeReference<BlogSearchJson>() {
            });
            categorys.add(blogSearchJson.getResponse());
            cate_name = blogSearchJson.getResponse().getName();
            if (blogSearchJson.getResponse().getItems() != null) {
                hasChild = true;
            }
        }
        return categorys;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : BlogSearchJson(cn.eoe.app.entity.BlogSearchJson) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) NewsSearchJson(cn.eoe.app.entity.NewsSearchJson) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) WikiSearchJson(cn.eoe.app.entity.WikiSearchJson)

Aggregations

BlogSearchJson (cn.eoe.app.entity.BlogSearchJson)1 NewsSearchJson (cn.eoe.app.entity.NewsSearchJson)1 WikiSearchJson (cn.eoe.app.entity.WikiSearchJson)1 IOException (java.io.IOException)1 JsonParseException (org.codehaus.jackson.JsonParseException)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 TypeReference (org.codehaus.jackson.type.TypeReference)1