Java Code Examples for android.support.v7.widget.RecyclerView.Recycler#getViewForPosition()
The following examples show how to use
android.support.v7.widget.RecyclerView.Recycler#getViewForPosition() .
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: TwoWayLayoutManager.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private View makeAndAddView(int position, Direction direction, Recycler recycler) { final View child = recycler.getViewForPosition(position); final boolean isItemRemoved = ((LayoutParams) child.getLayoutParams()).isItemRemoved(); if (!isItemRemoved) { addView(child, (direction == Direction.END ? -1 : 0)); } setupChild(child, direction); if (!isItemRemoved) { updateLayoutEdgesFromNewChild(child); } return child; }
Example 2
Source File: GridLayoutManager.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override void moveLayoutToPosition(int position, int offset, Recycler recycler, State state) { final Lanes lanes = getLanes(); lanes.reset(offset); getLaneForPosition(mTempLaneInfo, position, Direction.END); final int lane = mTempLaneInfo.startLane; if (lane == 0) { return; } final View child = recycler.getViewForPosition(position); measureChild(child, Direction.END); final int dimension = (isVertical() ? getDecoratedMeasuredHeight(child) : getDecoratedMeasuredWidth(child)); for (int i = lane - 1; i >= 0; i--) { lanes.offset(i, dimension); } }
Example 3
Source File: LinearLayoutManager.java From letv with Apache License 2.0 | 5 votes |
View next(Recycler recycler) { if (this.mScrapList != null) { return nextViewFromScrapList(); } View view = recycler.getViewForPosition(this.mCurrentPosition); this.mCurrentPosition += this.mItemDirection; return view; }
Example 4
Source File: SpannableGridLayoutManager.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override protected void moveLayoutToPosition(int position, int offset, Recycler recycler, State state) { final boolean isVertical = isVertical(); final Lanes lanes = getLanes(); lanes.reset(0); for (int i = 0; i <= position; i++) { SpannableItemEntry entry = (SpannableItemEntry) getItemEntryForPosition(i); if (entry == null) { final View child = recycler.getViewForPosition(i); entry = (SpannableItemEntry) cacheChildLaneAndSpan(child, Direction.END); } mTempLaneInfo.set(entry.startLane, entry.anchorLane); // The lanes might have been invalidated because an added or // removed item. See BaseLayoutManager.invalidateItemLanes(). if (mTempLaneInfo.isUndefined()) { lanes.findLane(mTempLaneInfo, getLaneSpanForPosition(i), Direction.END); entry.setLane(mTempLaneInfo); } lanes.getChildFrame(mTempRect, getChildWidth(entry.colSpan), getChildHeight(entry.rowSpan), mTempLaneInfo, Direction.END); if (i != position) { pushChildFrame(entry, mTempRect, entry.startLane, getLaneSpan(entry, isVertical), Direction.END); } } lanes.getLane(mTempLaneInfo.startLane, mTempRect); lanes.reset(Direction.END); lanes.offset(offset - (isVertical ? mTempRect.bottom : mTempRect.right)); }
Example 5
Source File: LayoutState.java From letv with Apache License 2.0 | 4 votes |
View next(Recycler recycler) { View view = recycler.getViewForPosition(this.mCurrentPosition); this.mCurrentPosition += this.mItemDirection; return view; }
Example 6
Source File: StaggeredGridLayoutManager.java From UltimateAndroid with Apache License 2.0 | 4 votes |
@Override void moveLayoutToPosition(int position, int offset, Recycler recycler, State state) { final boolean isVertical = isVertical(); final Lanes lanes = getLanes(); lanes.reset(0); for (int i = 0; i <= position; i++) { StaggeredItemEntry entry = (StaggeredItemEntry) getItemEntryForPosition(i); if (entry != null) { mTempLaneInfo.set(entry.startLane, entry.anchorLane); // The lanes might have been invalidated because an added or // removed item. See BaseLayoutManager.invalidateItemLanes(). if (mTempLaneInfo.isUndefined()) { lanes.findLane(mTempLaneInfo, getLaneSpanForPosition(i), Direction.END); entry.setLane(mTempLaneInfo); } lanes.getChildFrame(mTempRect, entry.width, entry.height, mTempLaneInfo, Direction.END); } else { final View child = recycler.getViewForPosition(i); // XXX: This might potentially cause stalls in the main // thread if the layout ends up having to measure tons of // child views. We might need to add different policies based // on known assumptions regarding certain layouts e.g. child // views have stable aspect ratio, lane size is fixed, etc. measureChild(child, Direction.END); // The measureChild() call ensures an entry is created for // this position. entry = (StaggeredItemEntry) getItemEntryForPosition(i); mTempLaneInfo.set(entry.startLane, entry.anchorLane); lanes.getChildFrame(mTempRect, getDecoratedMeasuredWidth(child), getDecoratedMeasuredHeight(child), mTempLaneInfo, Direction.END); cacheItemFrame(entry, mTempRect); } if (i != position) { pushChildFrame(entry, mTempRect, entry.startLane, entry.span, Direction.END); } } lanes.getLane(mTempLaneInfo.startLane, mTempRect); lanes.reset(Direction.END); lanes.offset(offset - (isVertical ? mTempRect.bottom : mTempRect.right)); }