use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class BizFragment method destoryFriendship.
/* 结束查看用户微博 */
// XXX /*取消对某用户的关注*/
public void destoryFriendship(final WeiBoUser user, final OnDestoryFriendshipCallback callback) {
Token token = AppContext.getAccount().getAccessToken();
if (AppContext.getAccount().getAdvancedToken() != null)
token = AppContext.getAccount().getAdvancedToken();
final Token trueToken = token;
new MaterialDialog.Builder(getRealActivity()).content(R.string.biz_destory_friend).negativeText(R.string.no).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
new WorkTask<Void, Void, WeiBoUser>() {
@Override
public WeiBoUser workInBackground(Void... params) throws TaskException {
return SinaSDK.getInstance(trueToken).friendshipsDestroy(user.getIdstr());
}
@Override
protected void onPrepare() {
super.onPrepare();
ViewUtils.createProgressDialog(getRealActivity(), getRealString(R.string.biz_destory_friendship), ThemeUtils.getThemeColor()).show();
}
@Override
protected void onFailure(TaskException exception) {
super.onFailure(exception);
showMessage(exception.getMessage());
}
@Override
protected void onSuccess(WeiBoUser result) {
super.onSuccess(result);
if (getRealActivity() == null) {
return;
}
callback.onFriendshipDestoryed(result);
}
@Override
protected void onFinished() {
super.onFinished();
if (getRealActivity() == null) {
return;
}
ViewUtils.dismissProgressDialog();
}
}.execute();
}
}).show();
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser 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);
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class BizFragment method createFriendship.
/* 结束取消对某用户的关注 */
// XXX /*添加关注*/
public void createFriendship(final WeiBoUser user, final OnCreateFriendshipCallback callback) {
Token token = AppContext.getAccount().getAccessToken();
if (AppContext.getAccount().getAdvancedToken() != null)
token = AppContext.getAccount().getAdvancedToken();
final Token trueToken = token;
new WorkTask<Void, Void, WeiBoUser>() {
@Override
public WeiBoUser workInBackground(Void... params) throws TaskException {
return SinaSDK.getInstance(trueToken).friendshipsCreate(user.getIdstr());
}
@Override
protected void onPrepare() {
super.onPrepare();
ViewUtils.createProgressDialog(getRealActivity(), getRealString(R.string.biz_create_friendship), ThemeUtils.getThemeColor()).show();
}
@Override
protected void onFailure(TaskException exception) {
super.onFailure(exception);
if (getRealActivity() == null) {
return;
}
showMessage(exception.getMessage());
}
@Override
protected void onSuccess(WeiBoUser result) {
super.onSuccess(result);
if (getRealActivity() == null) {
return;
}
callback.onFriendshipCreated(result);
}
@Override
protected void onFinished() {
super.onFinished();
if (getRealActivity() == null) {
return;
}
ViewUtils.dismissProgressDialog();
}
}.execute();
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class TimelineCommentItemView method onBindData.
@Override
public void onBindData(View convertView, StatusComment data, int position) {
WeiBoUser user = data.getUser();
if (user != null) {
BitmapLoader.getInstance().display(mFragment, AisenUtils.getUserPhoto(user), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
bizFragment.userShow(imgPhoto, user);
txtName.setText(AisenUtils.getUserScreenName(user));
} else {
bizFragment.userShow(imgPhoto, null);
txtName.setText(R.string.error_cmts);
imgPhoto.setImageResource(R.drawable.user_placeholder);
}
txtContent.setContent(AisenUtils.getCommentText(data.getText()));
AisenUtils.setTextSize(txtContent);
String createAt = AisenUtils.convDate(data.getCreated_at());
String from = String.format("%s", Html.fromHtml(data.getSource()));
String desc = String.format("%s %s", createAt, from);
txtDesc.setText(desc);
int top = position == 0 ? firstTop : normalTop;
convertView.setPadding(convertView.getPaddingLeft(), top, convertView.getPaddingRight(), convertView.getPaddingBottom());
if (data.isPicture()) {
imgPic.setVisibility(View.VISIBLE);
imgPic.display(data.getVideoUrl().getUrl_short());
} else {
imgPic.setVisibility(View.GONE);
}
// 源评论
if (data.getReply_comment() != null) {
layRe.setVisibility(View.VISIBLE);
txtReContent.setContent(AisenUtils.getCommentText(data.getReply_comment().getText()));
AisenUtils.setTextSize(txtReContent);
if (data.getReply_comment().getUser() != null) {
BitmapLoader.getInstance().display(mFragment, AisenUtils.getUserPhoto(data.getReply_comment().getUser()), imgRePhoto, ImageConfigUtils.getLargePhotoConfig());
bizFragment.userShow(imgRePhoto, data.getReply_comment().getUser());
} else {
bizFragment.userShow(imgRePhoto, null);
}
} else {
layRe.setVisibility(View.GONE);
}
btnLike.setTag(data);
setLikeBtn(data);
btnLike.setOnClickListener(this);
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class BilateralDB method findCacheData.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IResult findCacheData(Setting action, Params params) {
List<WeiBoUser> userList = selectAll();
if (userList.size() > 0) {
Friendship users = new Friendship();
users.setUsers(userList);
users.setFromCache(true);
users.setOutofdate(CacheTimeUtils.isOutofdate("Bilateral", AppContext.getAccount().getUser()));
users.setNext_cursor(ActivityHelper.getIntShareData(GlobalContext.getInstance(), "Bilateral" + AppContext.getAccount().getUser().getIdstr(), 0));
return users;
}
return null;
}
Aggregations