Search in sources :

Example 96 with Gson

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

the class ShowUserDao method getUserInfo.

public UserBean getUserInfo() throws WeiboException {
    String url = (!TextUtils.isEmpty(domain) ? URLHelper.USER_DOMAIN_SHOW : URLHelper.USER_SHOW);
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uid", uid);
    map.put("screen_name", screen_name);
    map.put("domain", domain);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, 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 97 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 98 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 99 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 100 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)

Aggregations

Gson (com.google.gson.Gson)1060 Test (org.junit.Test)236 HashMap (java.util.HashMap)200 JsonObject (com.google.gson.JsonObject)138 GsonBuilder (com.google.gson.GsonBuilder)135 CommandWrapper (ClientServerApi.CommandWrapper)123 CommandExecuter (CommandHandler.CommandExecuter)119 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)118 IOException (java.io.IOException)116 JsonSyntaxException (com.google.gson.JsonSyntaxException)100 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)96 ArrayList (java.util.ArrayList)94 Type (java.lang.reflect.Type)65 JsonElement (com.google.gson.JsonElement)57 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)53 SmartCode (BasicCommonClasses.SmartCode)50 Map (java.util.Map)45 InputStreamReader (java.io.InputStreamReader)41 BroadcastClientMessage (org.bigbluebutton.red5.client.messaging.BroadcastClientMessage)41 Location (BasicCommonClasses.Location)40