use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.
the class TimelineCacheUtility method addCacheData.
@Override
public void addCacheData(Setting action, Params params, IResult responseObj) {
// 如果是离线请求,忽略数据缓存
if (action.getExtras() != null && action.getExtras().containsKey("offline_action"))
return;
// 如果是用户微博
if (action.getValue().equals("statuses/user_timeline.json")) {
// 是当前登录用户
if (params.containsKey("user_id") && params.getParameter("user_id").equals(AppContext.getAccount().getUser().getIdstr())) {
} else if (params.containsKey("screen_name") && params.getParameter("screen_name").equals(AppContext.getAccount().getUser().getScreen_name())) {
} else {
return;
}
}
try {
StatusContents statusContents = (StatusContents) responseObj;
if (statusContents.getStatuses().size() == 0)
return;
boolean clear = false;
// 刷新
if (!TextUtils.isEmpty(params.getParameter("since_id"))) {
int diff = Math.abs(statusContents.getStatuses().size() - AppSettings.getTimelineCount());
clear = diff <= 3;
} else // 加载更多
if (!TextUtils.isEmpty(params.getParameter("max_id"))) {
} else // 重置
{
clear = true;
}
Extra extra = new Extra(AppContext.getAccount().getUser().getId(), getCacheKey(action, params));
if (clear) {
SinaDB.getTimelineDB().deleteAll(extra, StatusContent.class);
Logger.d(TAG, "清理数据");
}
long time = System.currentTimeMillis();
SinaDB.getTimelineDB().insert(extra, statusContents.getStatuses());
Logger.w(TAG, String.format("写入微博数据,共%d条,共耗时%sms", statusContents.getStatuses().size(), String.valueOf(System.currentTimeMillis() - time)));
CacheTimeUtils.saveTime(getCacheKey(action, params), AppContext.getAccount().getUser());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.
the class PublishDB method deletePublish.
public static void deletePublish(PublishBean bean, WeiBoUser user) {
Extra extra = new Extra(user.getIdstr(), null);
SinaDB.getDB().deleteById(extra, PublishBean.class, bean.getId());
}
use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.
the class PublishDB method updatePublish.
public static void updatePublish(PublishBean bean, WeiBoUser user) {
Extra extra = new Extra(user.getIdstr(), null);
SinaDB.getDB().insertOrReplace(extra, bean);
}
use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.
the class OfflineSettingsFragment method onPreferenceClick.
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals("pOfflineGroups")) {
final List<Group> groups = SinaDB.getOfflineSqlite().select(new Extra(AppContext.getAccount().getUser().getIdstr(), null), Group.class);
OfflineUtils.showOfflineGroupsModifyDialog(getActivity(), groups, new OfflineUtils.OnOfflineGroupSetCallback() {
@Override
public void onChanged(List<Group> newGroups) {
SinaDB.getOfflineSqlite().deleteAll(OfflineUtils.getLoggedExtra(null), Group.class);
if (newGroups == null || newGroups.size() == 0) {
} else {
SinaDB.getOfflineSqlite().insertOrReplace(OfflineUtils.getLoggedExtra(null), newGroups);
}
setGroupsSummary();
}
}, R.string.offline_groups_dialog);
}
return true;
}
use of org.aisen.android.component.orm.extra.Extra in project AisenWeiBo by wangdan.
the class BizFragment method statusDestory.
/* 结束回复评论 */
// XXX /*删除微博*/
/* 开始删除微博 */
public void statusDestory(final String id, final OnStatusDestoryCallback callback) {
final WeiBoUser user = AppContext.getAccount().getUser();
new WorkTask<String, Void, StatusContent>() {
protected void onPrepare() {
super.onPrepare();
ViewUtils.createProgressDialog(getRealActivity(), getRealString(R.string.biz_delete_status_loading), ThemeUtils.getThemeColor()).show();
}
;
protected void onFinished() {
super.onFinished();
ViewUtils.dismissProgressDialog();
}
;
protected void onSuccess(StatusContent result) {
super.onSuccess(result);
if (getRealActivity() == null) {
return;
}
callback.onStatusDestory(result);
showMessage(R.string.delete_success);
SinaDB.getTimelineDB().deleteById(new Extra(user.getIdstr(), null), StatusContent.class, result.getId());
}
;
protected void onFailure(TaskException exception) {
super.onFailure(exception);
if (getRealActivity() == null) {
return;
}
if (exception != null && "20101".equals(exception.getMessage())) {
StatusContent status = new StatusContent();
status.setId(Long.parseLong(id));
onSuccess(status);
} else if (!callback.onFaild(exception)) {
showMessage(exception.getMessage());
}
}
;
@Override
public StatusContent workInBackground(String... params) throws TaskException {
return SinaSDK.getInstance(AppContext.getAccount().getAccessToken()).statusDestroy(params[0]);
}
}.execute(id);
}
Aggregations