Search in sources :

Example 16 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.

the class SearchTopicDao method getGSONMsgList.

public TopicResultListBean getGSONMsgList() throws WeiboException {
    String json = getMsgListJson();
    Gson gson = new Gson();
    TopicResultListBean value = null;
    try {
        value = gson.fromJson(json, TopicResultListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
        return null;
    }
    if (value != null && value.getStatuses() != null && value.getStatuses().size() > 0) {
        List<MessageBean> msgList = value.getStatuses();
        Iterator<MessageBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            MessageBean msg = iterator.next();
            if (msg.getUser() == null) {
                iterator.remove();
            } else {
                msg.getListViewSpannableString();
                TimeUtility.dealMills(msg);
            }
        }
    }
    return value;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) TopicResultListBean(org.qii.weiciyuan.bean.TopicResultListBean) Gson(com.google.gson.Gson)

Example 17 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.

the class EditMyProfileDao method update.

public UserBean update() throws WeiboException {
    String apiUrl = URLHelper.MYPROFILE_EDIT;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("screen_name", screen_name);
    map.put("url", url);
    map.put("description", description);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, apiUrl, map);
    Gson gson = new Gson();
    UserBean value = null;
    try {
        value = gson.fromJson(jsonData, UserBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (this.avatar != null) {
        UploadAvatarDao uploadAvatarDao = new UploadAvatarDao(access_token, avatar);
        uploadAvatarDao.upload();
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) UserBean(org.qii.weiciyuan.bean.UserBean) HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 18 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.

the class FriendListDao method getGSONMsgList.

public UserListBean getGSONMsgList() throws WeiboException {
    String url = URLHelper.FRIENDS_LIST_BYID;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uid", uid);
    map.put("cursor", cursor);
    map.put("trim_status", trim_status);
    map.put("count", count);
    map.put("screen_name", screen_name);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    UserListBean value = null;
    try {
        value = gson.fromJson(jsonData, UserListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) UserListBean(org.qii.weiciyuan.bean.UserListBean)

Example 19 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.

the class RemarkDao method updateRemark.

public UserBean updateRemark() throws WeiboException {
    String url = URLHelper.REMARK_UPDATE;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uid", uid);
    map.put("remark", remark);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
    Gson gson = new Gson();
    UserBean value = null;
    try {
        value = gson.fromJson(jsonData, UserBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) UserBean(org.qii.weiciyuan.bean.UserBean) HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 20 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.

the class ShareShortUrlTimeLineDao method getGSONMsgList.

public ShareListBean getGSONMsgList() throws WeiboException {
    String json = getMsgListJson();
    Gson gson = new Gson();
    ShareListBean value = null;
    try {
        value = gson.fromJson(json, ShareListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (value != null) {
        Iterator<MessageBean> iterator = value.getItemList().iterator();
        while (iterator.hasNext()) {
            MessageBean msg = iterator.next();
            if (msg.getUser() == null) {
                iterator.remove();
            } else {
                msg.getListViewSpannableString();
                TimeUtility.dealMills(msg);
            }
        }
    }
    return value;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) ShareListBean(org.qii.weiciyuan.bean.ShareListBean) Gson(com.google.gson.Gson)

Aggregations

JsonSyntaxException (com.google.gson.JsonSyntaxException)143 Gson (com.google.gson.Gson)100 HashMap (java.util.HashMap)38 Cursor (android.database.Cursor)33 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)19 MessageBean (org.qii.weiciyuan.bean.MessageBean)16 BadRequestException (co.cask.cdap.common.BadRequestException)14 GsonBuilder (com.google.gson.GsonBuilder)13 InputStreamReader (java.io.InputStreamReader)13 ContentValues (android.content.ContentValues)12 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)12 Type (java.lang.reflect.Type)10 FileReader (java.io.FileReader)9 Reader (java.io.Reader)9 Path (javax.ws.rs.Path)9 CommentBean (org.qii.weiciyuan.bean.CommentBean)9 UserBean (org.qii.weiciyuan.bean.UserBean)9 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)8 Map (java.util.Map)7