コード例 #1
0
  /**
   * 1. this message has repost's message 2. this message is an original message
   *
   * <p>if this message has repost's message,try to include its content, if total word number above
   * 140,discard current msg content
   */
  private ItemBean repost() throws WeiboException {

    String content = ((EditText) findViewById(R.id.status_new_content)).getText().toString();

    if (msg.getRetweeted_status() != null) {
      String msgContent = "//@" + msg.getUser().getScreen_name() + ": " + msg.getText();
      String total = content + msgContent;
      if (total.length() < 140) {
        content = total;
      }
    }

    RepostNewMsgDao dao = new RepostNewMsgDao(token, msg.getId());

    boolean comment = true;
    boolean oriComment = enableCommentOri.isChecked();

    if (comment && oriComment) {
      dao.setIs_comment(RepostNewMsgDao.ENABLE_COMMENT_ALL);
    } else if (comment) {
      dao.setIs_comment(RepostNewMsgDao.ENABLE_COMMENT);
    } else if (oriComment) {
      dao.setIs_comment(RepostNewMsgDao.ENABLE_ORI_COMMENT);
    }

    dao.setStatus(content);

    return dao.sendNewMsg();
  }
コード例 #2
0
  private void buildRepostContent(
      MessageBean msg, final MessageBean repost_msg, ViewHolder holder, int position) {
    holder.repost_content.setVisibility(View.VISIBLE);
    if (!repost_msg.getId().equals((String) holder.repost_content.getTag())) {
      boolean haveCachedHeight = oriMsgHeights.get(msg.getIdLong()) != null;
      ViewGroup.LayoutParams layoutParams = holder.repost_content.getLayoutParams();
      if (haveCachedHeight) {
        layoutParams.height = oriMsgHeights.get(msg.getIdLong());
      } else {
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      }

      boolean haveCachedWidth = oriMsgWidths.get(msg.getIdLong()) != null;
      if (haveCachedWidth) {
        layoutParams.width = oriMsgWidths.get(msg.getIdLong());
      } else {
        layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
      }

      holder.repost_content.requestLayout();
      holder.repost_content.setText(repost_msg.getListViewSpannableString());

      if (!haveCachedHeight) {
        oriMsgHeights.append(msg.getIdLong(), layoutParams.height);
      }

      if (!haveCachedWidth) {
        oriMsgWidths.append(msg.getIdLong(), layoutParams.width);
      }

      holder.repost_content.setText(repost_msg.getListViewSpannableString());
      holder.repost_content.setTag(repost_msg.getId());
    }

    if (repost_msg.havePicture()) {
      if (repost_msg.isMultiPics()) {
        buildMultiPic(repost_msg, holder.repost_content_pic_multi);
      } else {
        buildPic(repost_msg, holder.repost_content_pic, position);
      }
    }
  }
コード例 #3
0
 private RefreshReCmtCountTask(
     FriendsTimeLineFragment friendsTimeLineFragment, MessageListBean data) {
   fragmentWeakReference = new WeakReference<FriendsTimeLineFragment>(friendsTimeLineFragment);
   msgIds = new ArrayList<String>();
   List<MessageBean> msgList = data.getItemList();
   for (MessageBean msg : msgList) {
     if (msg != null) {
       msgIds.add(msg.getId());
     }
   }
 }
コード例 #4
0
  private void updateTimeLineMessageCommentAndRepostData(List<MessageReCmtCountBean> value) {

    if (getList().getSize() <= value.size()) {
      return;
    }

    for (int i = 0; i < value.size(); i++) {
      MessageBean msg = getList().getItem(i);
      MessageReCmtCountBean count = value.get(i);
      if (msg != null && msg.getId().equals(count.getId())) {
        msg.setReposts_count(count.getReposts());
        msg.setComments_count(count.getComments());
      }
    }
    getAdapter().notifyDataSetChanged();
    FriendsTimeLineDBTask.asyncReplace(getList(), accountBean.getUid(), currentGroupId);
  }
コード例 #5
0
  @Override
  protected ItemBean sendData() throws WeiboException {
    if (!enableRepost.isChecked()) {
      CommentNewMsgDao dao =
          new CommentNewMsgDao(
              token,
              msg.getId(),
              ((EditText) findViewById(R.id.status_new_content)).getText().toString());
      if (enableCommentOri.isChecked()) {
        dao.enableComment_ori(true);
      } else {
        dao.enableComment_ori(false);
      }

      return dao.sendNewMsg();
    } else {
      return repost();
    }
  }
コード例 #6
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   // use Up instead of Back to reach this fragment
   if (data == null) {
     return;
   }
   final MessageBean msg = (MessageBean) data.getParcelableExtra("msg");
   if (msg != null) {
     for (int i = 0; i < getList().getSize(); i++) {
       if (msg.equals(getList().getItem(i))) {
         MessageBean ori = getList().getItem(i);
         if (ori.getComments_count() != msg.getComments_count()
             || ori.getReposts_count() != msg.getReposts_count()) {
           ori.setReposts_count(msg.getReposts_count());
           ori.setComments_count(msg.getComments_count());
           FriendsTimeLineDBTask.asyncUpdateCount(
               msg.getId(), msg.getComments_count(), msg.getReposts_count());
           getAdapter().notifyDataSetChanged();
         }
         break;
       }
     }
   }
 }