Search in sources :

Example 6 with CommentBean

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);
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) Intent(android.content.Intent) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 7 with CommentBean

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);
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) Cursor(android.database.Cursor) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 8 with CommentBean

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);
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) Cursor(android.database.Cursor) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 9 with CommentBean

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;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) Cursor(android.database.Cursor) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 10 with CommentBean

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);
}
Also used : SQLException(android.database.SQLException) DatabaseUtils(android.database.DatabaseUtils) Gson(com.google.gson.Gson) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Aggregations

CommentBean (org.qii.weiciyuan.bean.CommentBean)30 Gson (com.google.gson.Gson)13 JsonSyntaxException (com.google.gson.JsonSyntaxException)9 Intent (android.content.Intent)8 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)7 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)7 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)7 MessageBean (org.qii.weiciyuan.bean.MessageBean)6 CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)5 PendingIntent (android.app.PendingIntent)4 Cursor (android.database.Cursor)4 Notification (android.app.Notification)3 NotificationManager (android.app.NotificationManager)3 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 DatabaseUtils (android.database.DatabaseUtils)3 SQLException (android.database.SQLException)3 View (android.view.View)3 ListView (android.widget.ListView)3