use of com.google.gson.Gson in project weiciyuan by qii.
the class MentionCommentsTimeLineDBTask method updatePosition.
private static void updatePosition(TimeLinePosition position, String accountId) {
String sql = "select * from " + MentionCommentsTable.TABLE_NAME + " where " + MentionCommentsTable.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(MentionCommentsTable.TIMELINEDATA, gson.toJson(position));
getWsd().update(MentionCommentsTable.TABLE_NAME, cv, MentionCommentsTable.ACCOUNTID + "=?", args);
} catch (JsonSyntaxException e) {
}
} else {
ContentValues cv = new ContentValues();
cv.put(MentionCommentsTable.ACCOUNTID, accountId);
cv.put(MentionCommentsTable.TIMELINEDATA, gson.toJson(position));
getWsd().insert(MentionCommentsTable.TABLE_NAME, MentionCommentsTable.ID, cv);
}
}
use of com.google.gson.Gson in project weiciyuan by qii.
the class MentionCommentsTimeLineDBTask method addCommentLineMsg.
public static void addCommentLineMsg(CommentListBean list, String accountId) {
Gson gson = new Gson();
List<CommentBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), MentionCommentsTable.MentionCommentsDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(MentionCommentsTable.MentionCommentsDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(MentionCommentsTable.MentionCommentsDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(MentionCommentsTable.MentionCommentsDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (CommentBean msg : msgList) {
ih.prepareForInsert();
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceCommentTable(accountId);
}
use of com.google.gson.Gson in project weiciyuan by qii.
the class MentionCommentsTimeLineDBTask method getPosition.
public static TimeLinePosition getPosition(String accountId) {
String sql = "select * from " + MentionCommentsTable.TABLE_NAME + " where " + MentionCommentsTable.ACCOUNTID + " = " + accountId;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(MentionCommentsTable.TIMELINEDATA));
if (!TextUtils.isEmpty(json)) {
try {
TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
c.close();
return value;
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
}
c.close();
return TimeLinePosition.empty();
}
use of com.google.gson.Gson in project weiciyuan by qii.
the class MentionWeiboTimeLineDBTask method getPosition.
public static TimeLinePosition getPosition(String accountId) {
String sql = "select * from " + RepostsTable.TABLE_NAME + " where " + RepostsTable.ACCOUNTID + " = " + accountId;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(RepostsTable.TIMELINEDATA));
if (!TextUtils.isEmpty(json)) {
try {
TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
c.close();
return value;
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
}
c.close();
return TimeLinePosition.empty();
}
use of com.google.gson.Gson in project weiciyuan by qii.
the class DraftDBManager method insertReply.
public void insertReply(String content, CommentBean commentBean, String accountId) {
ContentValues cv = new ContentValues();
cv.put(DraftTable.CONTENT, content);
cv.put(DraftTable.ACCOUNTID, accountId);
cv.put(DraftTable.JSONDATA, new Gson().toJson(commentBean));
cv.put(DraftTable.TYPE, DraftTable.TYPE_REPLY);
wsd.insert(DraftTable.TABLE_NAME, DraftTable.ID, cv);
}
Aggregations