Search in sources :

Example 11 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class TimelineItemView method onBindData.

@Override
public void onBindData(View convertView, StatusContent data, int position) {
    this.data = data;
    WeiBoUser user = data.getUser();
    // userInfo
    setUserInfo(user, txtName, imgPhoto, imgVerified);
    // desc
    String createAt = "";
    if (!TextUtils.isEmpty(data.getCreated_at()))
        createAt = AisenUtils.convDate(data.getCreated_at());
    String from = "";
    if (!TextUtils.isEmpty(data.getSource()))
        from = String.format("%s", Html.fromHtml(data.getSource()));
    String desc = String.format("%s %s", createAt, from);
    txtDesc.setText(desc);
    // counter
    if (data.getReposts_count() == 0) {
        txtRepost.setVisibility(View.GONE);
    } else {
        txtRepost.setVisibility(View.VISIBLE);
        txtRepost.setText(AisenUtils.getCounter(data.getReposts_count()));
    }
    if (btnRepost != null) {
        btnRepost.setTag(data);
        btnRepost.setOnClickListener(this);
        if (data.getVisible() == null || "0".equals(data.getVisible().getType()))
            btnRepost.setVisibility(View.VISIBLE);
        else
            btnRepost.setVisibility(View.GONE);
    }
    if (data.getComments_count() == 0) {
        txtComment.setVisibility(View.GONE);
    } else {
        txtComment.setVisibility(View.VISIBLE);
        txtComment.setText(AisenUtils.getCounter(data.getComments_count()));
    }
    if (btnComment != null) {
        btnComment.setTag(data);
        btnComment.setOnClickListener(this);
    }
    setLikeView();
    // 文本
    //		txtContent.setText(data.getText());
    txtContent.setContent(data.getText());
    setTextSize(txtContent, textSize);
    // reContent
    StatusContent reContent = data.getRetweeted_status();
    if (reContent == null) {
        layRe.setVisibility(View.GONE);
    } else {
        layRe.setVisibility(View.VISIBLE);
        layRe.setTag(reContent);
        WeiBoUser reUser = reContent.getUser();
        String reUserName = "";
        if (reUser != null && !TextUtils.isEmpty(reUser.getScreen_name()))
            reUserName = String.format("@%s :", reUser.getScreen_name());
        txtReContent.setContent(reUserName + reContent.getText());
        // 正文
        setTextSize(txtReContent, textSize);
    }
    // pictures
    StatusContent s = data.getRetweeted_status() != null ? data.getRetweeted_status() : data;
    if (AppSettings.isPicNone() && !(fragment instanceof TimelineCommentFragment)) {
        layPicturs.setVisibility(View.GONE);
        if (s.getPic_urls() != null && s.getPic_urls().length > 0) {
            txtPics.setText(String.format("%dPics", s.getPic_urls().length));
            txtPics.setVisibility(View.VISIBLE);
            txtPics.setTag(s);
            txtPics.setOnClickListener(this);
        } else
            txtPics.setVisibility(View.GONE);
    } else {
        txtPics.setVisibility(View.GONE);
        layPicturs.setPics(s, fragment);
    }
    // group visiable
    txtVisiable.setVisibility(View.GONE);
    if (data.getVisible() != null && groupMap != null) {
        String name = groupMap.get(data.getVisible().getList_id());
        if (!TextUtils.isEmpty(name)) {
            txtVisiable.setText(String.format(fragment.getString(R.string.publish_group_visiable), name));
            txtVisiable.setVisibility(View.VISIBLE);
            if (layPicturs.getVisibility() == View.GONE) {
                txtVisiable.setPadding(0, 0, 0, 0);
            } else {
                txtVisiable.setPadding(0, vPadding, 0, 0);
            }
        }
    }
    btnMenus.setTag(data);
    btnMenus.setOnClickListener(this);
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser) TimelineCommentFragment(org.aisen.weibo.sina.ui.fragment.comment.TimelineCommentFragment)

Example 12 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class PublishStatusCommentFragment 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);
    StatusContent status = getPublishBean().getStatusContent();
    txtContent.setText(AisenUtils.getCommentText(status.getText()));
    if (status.getUser() != null)
        BitmapLoader.getInstance().display(this, AisenUtils.getUserPhoto(status.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_cmt_status);
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent)

Example 13 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent 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 14 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class MentionCmtItemView method onClick.

@Override
public void onClick(View v) {
    if (v.getId() == R.id.layStatus) {
        final StatusContent status = (StatusContent) v.getTag();
        TimelineDetailPagerFragment.launch(fragment.getActivity(), status);
    } else if (v.getId() == R.id.btnMenus) {
        final String[] commentMenuArr = GlobalContext.getInstance().getResources().getStringArray(R.array.cmt_menus);
        final StatusComment comment = (StatusComment) v.getTag();
        List<String> menuList = new ArrayList<String>();
        // 转发
        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]);
        final String[] menus = new String[menuList.size()];
        for (int i = 0; i < menuList.size(); i++) menus[i] = menuList.get(i);
        AisenUtils.showMenuDialog(fragment, v, menus, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                AisenUtils.commentMenuSelected(fragment, menus[which], comment);
            }
        });
    }
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) DialogInterface(android.content.DialogInterface) StatusComment(org.aisen.weibo.sina.sinasdk.bean.StatusComment) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class JokesFragment method onItemClick.

@Override
public void onItemClick(PLAAdapterView<?> parent, View view, int position, long id) {
    super.onItemClick(parent, view, position, id);
    final JokeBean bean = getAdapterItems().get(position);
    // 纯文
    if (bean.getItemType() == 0) {
        AisenUtils.showMenuDialog(this, view, getResources().getStringArray(R.array.jokes_menu), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (which == 0) {
                    MobclickAgent.onEvent(getActivity(), "joke_text_copy");
                    AisenUtils.copyToClipboard(bean.getExcerpt());
                } else if (which == 1) {
                    MobclickAgent.onEvent(getActivity(), "joke_text_share");
                    startActivity(Utils.getShareIntent("", bean.getExcerpt(), ""));
                }
            }
        });
    } else // 图文
    if (bean.getItemType() == 1) {
        StatusContent statusContent = new StatusContent();
        PicUrls picUrls = new PicUrls();
        picUrls.setThumbnail_pic(bean.getImgUrl());
        statusContent.setText(bean.getExcerpt());
        statusContent.setPic_urls(new PicUrls[] { picUrls });
        PicsActivity.launch(getActivity(), statusContent, 0);
    }
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls) DialogInterface(android.content.DialogInterface) JokeBean(org.aisen.weibo.sina.support.bean.JokeBean)

Aggregations

StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)15 WeiBoUser (org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)6 DialogInterface (android.content.DialogInterface)3 ArrayList (java.util.ArrayList)3 ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)2 Extra (org.aisen.android.component.orm.extra.Extra)2 TaskException (org.aisen.android.network.task.TaskException)2 PicUrls (org.aisen.weibo.sina.sinasdk.bean.PicUrls)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Setting (org.aisen.android.common.setting.Setting)1 Params (org.aisen.android.network.http.Params)1 ARecycleViewItemView (org.aisen.android.ui.fragment.adapter.ARecycleViewItemView)1