Search in sources :

Example 21 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException 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 22 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException 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 23 with JsonSyntaxException

use of com.google.gson.JsonSyntaxException 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 24 with JsonSyntaxException

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

Example 25 with JsonSyntaxException

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

the class CommentByMeTimeLineDBTask method updatePosition.

private static void updatePosition(TimeLinePosition position, String accountId) {
    String sql = "select * from " + CommentByMeTable.TABLE_NAME + " where " + CommentByMeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    if (c.moveToNext()) {
        try {
            String[] args = { accountId };
            ContentValues cv = new ContentValues();
            cv.put(CommentByMeTable.TIMELINEDATA, gson.toJson(position));
            getWsd().update(CommentByMeTable.TABLE_NAME, cv, CommentByMeTable.ACCOUNTID + "=?", args);
        } catch (JsonSyntaxException e) {
        }
    } else {
        ContentValues cv = new ContentValues();
        cv.put(CommentByMeTable.ACCOUNTID, accountId);
        cv.put(CommentByMeTable.TIMELINEDATA, gson.toJson(position));
        getWsd().insert(CommentByMeTable.TABLE_NAME, CommentByMeTable.ID, cv);
    }
}
Also used : ContentValues(android.content.ContentValues) JsonSyntaxException(com.google.gson.JsonSyntaxException) Gson(com.google.gson.Gson) Cursor(android.database.Cursor)

Aggregations

JsonSyntaxException (com.google.gson.JsonSyntaxException)152 Gson (com.google.gson.Gson)103 HashMap (java.util.HashMap)40 Cursor (android.database.Cursor)33 ArrayList (java.util.ArrayList)26 IOException (java.io.IOException)24 MessageBean (org.qii.weiciyuan.bean.MessageBean)16 GsonBuilder (com.google.gson.GsonBuilder)15 BadRequestException (co.cask.cdap.common.BadRequestException)14 InputStreamReader (java.io.InputStreamReader)14 ContentValues (android.content.ContentValues)12 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)12 Reader (java.io.Reader)10 Type (java.lang.reflect.Type)10 FileReader (java.io.FileReader)9 Path (javax.ws.rs.Path)9 CommentBean (org.qii.weiciyuan.bean.CommentBean)9 UserBean (org.qii.weiciyuan.bean.UserBean)9 JsonObject (com.google.gson.JsonObject)8 List (java.util.List)8