Search in sources :

Example 76 with Gson

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

the class ModifyGroupMemberDao method executeTask.

private UserBean executeTask(String url) throws WeiboException {
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uid", uid);
    map.put("list_id", list_id);
    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 77 with Gson

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

the class UpdateGroupNameDao method update.

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

Example 78 with Gson

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

the class StatusesTimeLineDao method getGSONMsgList.

public MessageListBean getGSONMsgList() throws WeiboException {
    String url = URLHelper.STATUSES_TIMELINE_BY_ID;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uid", uid);
    map.put("since_id", since_id);
    map.put("max_id", max_id);
    map.put("count", count);
    map.put("page", page);
    map.put("screen_name", screen_name);
    map.put("base_app", base_app);
    map.put("feature", feature);
    map.put("trim_user", trim_user);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    MessageListBean value = null;
    try {
        value = gson.fromJson(jsonData, MessageListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (value != null && value.getSize() > 0) {
        for (MessageBean b : value.getItemList()) {
            TimeUtility.dealMills(b);
            TimeLineUtility.addJustHighLightLinks(b);
        }
    }
    return value;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) Gson(com.google.gson.Gson)

Example 79 with Gson

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

the class AccountDBTask method updateMyProfile.

public static void updateMyProfile(AccountBean account, UserBean value) {
    String uid = account.getUid();
    String json = new Gson().toJson(value);
    ContentValues cv = new ContentValues();
    cv.put(AccountTable.UID, uid);
    cv.put(AccountTable.INFOJSON, json);
    int c = getWsd().update(AccountTable.TABLE_NAME, cv, AccountTable.UID + "=?", new String[] { uid });
}
Also used : ContentValues(android.content.ContentValues) Gson(com.google.gson.Gson)

Example 80 with Gson

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

the class AtUsersDBTask method get.

public static List<AtUserBean> get(SQLiteDatabase db, String accountId) {
    List<AtUserBean> msgList = new ArrayList<AtUserBean>();
    String sql = "select * from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + "  = " + accountId + " order by " + AtUsersTable.ID + " desc";
    Cursor c = db.rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(AtUsersTable.JSONDATA));
        try {
            AtUserBean value = gson.fromJson(json, AtUserBean.class);
            msgList.add(value);
        } catch (JsonSyntaxException e) {
            AppLogger.e(e.getMessage());
        }
    }
    c.close();
    return msgList;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) ArrayList(java.util.ArrayList) AtUserBean(org.qii.weiciyuan.bean.AtUserBean) Gson(com.google.gson.Gson) Cursor(android.database.Cursor)

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