Search in sources :

Example 11 with JsonSyntaxException

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

the class MentionsWeiboTimeLineDao method getGSONMsgListWithoutClearUnread.

public MessageListBean getGSONMsgListWithoutClearUnread() throws WeiboException {
    String json = getMsgListJson();
    Gson gson = new Gson();
    MessageListBean value = null;
    try {
        value = gson.fromJson(json, MessageListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    /**
         * sometime sina weibo may delete message,so data don't have any user information
         */
    if (value != null && value.getItemList().size() > 0) {
        List<MessageBean> msgList = value.getItemList();
        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) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) Gson(com.google.gson.Gson)

Example 12 with JsonSyntaxException

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

the class FriendshipsDao method executeTask.

private UserBean executeTask(String url) throws WeiboException {
    if (TextUtils.isEmpty(uid) && TextUtils.isEmpty(screen_name)) {
        AppLogger.e("uid or screen name can't be empty");
        return null;
    }
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    if (!TextUtils.isEmpty(uid)) {
        map.put("uid", uid);
    } else {
        map.put("screen_name", screen_name);
    }
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
    try {
        UserBean value = new Gson().fromJson(jsonData, UserBean.class);
        if (value != null) {
            return value;
        }
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    return null;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) UserBean(org.qii.weiciyuan.bean.UserBean) HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 13 with JsonSyntaxException

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

the class SearchDao method getStatusList.

public SearchStatusListBean getStatusList() throws WeiboException {
    String url = URLHelper.STATUSES_SEARCH;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("count", count);
    map.put("page", page);
    map.put("q", q);
    String jsonData = null;
    jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    SearchStatusListBean value = null;
    try {
        value = gson.fromJson(jsonData, SearchStatusListBean.class);
        List<MessageBean> list = value.getItemList();
        Iterator<MessageBean> iterator = list.iterator();
        while (iterator.hasNext()) {
            MessageBean msg = iterator.next();
            //message is deleted by sina
            if (msg.getUser() == null) {
                iterator.remove();
            } else {
                msg.getListViewSpannableString();
                TimeUtility.dealMills(msg);
            }
        }
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    return value;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) SearchStatusListBean(org.qii.weiciyuan.bean.SearchStatusListBean)

Example 14 with JsonSyntaxException

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

the class CommentNewMsgDao method sendNewMsg.

public CommentBean sendNewMsg() throws WeiboException {
    String url = URLHelper.COMMENT_CREATE;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("id", id);
    map.put("comment", comment);
    map.put("comment_ori", comment_ori);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
    Gson gson = new Gson();
    CommentBean value = null;
    try {
        value = gson.fromJson(jsonData, CommentBean.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) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 15 with JsonSyntaxException

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

the class ReplyToCommentMsgDao method reply.

public CommentBean reply() throws WeiboException {
    String url = URLHelper.COMMENT_REPLY;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("id", id);
    map.put("cid", cid);
    map.put("comment", comment);
    map.put("comment_ori", comment_ori);
    map.put("without_mention", without_mention);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
    Gson gson = new Gson();
    CommentBean value = null;
    try {
        value = gson.fromJson(jsonData, CommentBean.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) CommentBean(org.qii.weiciyuan.bean.CommentBean)

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