use of org.qii.weiciyuan.bean.android.CommentTimeLineData 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.CommentTimeLineData in project weiciyuan by qii.
the class FetchNewMsgService method fetchMsg.
private void fetchMsg(AccountBean accountBean) throws WeiboException {
CommentListBean commentResult = null;
MessageListBean mentionStatusesResult = null;
CommentListBean mentionCommentsResult = null;
UnreadBean unreadBean = null;
String token = accountBean.getAccess_token();
UnreadDao unreadDao = new UnreadDao(token, accountBean.getUid());
unreadBean = unreadDao.getCount();
if (unreadBean == null) {
return;
}
int unreadCommentCount = unreadBean.getCmt();
int unreadMentionStatusCount = unreadBean.getMention_status();
int unreadMentionCommentCount = unreadBean.getMention_cmt();
if (unreadCommentCount > 0 && SettingUtility.allowCommentToMe()) {
MainCommentsTimeLineDao dao = new MainCommentsTimeLineDao(token);
CommentListBean oldData = null;
CommentTimeLineData commentTimeLineData = CommentToMeTimeLineDBTask.getCommentLineMsgList(accountBean.getUid());
if (commentTimeLineData != null) {
oldData = commentTimeLineData.cmtList;
}
if (oldData != null && oldData.getSize() > 0) {
dao.setSince_id(oldData.getItem(0).getId());
}
commentResult = dao.getGSONMsgListWithoutClearUnread();
}
if (unreadMentionStatusCount > 0 && SettingUtility.allowMentionToMe()) {
MentionsWeiboTimeLineDao dao = new MentionsWeiboTimeLineDao(token);
MessageListBean oldData = null;
MentionTimeLineData mentionStatusTimeLineData = MentionWeiboTimeLineDBTask.getRepostLineMsgList(accountBean.getUid());
if (mentionStatusTimeLineData != null) {
oldData = mentionStatusTimeLineData.msgList;
}
if (oldData != null && oldData.getSize() > 0) {
dao.setSince_id(oldData.getItem(0).getId());
}
mentionStatusesResult = dao.getGSONMsgListWithoutClearUnread();
}
if (unreadMentionCommentCount > 0 && SettingUtility.allowMentionCommentToMe()) {
MainCommentsTimeLineDao dao = new MentionsCommentTimeLineDao(token);
CommentListBean oldData = null;
CommentTimeLineData commentTimeLineData = MentionCommentsTimeLineDBTask.getCommentLineMsgList(accountBean.getUid());
if (commentTimeLineData != null) {
oldData = commentTimeLineData.cmtList;
}
if (oldData != null && oldData.getSize() > 0) {
dao.setSince_id(oldData.getItem(0).getId());
}
mentionCommentsResult = dao.getGSONMsgListWithoutClearUnread();
}
clearDatabaseUnreadInfo(accountBean.getUid(), unreadBean.getMention_status(), unreadBean.getMention_cmt(), unreadBean.getCmt());
boolean mentionsWeibo = (mentionStatusesResult != null && mentionStatusesResult.getSize() > 0);
boolean mentionsComment = (mentionCommentsResult != null && mentionCommentsResult.getSize() > 0);
boolean commentsToMe = (commentResult != null && commentResult.getSize() > 0);
if (mentionsWeibo || mentionsComment || commentsToMe) {
sendTwoKindsOfBroadcast(accountBean, commentResult, mentionStatusesResult, mentionCommentsResult, unreadBean);
} else {
// NotificationManager notificationManager = (NotificationManager) getApplicationContext()
// .getSystemService(NOTIFICATION_SERVICE);
// notificationManager.cancel(
// NotificationServiceHelper.getMentionsWeiboNotificationId(accountBean));
}
}
use of org.qii.weiciyuan.bean.android.CommentTimeLineData 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.CommentTimeLineData 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);
}
use of org.qii.weiciyuan.bean.android.CommentTimeLineData in project weiciyuan by qii.
the class MentionCommentsTimeLineDBTask 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 " + MentionCommentsTable.MentionCommentsDataTable.TABLE_NAME + " where " + MentionCommentsTable.MentionCommentsDataTable.ACCOUNTID + " = " + accountId + " order by " + MentionCommentsTable.MentionCommentsDataTable.MBLOGID + " desc limit " + limit;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(MentionCommentsTable.MentionCommentsDataTable.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();
CommentTimeLineData mentionTimeLineData = new CommentTimeLineData(result, position);
return mentionTimeLineData;
}
Aggregations