Java Code Examples for android.support.v7.widget.RecyclerView#INVALID_TYPE
The following examples show how to use
android.support.v7.widget.RecyclerView#INVALID_TYPE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DelegateAdapter.java From vlayout with MIT License | 6 votes |
/** * Big integer of itemType returned by delegated adapter may lead to failed * * @param position item position * @return integer represent item view type */ @Override public int getItemViewType(int position) { Pair<AdapterDataObserver, Adapter> p = findAdapterByPosition(position); if (p == null) { return RecyclerView.INVALID_TYPE; } int subItemType = p.second.getItemViewType(position - p.first.mStartPosition); if (subItemType < 0) { // negative integer, invalid, just return return subItemType; } if (mHasConsistItemType) { mItemTypeAry.put(subItemType, p.second); return subItemType; } int index = p.first.mIndex; return (int) Cantor.getCantor(subItemType, index); }
Example 2
Source File: ShieldDisplayNodeAdapter.java From Shield with MIT License | 6 votes |
@Override public int getItemViewType(int position) { ShieldDisplayNode displayNode = getDisplayNode(position); if (displayNode != null) { String viewType = displayNode.getViewTypeWithTopInfo(); if (viewType != null) { if (!nodeTypeIndex.containsValue(viewType)) { nodeTypeIndex.putValue(viewType); recyclerView.getRecycledViewPool().setMaxRecycledViews(nodeTypeIndex.getIndex(viewType), DEFAULT_REUSE_POOL_SIZE); } if (!typeDisplayNodeMap.containsValue(displayNode)) { typeDisplayNodeMap.put(viewType, displayNode); } return nodeTypeIndex.getIndex(viewType); } else { if (nodeTypeIndex.containsValue(displayNode)) { return nodeTypeIndex.getIndex(displayNode); } else { nodeTypeIndex.putValue(displayNode); return nodeTypeIndex.getIndex(displayNode); } } } return RecyclerView.INVALID_TYPE; }
Example 3
Source File: XWrapAdapter.java From XRecyclerView with Apache License 2.0 | 6 votes |
@Override public int getItemViewType(int position) { // head view int numHeaders = getHeadersCount(); if (position < numHeaders) { return RecyclerView.INVALID_TYPE; } // the normal view int adjPosition = position - numHeaders; int adapterCount; if (mAdapter != null) { adapterCount = mAdapter.getItemCount(); if (adjPosition < adapterCount) { return mAdapter.getItemViewType(adjPosition); } } // footer view return RecyclerView.INVALID_TYPE - 1; }
Example 4
Source File: RecyclerWrapAdapter.java From PullToRefresh with Apache License 2.0 | 6 votes |
@Override public int getItemViewType(int position) { int numHeaders = getHeadersCount(); if (position < numHeaders) { return RecyclerView.INVALID_TYPE; } int adjPosition = position - numHeaders; int adapterCount = 0; if (mAdapter != null) { adapterCount = mAdapter.getItemCount(); if (adjPosition < adapterCount) { return mAdapter.getItemViewType(adjPosition); } } return RecyclerView.INVALID_TYPE - 1; }
Example 5
Source File: UploadRecyclerAdapter.java From RxUploader with Apache License 2.0 | 5 votes |
@Override public int getItemViewType(int position) { final DataModel m = getItemAt(position); if (m == null) { return RecyclerView.INVALID_TYPE; } return m.type(); }
Example 6
Source File: XWrapAdapter.java From XRecyclerView with Apache License 2.0 | 5 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == RecyclerView.INVALID_TYPE) { return new HeaderViewHolder(mHeaderViews.get(headerPosition++)); } else if (viewType == RecyclerView.INVALID_TYPE - 1) { return new FooterViewHolder(mFootViews.get(0)); } return mAdapter.onCreateViewHolder(parent, viewType); }
Example 7
Source File: RecyclerWrapAdapter.java From PullToRefresh with Apache License 2.0 | 5 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == RecyclerView.INVALID_TYPE) { mHeaderViews.get(0).setLayoutParams(parent.getLayoutParams()); return new HeaderViewHolder(mHeaderViews.get(0)); } else if (viewType == RecyclerView.INVALID_TYPE - 1) { mFootViews.get(0).setLayoutParams(parent.getLayoutParams()); return new HeaderViewHolder(mFootViews.get(0)); } return mAdapter.onCreateViewHolder(parent, viewType); }
Example 8
Source File: BaseRecyclerBinderAdapter.java From recyclerview-binder with Apache License 2.0 | 5 votes |
@Override public int getItemViewType(int position) { final Binder<V, VH> item = getItem(position); if (item != null) { return item.getViewType().viewType(); } else { return RecyclerView.INVALID_TYPE; } }