Search in sources :

Example 66 with Gson

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

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

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

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

Example 70 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)

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