コード例 #1
0
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    int viewType = getItemViewType(position);

    if (viewType == VIEW_TYPE_ITEM) {
      ItemViewHolder vh = (ItemViewHolder) viewHolder;
      Post item = model.get(position);

      vh.title.setText(item.getTitle());
      vh.excerpt.setText(item.getExcerpt());
      vh.date.setText(item.getDatePretty());

      int thumbnailId = item.getThumbnailId();

      if (thumbnailId > 0) {
        vh.thumbnail.setVisibility(View.VISIBLE);
        //                vh.thumbnail.setImageResource(R.drawable.place_holder_image);
        //                vh.thumbnail.setAdjustViewBounds(true);
        //                vh.thumbnail.setScaleType(ImageView.ScaleType.FIT_CENTER);

        Context context = vh.thumbnail.getContext();
        ImageLoader.enqueue(context, position, thumbnailId, vh.thumbnail);
      } else {
        vh.thumbnail.setVisibility(View.GONE);
      }
    } else if (viewType == VIEW_TYPE_FOOTER) {
      FooterViewHolder vh = (FooterViewHolder) viewHolder;
      vh.progressBar.setIndeterminate(true);
    }
  }
コード例 #2
0
  @Override
  public int getItemViewType(int position) {
    if (position >= model.size()) {
      return VIEW_TYPE_FOOTER;
    }

    return VIEW_TYPE_ITEM;
  }
コード例 #3
0
 @Override
 public int getItemCount() {
   return (footerEnabled) ? model.size() + 1 : model.size();
 }