use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.
the class UnreadMsgReceiver method showNotification.
private void showNotification(Context context, AccountBean accountBean, MessageListBean mentionsWeiboData, CommentListBean commentsToMeData, CommentListBean mentionsCommentData, UnreadBean unreadBean) {
Intent clickNotificationToOpenAppPendingIntentInner = MainTimeLineActivity.newIntent(accountBean, mentionsWeiboData, mentionsCommentData, commentsToMeData, unreadBean);
clickNotificationToOpenAppPendingIntentInner.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
String accountId = accountBean.getUid();
Set<String> dbUnreadMentionsWeibo = NotificationDBTask.getUnreadMsgIds(accountId, NotificationDBTask.UnreadDBType.mentionsWeibo);
Set<String> dbUnreadMentionsComment = NotificationDBTask.getUnreadMsgIds(accountId, NotificationDBTask.UnreadDBType.mentionsComment);
Set<String> dbUnreadCommentsToMe = NotificationDBTask.getUnreadMsgIds(accountId, NotificationDBTask.UnreadDBType.commentsToMe);
if (mentionsWeiboData != null && mentionsWeiboData.getSize() > 0) {
List<MessageBean> msgList = mentionsWeiboData.getItemList();
Iterator<MessageBean> iterator = msgList.iterator();
while (iterator.hasNext()) {
MessageBean msg = iterator.next();
if (dbUnreadMentionsWeibo.contains(msg.getId())) {
iterator.remove();
}
}
}
if (mentionsCommentData != null && mentionsCommentData.getSize() > 0) {
List<CommentBean> msgList = mentionsCommentData.getItemList();
Iterator<CommentBean> iterator = msgList.iterator();
while (iterator.hasNext()) {
CommentBean msg = iterator.next();
if (dbUnreadMentionsComment.contains(msg.getId())) {
iterator.remove();
}
}
}
if (commentsToMeData != null && commentsToMeData.getSize() > 0) {
List<CommentBean> msgList = commentsToMeData.getItemList();
Iterator<CommentBean> iterator = msgList.iterator();
while (iterator.hasNext()) {
CommentBean msg = iterator.next();
if (dbUnreadCommentsToMe.contains(msg.getId())) {
iterator.remove();
}
}
}
boolean mentionsWeibo = (mentionsWeiboData != null && mentionsWeiboData.getSize() > 0);
boolean mentionsComment = (mentionsCommentData != null && mentionsCommentData.getSize() > 0);
boolean commentsToMe = (commentsToMeData != null && commentsToMeData.getSize() > 0);
if (!mentionsWeibo && !mentionsComment && !commentsToMe) {
return;
}
// boolean commentsToMeDataSizeIsLarge = (commentsToMeData != null) && (
// commentsToMeData.getSize() >= Integer.valueOf(
// SettingUtility.getMsgCount()));
//
// boolean mentionsWeiboDataSizeIsLarge = (mentionsWeiboData != null) && (
// mentionsWeiboData.getSize() >= Integer.valueOf(
// SettingUtility.getMsgCount()));
//
// boolean mentionsCommentDataSizeIsLarge = (mentionsCommentData != null) && (
// mentionsCommentData.getSize() >= Integer.valueOf(
// SettingUtility.getMsgCount()));
//
// boolean showSimpleTextNotification = commentsToMeDataSizeIsLarge
// || mentionsWeiboDataSizeIsLarge || mentionsCommentDataSizeIsLarge;
// if (showSimpleTextNotification) {
// String ticker = NotificationUtility
// .getTicker(unreadBean);
// Intent intent = new Intent(context,
// SimpleTextNotificationService.class);
//
// intent.putExtra(NotificationServiceHelper.ACCOUNT_ARG, accountBean);
// intent.putExtra(NotificationServiceHelper.UNREAD_ARG, unreadBean);
// intent.putExtra(NotificationServiceHelper.PENDING_INTENT_INNER_ARG,
// clickNotificationToOpenAppPendingIntentInner);
// intent.putExtra(NotificationServiceHelper.TICKER, ticker);
// context.startService(intent);
//
// } else {
String ticker = NotificationUtility.getTicker(unreadBean, mentionsWeiboData, mentionsCommentData, commentsToMeData);
Intent intent = BigTextNotificationService.newIntent(accountBean, mentionsWeiboData, commentsToMeData, mentionsCommentData, unreadBean, clickNotificationToOpenAppPendingIntentInner, ticker, 0);
context.startService(intent);
}
use of org.qii.weiciyuan.bean.CommentBean 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.CommentBean 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.CommentBean 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;
}
use of org.qii.weiciyuan.bean.CommentBean 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);
}
Aggregations