public int getItemViewType(int position) { final ListAdapter adapter = mListAdapter; if (adapter != null) return adapter.getItemViewType(position); else return 0; }
private boolean isHeaderOrFooterPosition( int pos ){ int type = mAdapter.getItemViewType(pos); return type == ITEM_VIEW_TYPE_HEADER_OR_FOOTER; }
@Override public int getItemViewType(int position) { if (mAdapter != null) { return mAdapter.getItemViewType(position); } return -1; }
@Override public int getItemViewType(int position) { return mDelegate.getItemViewType(position); }
public int getItemViewType(int position) { int numHeaders = getHeadersCount(); if (mAdapter != null && position >= numHeaders) { int adjPosition = position - numHeaders; int adapterCount = mAdapter.getCount(); if (adjPosition < adapterCount) { return mAdapter.getItemViewType(adjPosition); } } return PLAAdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER; }
final int count = adapter.getCount(); for (int i = 0; i < count; i++) { final int positionType = adapter.getItemViewType(i); if (positionType != itemType) { itemType = positionType;
private void measureScrapChild(View child, int position, int widthMeasureSpec) { LayoutParams p = (LayoutParams) child.getLayoutParams(); if (p == null) { p = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); child.setLayoutParams(p); } p.viewType = mAdapter.getItemViewType(position); p.forceAdd = true; int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec, mListPadding.left + mListPadding.right, p.width); int lpHeight = p.height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); } else { childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } child.measure(childWidthSpec, childHeightSpec); }
scrapViews = mCurrentScrap; } else { final int whichScrap = mAdapter.getItemViewType(position); if (whichScrap >= 0 && whichScrap < mScrapViews.length) { scrapViews = mScrapViews[whichScrap];
final int count = adapter.getCount(); for (int i = 0; i < count; i++) { final int positionType = adapter.getItemViewType(i); if (positionType != itemType) { itemType = positionType;
private int measureContentWidth() { // Menus don't tend to be long, so this is more sane than it looks. int maxWidth = 0; View itemView = null; int itemType = 0; final ListAdapter adapter = mAdapter; final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); final int count = adapter.getCount(); for (int i = 0; i < count; i++) { final int positionType = adapter.getItemViewType(i); if (positionType != itemType) { itemType = positionType; itemView = null; } if (mMeasureParent == null) { mMeasureParent = new FrameLayout(mContext); } itemView = adapter.getView(i, itemView, mMeasureParent); itemView.measure(widthMeasureSpec, heightMeasureSpec); final int itemWidth = itemView.getMeasuredWidth(); if (itemWidth >= mPopupMaxWidth) { return mPopupMaxWidth; } else if (itemWidth > maxWidth) { maxWidth = itemWidth; } } return maxWidth; } @Override
int findFirstVisibleSectionPosition(int firstVisibleItem, int visibleItemCount) { ListAdapter adapter = getAdapter(); int adapterDataCount = adapter.getCount(); if (getLastVisiblePosition() >= adapterDataCount) return -1; // dataset has changed, no candidate if (firstVisibleItem+visibleItemCount >= adapterDataCount){//added to prevent index Outofbound (in case) visibleItemCount = adapterDataCount-firstVisibleItem; } for (int childIndex = 0; childIndex < visibleItemCount; childIndex++) { int position = firstVisibleItem + childIndex; int viewType = adapter.getItemViewType(position); if (isItemViewTypePinned(adapter, viewType)) return position; } return -1; }
if (adjPosition >= 0 && adjPosition < adapterCount) { if (adjPosition < mAdapter.getCount()) { type = mAdapter.getItemViewType(adjPosition); } else { if (mCachePlaceHoldView) {
int findCurrentSectionPosition(int fromPosition) { ListAdapter adapter = getAdapter(); if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate if (adapter instanceof SectionIndexer) { // try fast way by asking section indexer SectionIndexer indexer = (SectionIndexer) adapter; int sectionPosition = indexer.getSectionForPosition(fromPosition); int itemPosition = indexer.getPositionForSection(sectionPosition); int typeView = adapter.getItemViewType(itemPosition); if (isItemViewTypePinned(adapter, typeView)) { return itemPosition; } // else, no luck } // try slow way by looking through to the next section item above for (int position=fromPosition; position>=0; position--) { int viewType = adapter.getItemViewType(position); if (isItemViewTypePinned(adapter, viewType)) return position; } return -1; // no candidate found }
if (adjPosition >= 0 && adjPosition < adapterCount) { if (adjPosition < mAdapter.getCount()) { type = mAdapter.getItemViewType(adjPosition); } else { if (mCachePlaceHoldView) {
int count = adapter.getCount(); for (int i = 0; i < count; i++) { int newType = adapter.getItemViewType(i); if (newType != viewType) { child = null;
ViewGroup.LayoutParams.WRAP_CONTENT, 0); p.viewType = mAdapter.getItemViewType(position); p.scrappedFromPosition = position;
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mDelegateOnScrollListener != null) { // delegate mDelegateOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } // get expected adapter or fail fast ListAdapter adapter = getAdapter(); if (adapter == null || visibleItemCount == 0) return; // nothing to do final boolean isFirstVisibleItemSection = isItemViewTypePinned(adapter, adapter.getItemViewType(firstVisibleItem)); if (isFirstVisibleItemSection) { View sectionView = getChildAt(0); if (sectionView.getTop() == getPaddingTop()) { // view sticks to the top, no need for pinned shadow destroyPinnedShadow(); } else { // section doesn't stick to the top, make sure we have a pinned shadow ensureShadowForPosition(firstVisibleItem, firstVisibleItem, visibleItemCount); } } else { // section is not at the first visible position int sectionPosition = findCurrentSectionPosition(firstVisibleItem); if (sectionPosition > -1) { // we have section position ensureShadowForPosition(sectionPosition, firstVisibleItem, visibleItemCount); } else { // there is no section for the first visible item, destroy shadow destroyPinnedShadow(); } } };
@Override public int getItemViewType(int position) { return mAdapter.getItemViewType(position); }
return originalAdapter.getItemViewType(id);
int type = adapter.getItemViewType(position);