Search in sources :

Example 16 with WeiBoUser

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) TaskException(org.aisen.android.network.task.TaskException) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser) Token(org.aisen.weibo.sina.sinasdk.bean.Token)

Example 17 with WeiBoUser

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);
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) Extra(org.aisen.android.component.orm.extra.Extra) TaskException(org.aisen.android.network.task.TaskException) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)

Example 18 with WeiBoUser

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();
}
Also used : TaskException(org.aisen.android.network.task.TaskException) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser) Token(org.aisen.weibo.sina.sinasdk.bean.Token)

Example 19 with WeiBoUser

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);
}
Also used : WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)

Example 20 with WeiBoUser

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;
}
Also used : Friendship(org.aisen.weibo.sina.sinasdk.bean.Friendship) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)

Aggregations

WeiBoUser (org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)21 TaskException (org.aisen.android.network.task.TaskException)8 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)6 ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)4 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 Friendship (org.aisen.weibo.sina.sinasdk.bean.Friendship)3 Token (org.aisen.weibo.sina.sinasdk.bean.Token)3 Bitmap (android.graphics.Bitmap)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 NonNull (android.support.annotation.NonNull)2 LayoutInflater (android.view.LayoutInflater)2 FrameLayout (android.widget.FrameLayout)2 DialogAction (com.afollestad.materialdialogs.DialogAction)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 FadeInDisplayer (org.aisen.android.component.bitmaploader.display.FadeInDisplayer)2 Extra (org.aisen.android.component.orm.extra.Extra)2 StatusComment (org.aisen.weibo.sina.sinasdk.bean.StatusComment)2 Intent (android.content.Intent)1