Esempio n. 1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void setDataAdapter(
      XListView xListView,
      KBaseAdapter adapter,
      List<?> showList,
      List resultlist,
      boolean isRefresh) {
    mRefreshTime = ToolUtils.getNowTime();
    xListView.setRefreshTime(mRefreshTime);
    stopLoad(xListView);

    if (null == resultlist || resultlist.size() == 0) {
      xListView.setPullLoadEnable(false);
      BToast.show(mActivity, "数据加载完毕");
      return;
    }

    if (resultlist.size() < PAGE_SIZE_ADD) {
      xListView.setPullLoadEnable(false);
      BToast.show(mActivity, "数据加载完毕");
    } else {
      xListView.setPullLoadEnable(true);
    }

    if (isRefresh) {
      showList.clear();
      isRefresh = false;
    }

    showList.addAll(resultlist);
    adapter.notifyDataSetChanged();
  }
Esempio n. 2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final Holder holder;
    if (convertView == null) {
      holder = new Holder();
      convertView = mInflater.inflate(R.layout.weiqiang_item_layout, parent, false);
      holder.ivAuthorImg = (ImageView) convertView.findViewById(R.id.iv_img);
      holder.tvAuthorName = (TextView) convertView.findViewById(R.id.tv_nick);
      holder.tvTime = (TextView) convertView.findViewById(R.id.tv_time);
      holder.tvComments = (TextView) convertView.findViewById(R.id.tv_comments);
      holder.gridView = (NoScrollGridView) convertView.findViewById(R.id.gv_show_img);

      holder.llTransArea = (LinearLayout) convertView.findViewById(R.id.ll_old_area);
      holder.tvOldAuthorName = (TextView) convertView.findViewById(R.id.tv_old_user);
      holder.tvContent = (TextView) convertView.findViewById(R.id.tv_content);
      holder.oldgridView = (NoScrollGridView) convertView.findViewById(R.id.gv_old_show_img);

      holder.avZan = (ActionView) convertView.findViewById(R.id.av_zan);
      holder.avReply = (ActionView) convertView.findViewById(R.id.av_reply);
      holder.avTranspnt = (ActionView) convertView.findViewById(R.id.av_transpont);
      holder.avShare = (ActionView) convertView.findViewById(R.id.av_share);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }

    final WeiQiangBean weiqiangBean = (WeiQiangBean) mList.get(position);

    BGApp.getInstance().setImage(weiqiangBean.photo, holder.ivAuthorImg);

    holder.ivAuthorImg.setOnClickListener(new ShowNameCardListener(weiqiangBean, mActivity));

    holder.tvAuthorName.setText(weiqiangBean.name);
    holder.tvAuthorName.setOnClickListener(new ShowNameCardListener(weiqiangBean, mActivity));

    holder.tvTime.setText(ToolUtils.getFormatDate(weiqiangBean.date_time));

    if (!TextUtils.isEmpty(weiqiangBean.fromname)) { // 如果转发人存在
      holder.llTransArea.setVisibility(View.VISIBLE);
      holder.tvOldAuthorName.setText(weiqiangBean.fromname);
      holder.tvOldAuthorName.setOnClickListener(new ShowNameCardListener(weiqiangBean, mActivity));
      holder.tvContent.setText(weiqiangBean.content);
      holder.tvComments.setText(weiqiangBean.comments);
      ImgUtils.showImgs(weiqiangBean.imgs, holder.oldgridView, mActivity);
      holder.gridView.setVisibility(View.GONE);
      holder.tvContent.setVisibility(
          TextUtils.isEmpty(weiqiangBean.content) ? View.GONE : View.VISIBLE);
      holder.tvComments.setVisibility(
          TextUtils.isEmpty(weiqiangBean.comments) ? View.GONE : View.VISIBLE);
    } else {
      holder.llTransArea.setVisibility(View.GONE);
      holder.tvComments.setText(weiqiangBean.content);
      holder.tvComments.setVisibility(
          TextUtils.isEmpty(weiqiangBean.content) ? View.GONE : View.VISIBLE);
      holder.gridView.setVisibility(View.GONE);
      ImgUtils.showImgs(weiqiangBean.imgs, holder.gridView, mActivity);
    }

    holder.avZan.setCount(weiqiangBean.like_count);
    holder.avZan.setOnClickListener(mListener);
    holder.avZan.setTag(weiqiangBean);

    holder.avReply.setCount(weiqiangBean.comment_count);
    holder.avReply.setOnClickListener(mListener);
    holder.avReply.setTag(weiqiangBean);

    holder.avTranspnt.setCount(weiqiangBean.forward_count);
    holder.avTranspnt.setOnClickListener(mListener);
    holder.avTranspnt.setTag(weiqiangBean);

    holder.avShare.setCount(weiqiangBean.share_count);
    holder.avShare.setOnClickListener(mListener);
    holder.avShare.setTag(weiqiangBean);

    return convertView;
  }