Search in sources :

Example 71 with Gson

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

the class RepostsTimeLineByIdDao method getGSONMsgList.

public RepostListBean getGSONMsgList() throws WeiboException {
    String url = URLHelper.REPOSTS_TIMELINE_BY_MSGID;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("id", id);
    map.put("since_id", since_id);
    map.put("max_id", max_id);
    map.put("count", count);
    map.put("page", page);
    map.put("filter_by_author", filter_by_author);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    RepostListBean value = null;
    try {
        value = gson.fromJson(jsonData, RepostListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    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) RepostListBean(org.qii.weiciyuan.bean.RepostListBean) HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 72 with Gson

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

the class DestroyStatusDao method destroy.

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

Example 73 with Gson

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

the class DMConversationDao method getConversationList.

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

Example 74 with Gson

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

the class FavDao method executeTask.

private FavBean executeTask(String url) throws WeiboException {
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("id", id);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
    try {
        FavBean value = new Gson().fromJson(jsonData, FavBean.class);
        if (value != null) {
            return value;
        }
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    return null;
}
Also used : FavBean(org.qii.weiciyuan.bean.FavBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 75 with Gson

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

the class GroupListDao method getInfo.

public List<String> getInfo() throws WeiboException {
    String url = URLHelper.GROUP_MEMBER_LIST;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uids", uids);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    List<GroupUser> value = null;
    try {
        value = gson.fromJson(jsonData, new TypeToken<List<GroupUser>>() {
        }.getType());
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (value != null && value.size() > 0) {
        GroupUser user = value.get(0);
        List<String> ids = new ArrayList<String>();
        for (GroupBean b : user.lists) {
            ids.add(b.getIdstr());
        }
        return ids;
    }
    return null;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) ArrayList(java.util.ArrayList) List(java.util.List) GroupBean(org.qii.weiciyuan.bean.GroupBean)

Aggregations

Gson (com.google.gson.Gson)1309 Test (org.junit.Test)280 HashMap (java.util.HashMap)227 GsonBuilder (com.google.gson.GsonBuilder)174 JsonObject (com.google.gson.JsonObject)157 IOException (java.io.IOException)147 CommandWrapper (ClientServerApi.CommandWrapper)123 ArrayList (java.util.ArrayList)121 CommandExecuter (CommandHandler.CommandExecuter)119 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)118 JsonSyntaxException (com.google.gson.JsonSyntaxException)103 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)96 JsonElement (com.google.gson.JsonElement)78 Type (java.lang.reflect.Type)77 Map (java.util.Map)63 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)53 SmartCode (BasicCommonClasses.SmartCode)50 InputStreamReader (java.io.InputStreamReader)49 List (java.util.List)49 TypeToken (com.google.gson.reflect.TypeToken)44