Search in sources :

Example 1 with UnreadCount

use of org.aisen.weibo.sina.sinasdk.bean.UnreadCount 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)

Example 2 with UnreadCount

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

the class AccountFragment method login.

// 登录账号
public static void login(AccountBean accountBean, boolean toMain) {
    if (AppContext.isLoggedIn()) {
        // 1、清理定时发布
        MyApplication.removeAllPublishAlarm();
        // 2、清理正在发布的数据
        PublishService.stopPublish();
        // 3、重新开始读取未读消息
        UnreadService.stopService();
        // 4、清理未读消息
        UnreadCountNotifier.mCount = new UnreadCount();
        // 5、清理通知栏
        PublishNotifier.cancelAll();
    }
    // 登录该账号
    AppContext.login(accountBean);
    AccountUtils.setLogedinAccount(accountBean);
    // 进入首页
    if (toMain) {
        MainActivity.login();
        MainActivity.runCheckAccountTask(accountBean);
    }
}
Also used : UnreadCount(org.aisen.weibo.sina.sinasdk.bean.UnreadCount)

Example 3 with UnreadCount

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

the class MenuFragment method setUnreadNotification.

private void setUnreadNotification() {
    // 通知
    UnreadCount unreadCount = AppContext.getAccount().getUnreadCount();
    int count = 0;
    if (unreadCount != null) {
        count = unreadCount.getCmt() + unreadCount.getMention_cmt() + unreadCount.getMention_status();
    }
    setNavMenuUnread(MENU_NOTIFICATION, count);
    // 私信
    count = 0;
    if (unreadCount != null) {
        count = unreadCount.getDm();
    }
    setNavMenuUnread(MENU_MD, count);
}
Also used : UnreadCount(org.aisen.weibo.sina.sinasdk.bean.UnreadCount)

Example 4 with UnreadCount

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

the class UnreadService method stopService.

public static void stopService() {
    clearAlarm();
    if (AppContext.isLoggedIn()) {
        UnreadCountNotifier.mCount = new UnreadCount();
    }
    Intent intent = new Intent(GlobalContext.getInstance(), UnreadService.class);
    GlobalContext.getInstance().stopService(intent);
}
Also used : UnreadCount(org.aisen.weibo.sina.sinasdk.bean.UnreadCount) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 5 with UnreadCount

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

the class AppContext method login.

public static void login(AccountBean accountBean) {
    AppContext.setAccount(accountBean);
    // 未读消息重置
    if (AppContext.getAccount().getUnreadCount() == null) {
        AppContext.getAccount().setUnreadCount(UnreadService.getUnreadCount());
    }
    if (AppContext.getAccount().getUnreadCount() == null) {
        AppContext.getAccount().setUnreadCount(new UnreadCount());
    }
    // 开启未读服务
    UnreadService.startService();
    // 刷新定时任务
    MyApplication.refreshPublishAlarm();
    // 处理点赞数据
    DoLikeAction.refreshLikeCache();
    // 停止离线服务
    if (OfflineService.getInstance() != null)
        OfflineService.stopOffline();
    // 设置友盟的账号统计
    MobclickAgent.onProfileSignIn(accountBean.getUid());
}
Also used : UnreadCount(org.aisen.weibo.sina.sinasdk.bean.UnreadCount)

Aggregations

UnreadCount (org.aisen.weibo.sina.sinasdk.bean.UnreadCount)6 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 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