// 因为要支持两种类型,一种底部进度条 // TODO 添加多种进度条支持 @Override public int getViewTypeCount() { if (mMultiItemTypeSupport != null) { return mMultiItemTypeSupport.getViewTypeCount() + 1; } return 2; }
@Override public int getItemViewType(int position) { if (mMultiItemTypeSupport != null) { return mMultiItemTypeSupport.getItemViewType(position, getItem(position)); } return super.getItemViewType(position); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (mMultiItemTypeSupport == null) return super.getView(position, convertView, parent); int layoutId = mMultiItemTypeSupport.getLayoutId(position, getItem(position)); ViewHolder viewHolder = ViewHolder.get(mContext, convertView, parent, layoutId, position); convert(viewHolder, getItem(position)); return viewHolder.getConvertView(); }
@Override public int getItemViewType(int position) { if (position >= this.mData.size()) { // 底部进度条 return 0; } return (mMultiItemTypeSupport != null) ? mMultiItemTypeSupport.getItemViewType(position, getItem(position)) : 1; }
@Override public BaseAdapterHelper onCreateViewHolder(ViewGroup viewGroup, int viewType) { View view = null; if (mMultiItemTypeSupport != null) { int layoutId = mMultiItemTypeSupport.getLayoutId(viewType); view = LayoutInflater.from(viewGroup.getContext()).inflate(layoutId, viewGroup, false); } else { view = LayoutInflater.from(viewGroup.getContext()).inflate(layoutResId, viewGroup, false); } view.setOnClickListener(this); BaseAdapterHelper vh = new BaseAdapterHelper(view); return vh; }
@Override public int getViewTypeCount() { if (mMultiItemTypeSupport != null) return mMultiItemTypeSupport.getViewTypeCount(); return super.getViewTypeCount(); }