use of org.aisen.weibo.sina.sinasdk.bean.StatusComment in project AisenWeiBo by wangdan.
the class TimelineCommentFragment method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
super.onItemClick(parent, view, position, id);
if (getAdapterItems().size() == 0) {
return;
}
final StatusComment comment = getAdapterItems().get(position);
final String[] commentMenuArr = GlobalContext.getInstance().getResources().getStringArray(R.array.cmt_menus);
if (mStatusContent != null)
comment.setStatus(mStatusContent);
final List<String> menuList = new ArrayList<String>();
// 回复
if (comment.getUser() != null && !comment.getUser().getId().equals(AppContext.getAccount().getUser().getId()))
menuList.add(commentMenuArr[3]);
// 转发
if (comment.getStatus() != null && (comment.getUser() != null && !comment.getUser().getIdstr().equals(AppContext.getAccount().getUser().getIdstr())))
menuList.add(commentMenuArr[1]);
// 复制
menuList.add(commentMenuArr[0]);
// 删除
if (comment.getUser() != null && AppContext.getAccount().getUser().getIdstr().equals(comment.getUser().getIdstr()))
menuList.add(commentMenuArr[2]);
new AlertDialogWrapper.Builder(getActivity()).setTitle(comment.getUser().getScreen_name()).setItems(menuList.toArray(new String[0]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AisenUtils.commentMenuSelected(TimelineCommentFragment.this, menuList.toArray(new String[0])[which], comment);
}
}).show();
}
use of org.aisen.weibo.sina.sinasdk.bean.StatusComment in project AisenWeiBo by wangdan.
the class PublishCommentReplyFragment method layoutInit.
@Override
protected void layoutInit(LayoutInflater inflater, Bundle savedInstanceState) {
super.layoutInit(inflater, savedInstanceState);
btnCamera.setVisibility(View.GONE);
btnOverflow.setVisibility(View.GONE);
editContent.setHint(R.string.publish_cmt_def);
if (getPublishBean().getExtras() != null && getPublishBean().getExtras().containsKey("append"))
editContent.setText(getPublishBean().getExtras().getParameter("append"));
StatusComment mComment = getPublishBean().getStatusComment();
txtContent.setText(AisenUtils.getCommentText(mComment.getText()));
if (mComment.getUser() != null)
BitmapLoader.getInstance().display(this, AisenUtils.getUserPhoto(mComment.getUser()), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
checkBox.setChecked(Boolean.parseBoolean(getPublishBean().getExtras().getParameter("forward")));
checkBox.setOnCheckedChangeListener(this);
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
((BaseActivity) getActivity()).getSupportActionBar().setTitle(R.string.title_reply_cmt);
}
use of org.aisen.weibo.sina.sinasdk.bean.StatusComment 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.weibo.sina.sinasdk.bean.StatusComment in project AisenWeiBo by wangdan.
the class CommentCacheUtility method addCacheData.
@Override
public void addCacheData(Setting action, Params params, IResult result) {
if (!AppContext.isLoggedIn())
return;
try {
StatusComments cmts = (StatusComments) result;
List<StatusComment> newList = new ArrayList<StatusComment>();
boolean clear = false;
// 刷新
if (!TextUtils.isEmpty(params.getParameter("since_id"))) {
int diff = Math.abs(cmts.getComments().size() - AppSettings.getCommentCount());
clear = diff <= 3;
} else // 加载更多
if (!TextUtils.isEmpty(params.getParameter("max_id"))) {
} else // 重置
{
clear = true;
}
Extra extra = getExtra(params, action, AppContext.getAccount().getUser());
long time = System.currentTimeMillis();
if (clear) {
SinaDB.getTimelineDB().deleteAll(extra, StatusComment.class);
Logger.d(TAG, "清理数据");
}
SinaDB.getTimelineDB().insert(extra, cmts.getComments());
Logger.w(TAG, String.format("写入评论数据,共%d条,共耗时%sms", newList.size(), String.valueOf(System.currentTimeMillis() - time)));
// 如果是重置数据,刷新缓存时间
if (!params.containsKey("max_id")) {
CacheTimeUtils.saveTime(getExtra(params, action, AppContext.getAccount().getUser()).getKey(), AppContext.getAccount().getUser());
}
} catch (Exception e) {
}
}
use of org.aisen.weibo.sina.sinasdk.bean.StatusComment in project AisenWeiBo by wangdan.
the class CommentCacheUtility method findCacheData.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IResult findCacheData(Setting action, Params params) {
if (AppSettings.isDisableCache())
return null;
if (!AppContext.isLoggedIn())
return null;
try {
long time = System.currentTimeMillis();
Extra extra = getExtra(params, action, AppContext.getAccount().getUser());
List<StatusComment> cmtList = SinaDB.getTimelineDB().select(extra, StatusComment.class);
if (cmtList.size() > 0) {
StatusComments cmts = new StatusComments();
cmts.setFromCache(true);
cmts.setOutofdate(CacheTimeUtils.isOutofdate(getExtra(params, action, AppContext.getAccount().getUser()).getKey(), AppContext.getAccount().getUser()));
cmts.setComments(cmtList);
Logger.w(TAG, String.format("读取缓存耗时%sms", String.valueOf(System.currentTimeMillis() - time)));
Logger.d(TAG, String.format("返回评论数据%d条, expired = %s", cmts.getComments().size(), String.valueOf(cmts.outofdate())));
return cmts;
}
} catch (Exception e) {
}
return null;
}
Aggregations