Search in sources :

Example 1 with MentionsCommentTimeLineDao

use of org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao 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));
    }
}
Also used : MainCommentsTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MainCommentsTimeLineDao) UnreadBean(org.qii.weiciyuan.bean.UnreadBean) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) MentionTimeLineData(org.qii.weiciyuan.bean.android.MentionTimeLineData) MentionsCommentTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) UnreadDao(org.qii.weiciyuan.dao.unread.UnreadDao) MentionsWeiboTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MentionsWeiboTimeLineDao)

Example 2 with MentionsCommentTimeLineDao

use of org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao in project weiciyuan by qii.

the class MentionsCommentMsgLoader method loadData.

public CommentListBean loadData() throws WeiboException {
    MentionsCommentTimeLineDao dao = new MentionsCommentTimeLineDao(token);
    dao.setSince_id(sinceId);
    dao.setMax_id(maxId);
    CommentListBean result = null;
    lock.lock();
    try {
        result = dao.getGSONMsgList();
    } finally {
        lock.unlock();
    }
    return result;
}
Also used : MentionsCommentTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao) CommentListBean(org.qii.weiciyuan.bean.CommentListBean)

Aggregations

CommentListBean (org.qii.weiciyuan.bean.CommentListBean)2 MentionsCommentTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao)2 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)1 UnreadBean (org.qii.weiciyuan.bean.UnreadBean)1 CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)1 MentionTimeLineData (org.qii.weiciyuan.bean.android.MentionTimeLineData)1 MainCommentsTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MainCommentsTimeLineDao)1 MentionsWeiboTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsWeiboTimeLineDao)1 UnreadDao (org.qii.weiciyuan.dao.unread.UnreadDao)1