コード例 #1
0
  @Override
  public void destroyItem(ViewGroup collection, int position, Object object) {
    EfficientViewHolder viewHolder = (EfficientViewHolder) object;
    collection.removeView(viewHolder.getView());
    onViewDetachedFromWindow(viewHolder);

    int viewType = getItemViewType(position);
    List<EfficientViewHolder> viewHolders = mRecycleViewHolders.get(viewType);
    if (viewHolders == null) {
      viewHolders = new ArrayList<>();
    }
    mRecycleViewHolders.put(viewType, viewHolders);
    viewHolders.add(viewHolder);
  }
コード例 #2
0
 @Override
 public Object instantiateItem(ViewGroup collection, int position) {
   int viewType = getItemViewType(position);
   List<EfficientViewHolder> viewHolders = mRecycleViewHolders.get(viewType);
   EfficientViewHolder viewHolder;
   if (viewHolders == null || viewHolders.isEmpty()) {
     viewHolder = onCreateViewHolder(collection, viewType);
   } else {
     viewHolder = viewHolders.remove(0);
     onViewRecycled(viewHolder);
   }
   onBindViewHolder(viewHolder, position);
   collection.addView(viewHolder.getView(), 0);
   onViewAttachedToWindow(viewHolder);
   return viewHolder;
 }
コード例 #3
0
  @Override
  public void onBindViewHolder(EfficientViewHolder viewHolder, int position) {
    T object = mBaseAdapter.get(position);
    viewHolder.onBindView(object, position);

    mBaseAdapter.setClickListenerOnView(this, viewHolder);
    mBaseAdapter.setLongClickListenerOnView(this, viewHolder);
  }
コード例 #4
0
 @Override
 public void onViewDetachedFromWindow(EfficientViewHolder holder) {
   holder.onViewDetachedFromWindow();
 }
コード例 #5
0
 @Override
 public void onViewAttachedToWindow(EfficientViewHolder holder) {
   holder.onViewAttachedToWindow();
 }
コード例 #6
0
 @Override
 public void onViewRecycled(EfficientViewHolder holder) {
   holder.onViewRecycled();
 }