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));
}
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();
}
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);
}
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);
}
}
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);
}
Aggregations