Search in sources :

Example 1 with TimelineCommentFragment

use of org.aisen.weibo.sina.ui.fragment.comment.TimelineCommentFragment 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)

Aggregations

StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)1 WeiBoUser (org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)1 TimelineCommentFragment (org.aisen.weibo.sina.ui.fragment.comment.TimelineCommentFragment)1