Search in sources :

Example 1 with Extra

use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.

the class OfflineSettingsFragment method setGroupsSummary.

private void setGroupsSummary() {
    List<Group> groups = SinaDB.getOfflineSqlite().select(new Extra(AppContext.getAccount().getUser().getIdstr(), null), Group.class);
    String summary = "";
    if (groups.size() == 0) {
        summary = getString(R.string.offline_none_groups) + ",";
    } else {
        for (Group group : groups) {
            summary = summary + group.getName() + ",";
        }
    }
    pOfflineGroups.setSummary(summary.substring(0, summary.length() - 1));
}
Also used : Group(org.aisen.weibo.sina.sinasdk.bean.Group) Extra(org.aisen.android.component.orm.extra.Extra)

Example 2 with Extra

use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.

the class BizFragment method commentDestory.

// XXX /*删除评论*/
/* 删除评论 */
public void commentDestory(final StatusComment commnet, final OnCommentDestoryCallback callback) {
    final WeiBoUser user = AppContext.getAccount().getUser();
    new WorkTask<Void, Void, StatusComment>() {

        protected void onPrepare() {
            super.onPrepare();
            ViewUtils.createProgressDialog(getRealActivity(), getRealString(R.string.biz_delete_cmt_loading), ThemeUtils.getThemeColor()).show();
        }

        ;

        protected void onFinished() {
            super.onFinished();
            ViewUtils.dismissProgressDialog();
        }

        ;

        protected void onSuccess(StatusComment result) {
            super.onSuccess(result);
            if (getRealActivity() == null) {
                return;
            }
            if (callback != null)
                callback.onCommentDestory(commnet);
            showMessage(R.string.delete_success);
            // 删除成功后,DB同时也删除
            SinaDB.getTimelineDB().deleteById(new Extra(user.getIdstr(), null), StatusComment.class, result.getId());
        }

        ;

        protected void onFailure(TaskException exception) {
            super.onFailure(exception);
            if (getRealActivity() == null) {
                return;
            }
            if (!TextUtils.isEmpty(exception.getMessage()))
                showMessage(exception.getMessage());
            else
                showMessage(R.string.delete_faild);
        }

        ;

        @Override
        public StatusComment workInBackground(Void... params) throws TaskException {
            return SinaSDK.getInstance(AppContext.getAccount().getAccessToken()).commentsDestory(commnet.getId());
        }
    }.execute();
}
Also used : Extra(org.aisen.android.component.orm.extra.Extra) TaskException(org.aisen.android.network.task.TaskException) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser) StatusComment(org.aisen.weibo.sina.sinasdk.bean.StatusComment)

Example 3 with Extra

use of org.aisen.android.component.orm.extra.Extra 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 4 with Extra

use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.

the class OfflineUtils method toggleOffline.

/**
     * 触发一次离线,如果没有设置过离线分组,优先设置后再离线
     *
     * @param context
     */
public static void toggleOffline(final Activity context) {
    if (!AppContext.isLoggedIn())
        return;
    List<Group> groups = SinaDB.getOfflineSqlite().select(new Extra(AppContext.getAccount().getUser().getIdstr(), null), Group.class);
    if (groups.size() == 0) {
        Logger.d(TAG, "离线分组未设置过");
        new AlertDialogWrapper.Builder(context).setMessage(R.string.offline_none_groups_remind).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                showOfflineGroupsModifyDialog(context, new ArrayList<Group>(), new OnOfflineGroupSetCallback() {

                    @Override
                    public void onChanged(List<Group> newGroups) {
                        // 设置离线分组
                        Logger.d(TAG, "设置离线分组%d个", newGroups.size());
                        if (newGroups.size() > 0) {
                            SinaDB.getOfflineSqlite().insert(getLoggedExtra(null), newGroups);
                            toggleOffline(context);
                        }
                    }
                }, R.string.offline_groups_dialog);
            }
        }).show();
    } else {
        OfflineService.startOffline((ArrayList) groups);
    }
}
Also used : Group(org.aisen.weibo.sina.sinasdk.bean.Group) Extra(org.aisen.android.component.orm.extra.Extra) DialogInterface(android.content.DialogInterface)

Example 5 with Extra

use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.

the class PublishDB method addPublish.

public static void addPublish(PublishBean bean, WeiBoUser user) {
    Extra extra = new Extra(user.getIdstr(), null);
    SinaDB.getDB().insertOrReplace(extra, bean);
}
Also used : Extra(org.aisen.android.component.orm.extra.Extra)

Aggregations

Extra (org.aisen.android.component.orm.extra.Extra)15 TaskException (org.aisen.android.network.task.TaskException)3 Group (org.aisen.weibo.sina.sinasdk.bean.Group)3 StatusComment (org.aisen.weibo.sina.sinasdk.bean.StatusComment)3 StatusComments (org.aisen.weibo.sina.sinasdk.bean.StatusComments)2 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)2 StatusContents (org.aisen.weibo.sina.sinasdk.bean.StatusContents)2 WeiBoUser (org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)2 DialogInterface (android.content.DialogInterface)1 ArrayList (java.util.ArrayList)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 JokeBeans (org.aisen.weibo.sina.support.bean.JokeBeans)1 OfflineUtils (org.aisen.weibo.sina.support.utils.OfflineUtils)1