use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class AppNotificationCenter method addDatabaseUnreadCommentsToMe.
private void addDatabaseUnreadCommentsToMe(String accountId, CommentListBean mentions) {
CommentTimeLineData dbData = CommentToMeTimeLineDBTask.getCommentLineMsgList(accountId);
List<CommentBean> itemList = dbData.cmtList.getItemList();
TimeLinePosition position = dbData.position;
TreeSet<Long> newMsgIds = position.newMsgIds;
HashMap<Long, CommentBean> map = new HashMap<>();
for (CommentBean msg : itemList) {
map.put(msg.getIdLong(), msg);
}
for (Object object : newMsgIds) {
long id;
if (object instanceof Double) {
Double value = (Double) object;
id = value.longValue();
} else {
id = (Long) object;
}
CommentBean msg = map.get(id);
if (msg != null) {
mentions.getItemList().add(msg);
}
}
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class CommentByMeTimeLineDBTask method getCommentLineMsgList.
public static CommentTimeLineData getCommentLineMsgList(String accountId) {
TimeLinePosition position = getPosition(accountId);
CommentListBean result = new CommentListBean();
int limit = position.position + AppConfig.DB_CACHE_COUNT_OFFSET > AppConfig.DEFAULT_MSG_COUNT_50 ? position.position + AppConfig.DB_CACHE_COUNT_OFFSET : AppConfig.DEFAULT_MSG_COUNT_50;
List<CommentBean> msgList = new ArrayList<CommentBean>();
String sql = "select * from " + CommentByMeTable.CommentByMeDataTable.TABLE_NAME + " where " + CommentByMeTable.CommentByMeDataTable.ACCOUNTID + " = " + accountId + " order by " + CommentByMeTable.CommentByMeDataTable.MBLOGID + " desc limit " + limit;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(CommentByMeTable.CommentByMeDataTable.JSONDATA));
if (!TextUtils.isEmpty(json)) {
try {
CommentBean value = gson.fromJson(json, CommentBean.class);
if (!value.isMiddleUnreadItem()) {
value.getListViewSpannableString();
}
msgList.add(value);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
} else {
msgList.add(null);
}
}
result.setComments(msgList);
c.close();
return new CommentTimeLineData(result, position);
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class CommentByMeTimeLineDBTask method getPosition.
private static TimeLinePosition getPosition(String accountId) {
String sql = "select * from " + CommentByMeTable.TABLE_NAME + " where " + CommentByMeTable.ACCOUNTID + " = " + accountId;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(CommentByMeTable.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 org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class CommentToMeTimeLineDBTask method getPosition.
public static TimeLinePosition getPosition(String accountId) {
String sql = "select * from " + CommentsTable.TABLE_NAME + " where " + CommentsTable.ACCOUNTID + " = " + accountId;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(CommentsTable.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 org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class CommentToMeTimeLineDBTask method getCommentLineMsgList.
public static CommentTimeLineData getCommentLineMsgList(String accountId) {
TimeLinePosition position = getPosition(accountId);
int limit = position.position + AppConfig.DB_CACHE_COUNT_OFFSET > AppConfig.DEFAULT_MSG_COUNT_50 ? position.position + AppConfig.DB_CACHE_COUNT_OFFSET : AppConfig.DEFAULT_MSG_COUNT_50;
CommentListBean result = new CommentListBean();
List<CommentBean> msgList = new ArrayList<CommentBean>();
String sql = "select * from " + CommentsTable.CommentsDataTable.TABLE_NAME + " where " + CommentsTable.CommentsDataTable.ACCOUNTID + " = " + accountId + " order by " + CommentsTable.CommentsDataTable.MBLOGID + " desc limit " + limit;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(CommentsTable.CommentsDataTable.JSONDATA));
if (!TextUtils.isEmpty(json)) {
try {
CommentBean value = gson.fromJson(json, CommentBean.class);
if (!value.isMiddleUnreadItem()) {
value.getListViewSpannableString();
}
msgList.add(value);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
} else {
msgList.add(null);
}
}
result.setComments(msgList);
c.close();
return new CommentTimeLineData(result, position);
}
Aggregations