本文整理匯總了Java中android.support.v7.widget.RecyclerView.INVALID_TYPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.INVALID_TYPE屬性的具體用法?Java RecyclerView.INVALID_TYPE怎麽用?Java RecyclerView.INVALID_TYPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.INVALID_TYPE屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getItemViewType
@Override
public int getItemViewType(int position) {
int numHeaders = getHeadersCount();
if (position < numHeaders) {
return RecyclerView.INVALID_TYPE;
}
int adjPosition = position - numHeaders;
int adapterCount;
if (mAdapter != null) {
adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
return mAdapter.getItemViewType(adjPosition);
}
}
return RecyclerView.INVALID_TYPE - 1;
}
示例2: getItemViewType
/**
* 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) getCantor(subItemType, index);
}
示例3: getItemViewType
/**
* 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);
}
示例4: findTarget
/**
* Searches for a clickable view that has tapped by the user.
*
* @param x The x coordinate of the touch that caused the search.
* @param y The y coordinate of the touch that caused the search.
* @return {@link Target} instance that contains tapped view and containing view holder,
* null if view has not been found.
*/
@Nullable
Target findTarget(final float x, final float y) {
final View itemView = mHostView.findChildViewUnder(x, y);
if (itemView == null) {
return null;
}
final RecyclerView.ViewHolder viewHolder = mHostView.getChildViewHolder(itemView);
final int position = viewHolder.getAdapterPosition();
final int viewType = viewHolder.getItemViewType();
if (position <= RecyclerView.NO_POSITION || viewType <= RecyclerView.INVALID_TYPE) {
return null;
}
final ClickableViews clickableViews = mCallback.getClickableViews(position, viewType);
return findTargetInViewHolder(viewHolder, clickableViews, x, y);
}
示例5: getItemViewType
@Override
public int getItemViewType(int position) {
if(position>=0&&position<headerViews.size()){
//如果是頭部則返回一個不可用的標識,表示這是頭部item
return RecyclerView.INVALID_TYPE;
}
if(adapter!=null){
int p=position-headerViews.size();
if(p<adapter.getItemCount()){
return adapter.getItemViewType(p);
}
}
return RecyclerView.INVALID_TYPE-1;//默認返回表示是尾部的item
}
示例6: getItemViewType
@Override
public int getItemViewType(int position) {
// 當有頭部的情況下
if (mHeaderView != null && position == 0) {
// 這裏表示頭部
return RecyclerView.INVALID_TYPE;
}
// 這裏需要對常規列表item的position進行修複,需要排除頭部與底部所占的位置
int fixedPosition = position - 1;
if (fixedPosition >=0 && fixedPosition < mAdapter.getItemCount()) {
return mAdapter.getItemViewType(fixedPosition);
}
// 這裏表示底部
return RecyclerView.INVALID_TYPE - 1;
}
示例7: onCreateViewHolder
@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) {
StaggeredGridLayoutManager.LayoutParams params = new StaggeredGridLayoutManager.LayoutParams(
StaggeredGridLayoutManager.LayoutParams.MATCH_PARENT, StaggeredGridLayoutManager.LayoutParams.WRAP_CONTENT);
params.setFullSpan(true);
mFootViews.get(0).setLayoutParams(params);
return new HeaderViewHolder(mFootViews.get(0));
}
return mAdapter.onCreateViewHolder(parent, viewType);
}
示例8: onCreateViewHolder
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == RecyclerView.INVALID_TYPE) {
return new RecyclerView.ViewHolder(new LinearLayout(parent.getContext())){};
}
return mAdapter.onCreateViewHolder(parent, viewType);
}
示例9: getItemViewType
@Override
public int getItemViewType(int position) {
if (position == 0) {
return RecyclerView.INVALID_TYPE;
}
return super.getItemViewType(position);
}
示例10: onCreateViewHolder
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if(viewType== RecyclerView.INVALID_TYPE){
//頭部item
return new RecyclerView.ViewHolder(headerViews.get(0)){};
}else if(viewType== (RecyclerView.INVALID_TYPE-1)){
//尾部item
return new RecyclerView.ViewHolder(footViews.get(0)){};
}
return adapter.onCreateViewHolder(parent,viewType);
}
示例11: onCreateViewHolder
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// 頭部
if (mHeaderView != null && viewType == RecyclerView.INVALID_TYPE) {
return new RecyclerView.ViewHolder(mHeaderView) {};
}
// 底部
else if (mFooterView != null && viewType == RecyclerView.INVALID_TYPE - 1) {
return new RecyclerView.ViewHolder(mFooterView) {};
}
// 其他常規列表item
return mAdapter.onCreateViewHolder(parent, viewType);
}
示例12: onCreateViewHolder
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == RecyclerView.INVALID_TYPE) {
return new RecyclerView.ViewHolder(new LinearLayout(parent.getContext())) {
};
}
return mAdapter.onCreateViewHolder(parent, viewType);
}
示例13: getItemViewType
@Override
public int getItemViewType(int position) {
final DataModel m = getItemAt(position);
if (m == null) {
return RecyclerView.INVALID_TYPE;
}
return m.type();
}