示例#1
0
  public void parse(TimeLineModel data) {
    this.mData = data;
    if (data.hasPics || data.hasRepostPics) {
      mPic.setVisibility(GONE);
      mGridView.setVisibility(VISIBLE);
      mGridView.setAdapter(new GridPicsAdapter(getContext(), data.pics));
      LayoutParams lp = (LayoutParams) mCommentCount.getLayoutParams();
      lp.addRule(BELOW, R.id.timeline_listitem_picgrid);
      mCommentCount.setLayoutParams(lp);
    } else {
      mGridView.setVisibility(GONE);
      LayoutParams lp = (LayoutParams) mCommentCount.getLayoutParams();
      lp.addRule(BELOW, R.id.timeline_listitem_pic);
      mCommentCount.setLayoutParams(lp);
      if (data.hasPic || data.hasRepostPic) {
        mPic.setVisibility(VISIBLE);
        mPic.setGif(TextUtils.isGifLink(data.pics.get(0)));
        if (NetworkUtils.isWifi(getContext())) {
          ImageLoader.getInstance()
              .displayImage(data.pics.get(0).replace("thumbnail", "bmiddle"), mPic);
        } else {
          ImageLoader.getInstance().displayImage(data.pics.get(0), mPic);
        }
      } else {
        mPic.setVisibility(GONE);
      }
    }
    if (data.topics.size() == 0) {
      mTopic.setVisibility(INVISIBLE);
    } else {
      mTopic.setVisibility(VISIBLE);
      mTopic.setText(data.topics.get(0));
    }
    if (data.hasRepost) {
      mLine.setVisibility(VISIBLE);
      mRepostName.setVisibility(VISIBLE);
      mRepostText.setVisibility(VISIBLE);
      mRepostName.setText(data.repostName);
      mRepostText.setText(data.repostText);
    } else {
      mLine.setVisibility(GONE);
      mRepostName.setVisibility(GONE);
      mRepostText.setVisibility(GONE);
    }
    if (data.commentCount != 0) {
      mCommentCount.setText(data.commentCount + "");
    } else {
      mCommentCount.setText("评论");
    }
    if (data.repostCount != 0) {
      mRepostCount.setText(data.repostCount + "");
    } else {
      mRepostCount.setText("转发");
    }

    mText.setText(data.text);
    mName.setText(data.name);
    mTime.setText(data.time);
    ImageLoader.getInstance().displayImage(data.headUrl, mHead, mOptions);
  }
示例#2
0
  private void init() {
    inflate(getContext(), R.layout.widget_timeline_listitem, this);
    mHead = (HeadIconImageView) findViewById(R.id.timeline_listitem_head);
    mName = (TextView) findViewById(R.id.timeline_listitem_name);
    mText = (TextView) findViewById(R.id.timeline_listitem_text);
    mText.setMovementMethod(LinkMovementMethod.getInstance());
    mTopic = (TextView) findViewById(R.id.timeline_listitem_topic);
    mTime = (TextView) findViewById(R.id.timeline_listitem_time);
    mGridView = (NoScrollGridView) findViewById(R.id.timeline_listitem_picgrid);
    mGridView.setSelector(getResources().getDrawable(R.drawable.list_selector_holo));
    mPic = (SelectorImageView) findViewById(R.id.timeline_listitem_pic);
    mLine = findViewById(R.id.timeline_listitem_line);
    mRepostName = (TextView) findViewById(R.id.timeline_listitem_repost_name);
    mRepostName.setMovementMethod(LinkMovementMethod.getInstance());
    mRepostText = (TextView) findViewById(R.id.timeline_listitem_repost_text);
    mRepostText.setMovementMethod(LinkMovementMethod.getInstance());
    mCommentCount = (TextView) findViewById(R.id.timeline_listitem_commentcount);
    mRepostCount = (TextView) findViewById(R.id.timeline_listitem_repostcount);

    mHead.setOnClickListener(this);
    mGridView.setOnItemClickListener(this);
    mPic.setOnClickListener(this);
    mCommentCount.setOnClickListener(this);
    mRepostCount.setOnClickListener(this);
  }