use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class NewsDao method getMore.
public NewsMoreResponse getMore(String more_url) {
NewsMoreResponse response;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, more_url + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, true);
response = mObjectMapper.readValue(result, new TypeReference<NewsMoreResponse>() {
});
return response;
} 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();
}
return null;
}
use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class NewsDao method mapperJson.
public NewsResponseEntity mapperJson(boolean useCache) {
// TODO Auto-generated method stub
NewsJson newsJson;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, Urls.NEWS_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
newsJson = mObjectMapper.readValue(result, new TypeReference<NewsJson>() {
});
if (newsJson == null) {
return null;
}
this._newsResponse = newsJson.getResponse();
return _newsResponse;
} 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;
}
use of org.codehaus.jackson.JsonParseException 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;
}
use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class TopDao method mapperJson.
public List<Object> mapperJson(boolean useCache) {
List<Object> topCategorys = new ArrayList<Object>();
tabs.clear();
try {
String resultNews = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_NEWS_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
NewsMoreResponse newsMoreResponse = mObjectMapper.readValue(resultNews, new TypeReference<NewsMoreResponse>() {
});
if (newsMoreResponse != null) {
this.newsCategorys = newsMoreResponse.getResponse();
}
String resultBlogs = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_BLOG_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
BlogsMoreResponse blogsMoreResponse = mObjectMapper.readValue(resultBlogs, new TypeReference<BlogsMoreResponse>() {
});
if (blogsMoreResponse != null) {
this.blogsCategorys = blogsMoreResponse.getResponse();
}
String resultWiki = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_WIKI_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
WikiMoreResponse wikiMoreResponse = mObjectMapper.readValue(resultWiki, new TypeReference<WikiMoreResponse>() {
});
if (wikiMoreResponse != null) {
this.wikiCategorys = wikiMoreResponse.getResponse();
}
Collections.addAll(topCategorys, newsCategorys, blogsCategorys, wikiCategorys);
return topCategorys;
} 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;
}
use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class UserDao method mapperJson.
public UserResponse mapperJson(String key) {
// TODO Auto-generated method stub
UserJson userJson;
try {
if (!key.contains(":")) {
return null;
}
String url = String.format(Urls.KEYBindURL, key) + Utility.getParams(key);
String result = HttpUtils.getByHttpClient(mContext, url);
userJson = mObjectMapper.readValue(result, new TypeReference<UserJson>() {
});
if (userJson == null) {
return null;
}
return userJson.getResponse();
} 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;
}
Aggregations