コード例 #1
0
  @Override
  public View getView(int position, View view, ViewGroup arg2) {
    ViewHolder holder;
    PiazzaQuestionItem pdi = mListItems.get(position);
    if (view == null) {
      view = LayoutInflater.from(context).inflate(R.layout.piazza_question_list_item, null);
      holder = new ViewHolder();
      holder.advTitle = (TextView) view.findViewById(R.id.essay_item_title);
      holder.advTime = (TextView) view.findViewById(R.id.essay_item_time);
      holder.imageUrl = (NetworkImageRoundView) view.findViewById(R.id.item_img);
      holder.question_item_image_info_1 =
          (NetworkImageView) view.findViewById(R.id.question_item_image_info_1);
      holder.question_item_image_info_2 =
          (NetworkImageView) view.findViewById(R.id.question_item_image_info_2);
      holder.question_item_image_info_3 =
          (NetworkImageView) view.findViewById(R.id.question_item_image_info_3);
      holder.question_item_image_info_4 =
          (NetworkImageView) view.findViewById(R.id.question_item_image_info_4);
      view.setTag(holder);
    } else {
      holder = (ViewHolder) view.getTag();
    }

    LruImageCache lruImageCache = LruImageCache.instance();
    ImageLoader imageLoader =
        new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
    // holder.imageUrl.setDefaultImageResId(R.drawable.icon);
    // holder.imageUrl.setErrorImageResId(R.drawable.icon);

    holder.imageUrl.setImageUrl(pdi.getUportrait(), imageLoader);
    holder.advTitle.setText(pdi.getNickname());
    holder.advTime.setText(pdi.getBody());

    holder.question_item_image_info_4.setVisibility(View.GONE);
    holder.question_item_image_info_3.setVisibility(View.GONE);
    holder.question_item_image_info_2.setVisibility(View.GONE);
    holder.question_item_image_info_1.setVisibility(View.GONE);

    // holder.essay_item_image_info.setVisibility(View.VISIBLE);

    if (pdi.getImages() != null) {

      switch (pdi.getImages().size()) {
        case 4:
          holder.question_item_image_info_4.setVisibility(View.VISIBLE);

          ImageLoader imageLoader4 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.question_item_image_info_4.setImageUrl(
              pdi.getImages().get(3).getImageurl(), imageLoader4);
        case 3:
          holder.question_item_image_info_3.setVisibility(View.VISIBLE);

          ImageLoader imageLoader3 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.question_item_image_info_3.setImageUrl(
              pdi.getImages().get(2).getImageurl(), imageLoader3);
        case 2:
          holder.question_item_image_info_2.setVisibility(View.VISIBLE);

          ImageLoader imageLoader2 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.question_item_image_info_2.setImageUrl(
              pdi.getImages().get(1).getImageurl(), imageLoader2);
        case 1:
          holder.question_item_image_info_1.setVisibility(View.VISIBLE);

          ImageLoader imageLoader1 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.question_item_image_info_1.setImageUrl(
              pdi.getImages().get(0).getImageurl(), imageLoader1);
        default:
          break;
      }
    }
    return view;
  }
コード例 #2
0
  @Override
  public View getView(int position, View view, ViewGroup arg2) {
    ViewHolder holder;
    GroupListItemSharedModel eli = mListItems.get(position);
    if (view == null) {
      view = LayoutInflater.from(context).inflate(R.layout.group_personal_shared_list_item, null);
      holder = new ViewHolder();
      holder.group_shared_item_title = (TextView) view.findViewById(R.id.group_shared_item_title);
      holder.group_shared_item_time = (TextView) view.findViewById(R.id.group_shared_item_time);
      holder.group_shared_item_summary =
          (TextView) view.findViewById(R.id.group_shared_item_summary);
      holder.group_shared_item_delete = (TextView) view.findViewById(R.id.group_shared_item_delete);
      holder.imageUrl = (NetworkImageView) view.findViewById(R.id.item_img);

      holder.group_shared_item_delete.setTag(R.id.group_shared_item_delete, position);

      holder.group_detail_item_image_info_1 =
          (NetworkImageView) view.findViewById(R.id.group_detail_item_image_info_1);
      holder.group_detail_item_image_info_2 =
          (NetworkImageView) view.findViewById(R.id.group_detail_item_image_info_2);
      holder.group_detail_item_image_info_3 =
          (NetworkImageView) view.findViewById(R.id.group_detail_item_image_info_3);
      holder.group_detail_item_image_info_4 =
          (NetworkImageView) view.findViewById(R.id.group_detail_item_image_info_4);

      view.setTag(holder);
    } else {
      holder = (ViewHolder) view.getTag();
    }

    LruImageCache lruImageCache = LruImageCache.instance();
    ImageLoader imageLoader =
        new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
    holder.imageUrl.setDefaultImageResId(R.drawable.icon_dialog);
    holder.imageUrl.setErrorImageResId(R.drawable.icon_dialog);

    holder.imageUrl.setImageUrl(eli.getUportrait(), imageLoader);
    holder.group_shared_item_title.setText(eli.getNickname());
    if (!"0".equals(eli.getComments()) && TextUtils.isEmpty(eli.getComments())) {}
    holder.group_shared_item_time.setText(Util.formatTime2Away(eli.getTimeline()));
    holder.group_shared_item_summary.setText(eli.getBody());

    holder.group_shared_item_delete.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            int position = (Integer) v.getTag(R.id.group_shared_item_delete);
            operator.onDeleteItem(position);
          }
        });

    holder.group_detail_item_image_info_4.setVisibility(View.GONE);
    holder.group_detail_item_image_info_3.setVisibility(View.GONE);
    holder.group_detail_item_image_info_2.setVisibility(View.GONE);
    holder.group_detail_item_image_info_1.setVisibility(View.GONE);

    if (eli.getImages() != null) {
      switch (eli.getImages().size()) {
        case 4:
          holder.group_detail_item_image_info_4.setVisibility(View.VISIBLE);

          ImageLoader imageLoader4 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.group_detail_item_image_info_4.setDefaultImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_4.setErrorImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_4.setImageUrl(
              eli.getImages().get(3).getImageurl(), imageLoader4);
        case 3:
          holder.group_detail_item_image_info_3.setVisibility(View.VISIBLE);

          ImageLoader imageLoader3 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.group_detail_item_image_info_3.setDefaultImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_3.setErrorImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_3.setImageUrl(
              eli.getImages().get(2).getImageurl(), imageLoader3);
        case 2:
          holder.group_detail_item_image_info_2.setVisibility(View.VISIBLE);

          ImageLoader imageLoader2 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.group_detail_item_image_info_2.setDefaultImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_2.setErrorImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_2.setImageUrl(
              eli.getImages().get(1).getImageurl(), imageLoader2);
        case 1:
          holder.group_detail_item_image_info_1.setVisibility(View.VISIBLE);

          ImageLoader imageLoader1 =
              new ImageLoader(VolleyUtils.getInstance().getRequestQueue(), lruImageCache);
          holder.group_detail_item_image_info_1.setDefaultImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_1.setErrorImageResId(R.drawable.welcome_homework);
          holder.group_detail_item_image_info_1.setImageUrl(
              eli.getImages().get(0).getImageurl(), imageLoader1);
        default:
          break;
      }
    }

    return view;
  }