Search in sources :

Example 56 with Gson

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

the class NearbyTimeLineDao method get.

public NearbyStatusListBean get() throws WeiboException {
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("lat", lat);
    map.put("long", long_fix);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, URLHelper.NEARBY_STATUS, map);
    try {
        NearbyStatusListBean value = new Gson().fromJson(jsonData, NearbyStatusListBean.class);
        if (value != null) {
            return value;
        }
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    return null;
}
Also used : NearbyStatusListBean(org.qii.weiciyuan.bean.NearbyStatusListBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 57 with Gson

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

the class OAuthDao method getOAuthUserInfo.

public UserBean getOAuthUserInfo() throws WeiboException {
    String uidJson = getOAuthUserUIDJsonData();
    String uid = "";
    try {
        JSONObject jsonObject = new JSONObject(uidJson);
        uid = jsonObject.optString("uid");
    } catch (JSONException e) {
        AppLogger.e(e.getMessage());
    }
    Map<String, String> map = new HashMap<String, String>();
    map.put("uid", uid);
    map.put("access_token", access_token);
    String url = URLHelper.USER_SHOW;
    String result = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    UserBean user = new UserBean();
    try {
        user = gson.fromJson(result, UserBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(result);
    }
    return user;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) JSONObject(org.json.JSONObject) UserBean(org.qii.weiciyuan.bean.UserBean) HashMap(java.util.HashMap) JSONException(org.json.JSONException) Gson(com.google.gson.Gson)

Example 58 with Gson

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

the class FriendGroupDao method getGroup.

public GroupListBean getGroup() throws WeiboException {
    String url = URLHelper.FRIENDSGROUP_INFO;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    GroupListBean value = null;
    try {
        value = gson.fromJson(jsonData, GroupListBean.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) GroupListBean(org.qii.weiciyuan.bean.GroupListBean)

Example 59 with Gson

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

the class FriendGroupTimeLineDao method getGSONMsgList.

public MessageListBean getGSONMsgList() 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());
        return null;
    }
    if (value != null && value.getItemList().size() > 0) {
        TimeLineUtility.filterMessage(value);
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) Gson(com.google.gson.Gson)

Example 60 with Gson

use of com.google.gson.Gson 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)

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