Search in sources :

Example 1 with SetCount

use of org.aisen.weibo.sina.sinasdk.bean.SetCount in project AisenWeiBo by wangdan.

the class BizFragment method remindSetCount.

public void remindSetCount(final RemindType remindType) {
    // 测试通知功能时,不清零
    if (AppSettings.ignoreUnread()) {
        return;
    }
    final String uid = AppContext.getAccount().getUser().getIdstr();
    new WorkTask<RemindType, Void, SetCount>() {

        @Override
        public SetCount workInBackground(RemindType... params) throws TaskException {
            return SinaSDK.getInstance(AppContext.getAccount().getAccessToken()).remindSetCount(params[0].toString());
        }

        @Override
        protected void onSuccess(SetCount result) {
            super.onSuccess(result);
            if (getRealActivity() == null)
                return;
            UnreadCount count = AppContext.getAccount().getUnreadCount();
            if (count != null) {
                UnreadCountNotifier notifier = new UnreadCountNotifier(getRealActivity());
                if (remindType == RemindType.cmt) {
                    count.setCmt(0);
                    notifier.cancelNotification(Notifier.RemindUnreadComments);
                } else if (remindType == RemindType.follower) {
                    count.setFollower(0);
                    notifier.cancelNotification(Notifier.RemindUnreadForFollowers);
                } else if (remindType == RemindType.mention_cmt) {
                    count.setMention_cmt(0);
                    notifier.cancelNotification(Notifier.RemindUnreadForMentionComments);
                } else if (remindType == RemindType.mention_status) {
                    count.setMention_status(0);
                    notifier.cancelNotification(Notifier.RemindUnreadForMentionStatus);
                }
                // 更新DB
                SinaDB.getDB().insert(new Extra(uid, null), count);
                AppContext.getAccount().setUnreadCount(count);
                UnreadCountNotifier.mCount = count;
                // 发出广播更新状态
                UnreadService.sendUnreadBroadcast();
            }
        }

        ;
    }.execute(remindType);
}
Also used : SetCount(org.aisen.weibo.sina.sinasdk.bean.SetCount) UnreadCount(org.aisen.weibo.sina.sinasdk.bean.UnreadCount) TaskException(org.aisen.android.network.task.TaskException) Extra(org.aisen.android.component.orm.extra.Extra) UnreadCountNotifier(org.aisen.weibo.sina.service.notifier.UnreadCountNotifier)

Aggregations

Extra (org.aisen.android.component.orm.extra.Extra)1 TaskException (org.aisen.android.network.task.TaskException)1 UnreadCountNotifier (org.aisen.weibo.sina.service.notifier.UnreadCountNotifier)1 SetCount (org.aisen.weibo.sina.sinasdk.bean.SetCount)1 UnreadCount (org.aisen.weibo.sina.sinasdk.bean.UnreadCount)1