Lines Matching refs:position

79  *     <li><em>Position:</em> The position of a data item within an <em>Adapter</em>.</li>
83 * to a <em>position</em> within the adapter.</li>
85 * position may be placed in a cache for later reuse to display the same type of data again
104 * For this reason, there are two types of <code>position</code> related methods in RecyclerView:
106 * <li>layout position: Position of an item in the latest layout calculation. This is the
107 * position from the LayoutManager's perspective.</li>
108 * <li>adapter position: Position of an item in the adapter. This is the position from
115 * Methods that return or receive <code>*LayoutPosition*</code> use position as of the latest
123 * The other set of position related methods are in the form of
411 * The RecyclerView is currently animating to a final position while not under
456 // simple array to keep min and max child position during a layout calculation
782 public ViewHolder findViewHolder(int position) {
783 final ViewHolder vh = findViewHolderForPosition(position, true);
1448 * Set a listener that will be notified of any changes in scroll state or position.
1461 * Add a listener that will be notified of any changes in scroll state or position.
1477 * Remove a listener that was notified of any changes in scroll state or position.
1488 * Remove all secondary listener that were notified of any changes in scroll state or position.
1497 * Convenience method to scroll to a certain position.
1501 * @param position Scroll to this adapter position
1504 public void scrollToPosition(int position) {
1510 Log.e(TAG, "Cannot scroll to position a LayoutManager set. "
1514 mLayout.scrollToPosition(position);
1518 void jumpToPositionForSmoothScroller(int position) {
1522 mLayout.scrollToPosition(position);
1527 * Starts a smooth scroll to an adapter position.
1538 * @param position The adapter position to scroll to
1541 public void smoothScrollToPosition(int position) {
1550 mLayout.smoothScrollToPosition(this, mState, position);
1555 Log.w(TAG, "RecyclerView does not support scrolling to an absolute position. "
3285 // mFocusedItemPosition should hold the current adapter position of the previously
3286 // focused item. If the item is removed, we store the previous adapter position of the
3474 // items back to the container). This gives the pre-layout position of APPEARING views
3743 * It might be child's position or stable id depending on the adapter type.
3932 throw new IllegalStateException("view holder cannot have position -1 unless it"
3993 + holder + " now at position " + (holder.mPosition + itemCount));
4013 + " holder " + holder + " now at position "
4036 * @param positionStart Adapter position to start at
4073 * Attached items are labeled as position unknown, and may no longer be cached.
4233 * Return the adapter position that the given child view corresponds to.
4236 * @return Adapter position corresponding to the given view or {@link #NO_POSITION}
4244 * Return the adapter position of the given child view as of the latest completed layout pass.
4246 * This position may not be equal to Item's adapter position if there are pending changes
4250 * @return Adapter position of the given View as of last layout pass or {@link #NO_POSITION} if
4277 public ViewHolder findViewHolderForPosition(int position) {
4278 return findViewHolderForPosition(position, false);
4282 * Return the ViewHolder for the item in the given position of the data set as of the latest
4286 * <code>position</code> is not laid out, it <em>will not</em> create a new one.
4291 * #{@link ViewHolder#getAdapterPosition()} to get the current adapter position of a ViewHolder.
4294 * with the same layout position representing the same Item. In this case, the updated
4297 * @param position The position of the item in the data set of the adapter
4298 * @return The ViewHolder at <code>position</code> or null if there is no such item
4300 public ViewHolder findViewHolderForLayoutPosition(int position) {
4301 return findViewHolderForPosition(position, false);
4305 * Return the ViewHolder for the item in the given position of the data set. Unlike
4313 * <code>position</code> is not laid out, it <em>will not</em> create a new one.
4318 * @param position The position of the item in the data set of the adapter
4319 * @return The ViewHolder at <code>position</code> or null if there is no such item
4321 public ViewHolder findViewHolderForAdapterPosition(int position) {
4331 && getAdapterPositionFor(holder) == position) {
4342 ViewHolder findViewHolderForPosition(int position, boolean checkNewPosition) {
4349 if (holder.mPosition != position) {
4352 } else if (holder.getLayoutPosition() != position) {
4364 // reasonable to return null if position is not laid out.
4404 * @param x Horizontal position in pixels to search
4405 * @param y Vertical position in pixels to search
4526 * Called when the scroll position of this RecyclerView changes. Subclasses should use
4536 * scroll coordinates. Since RecyclerView cannot compute the absolute scroll position from
4539 * do not correspond to the data set scroll position. However, some subclasses may choose
5163 * an adapter's data set representing the data at a given position or item ID.
5229 * Checks whether a given view holder can be used for the provided position.
5232 * @return true if ViewHolder matches the provided position, false otherwise
5246 + "adapter position" + holder);
5267 * @param position Pre-layout position of item to be bound.
5274 int position, long deadlineNs) {
5288 holder.mPreLayoutPosition = position;
5294 * Binds the given View to the position. The View can be a View previously retrieved via
5302 * Note that, {@link #getViewForPosition(int)} already binds the View to the position so
5303 * you don't need to call this method unless you want to bind this View to another position.
5306 * @param position The position of the item to bind to this View.
5308 public void bindViewToPosition(View view, int position) {
5315 final int offsetPosition = mAdapterHelper.findPositionOffset(position);
5318 + "position " + position + "(offset:" + offsetPosition + ")."
5321 tryBindViewHolderByDeadline(holder, offsetPosition, position, FOREVER_NS);
5341 * RecyclerView provides artificial position range (item count) in pre-layout state and
5347 * case you need the actual adapter position instead of the pre layout position. You
5348 * can use this method to convert a pre-layout position to adapter (post layout) position.
5350 * Note that if the provided position belongs to a deleted ViewHolder, this method will
5355 * @param position The pre-layout position to convert. Must be greater or equal to 0 and
5358 public int convertPreLayoutPositionToPostLayout(int position) {
5359 if (position < 0 || position >= mState.getItemCount()) {
5360 throw new IndexOutOfBoundsException("invalid position " + position + ". State "
5364 return position;
5366 return mAdapterHelper.findPositionOffset(position);
5370 * Obtain a view initialized for the given position.
5377 * data at the given position has changed, the Recycler will attempt to hand back
5380 * @param position Position to obtain a view for
5381 * @return A view representing the data at <code>position</code> from <code>adapter</code>
5383 public View getViewForPosition(int position) {
5384 return getViewForPosition(position, false);
5387 View getViewForPosition(int position, boolean dryRun) {
5388 return tryGetViewHolderForPositionByDeadline(position, dryRun, FOREVER_NS).itemView;
5392 * Attempts to get the ViewHolder for the given position, either from the Recycler scrap,
5401 * @param position Position of ViewHolder to be returned.
5407 * @return ViewHolder for requested position
5410 ViewHolder tryGetViewHolderForPositionByDeadline(int position,
5412 if (position < 0 || position >= mState.getItemCount()) {
5413 throw new IndexOutOfBoundsException("Invalid item position " + position
5414 + "(" + position + "). Item count:" + mState.getItemCount());
5420 holder = getChangedScrapViewForPosition(position);
5423 // 1) Find by position from scrap/hidden list/cache
5425 holder = getScrapOrHiddenOrCachedHolderForPosition(position, dryRun);
5448 final int offsetPosition = mAdapterHelper.findPositionOffset(position);
5451 + "position " + position + "(offset:" + offsetPosition + ")."
5461 // update position
5470 .getViewForPositionAndType(this, position, type);
5486 + position + ") fetching from shared pool");
5539 holder.mPreLayoutPosition = position;
5545 final int offsetPosition = mAdapterHelper.findPositionOffset(position);
5546 bound = tryBindViewHolderByDeadline(holder, offsetPosition, position, deadlineNs);
5797 * for rebinding and reuse. Requests for a view for a given position may return a
5854 ViewHolder getChangedScrapViewForPosition(int position) {
5860 // find by position
5863 if (!holder.wasReturnedFromScrap() && holder.getLayoutPosition() == position) {
5870 final int offsetPosition = mAdapterHelper.findPositionOffset(position);
5886 * Returns a view for the position either from attach scrap, hidden children, or cache.
5888 * @param position Item position
5890 * @return a ViewHolder that can be re-used for this position.
5892 ViewHolder getScrapOrHiddenOrCachedHolderForPosition(int position, boolean dryRun) {
5898 if (!holder.wasReturnedFromScrap() && holder.getLayoutPosition() == position
5906 View view = mChildHelper.findHiddenNonRemovedView(position);
5931 if (!holder.isInvalid() && holder.getLayoutPosition() == position) {
5936 Log.d(TAG, "getScrapOrHiddenOrCachedHolderForPosition(" + position
5957 // > item is removed then added to another position and we are in
6053 + holder + " now at position " + (holder.mPosition + count));
6063 * @param applyToPreLayout If true, changes will affect ViewHolder's pre-layout position, if
6075 + " holder " + holder + " now at position "
6200 * Returns a View that can be binded to the given Adapter position.
6203 * an already created View that can be re-used for the given type and position.
6207 * RecyclerView will re-bind the returned View to the position if necessary.
6210 * @param position The adapter position
6212 * @return A View that is bound to the given position or NULL if there is no View to re-use
6215 public abstract View getViewForPositionAndType(Recycler recycler, int position, int type);
6244 * an adapter position.
6254 * Called by RecyclerView to display the data at the specified position. This method should
6256 * position.
6259 * again if the position of the item changes in the data set unless the item itself is
6260 * invalidated or the new position cannot be determined. For this reason, you should only
6261 * use the <code>position</code> parameter while acquiring the related data item inside
6262 * this method and should not keep a copy of it. If you need the position of an item later
6264 * have the updated adapter position.
6270 * item at the given position in the data set.
6271 * @param position The position of the item within the adapter's data set.
6273 public abstract void onBindViewHolder(VH holder, int position);
6276 * Called by RecyclerView to display the data at the specified position. This method
6278 * the given position.
6281 * again if the position of the item changes in the data set unless the item itself is
6282 * invalidated or the new position cannot be determined. For this reason, you should only
6283 * use the <code>position</code> parameter while acquiring the related data item inside
6284 * this method and should not keep a copy of it. If you need the position of an item later
6286 * have the updated adapter position.
6299 * item at the given position in the data set.
6300 * @param position The position of the item within the adapter's data set.
6304 public void onBindViewHolder(VH holder, int position, List<Object> payloads) {
6305 onBindViewHolder(holder, position);
6324 * {@link ViewHolder} contents with the item at the given position and also sets up some
6329 public final void bindViewHolder(VH holder, int position) {
6330 holder.mPosition = position;
6332 holder.mItemId = getItemId(position);
6338 onBindViewHolder(holder, position, holder.getUnmodifiedPayloads());
6348 * Return the view type of the item at <code>position</code> for the purposes
6355 * @param position position to query
6357 * <code>position</code>. Type codes need not be contiguous.
6359 public int getItemViewType(int position) {
6380 * Return the stable ID for the item at <code>position</code>. If {@link #hasStableIds()}
6384 * @param position Adapter position to query
6385 * @return the stable ID of the item at position
6387 public long getItemId(int position) {
6400 * act as a key for the item at a given position in the data set. If that item is relocated
6422 * its adapter position.
6438 * {@link #onBindViewHolder(ViewHolder, int)} call when View is rebound to a new position.
6589 * Notify any registered observers that the item at <code>position</code> has changed.
6590 * Equivalent to calling <code>notifyItemChanged(position, null);</code>.
6593 * reflection of the data at <code>position</code> is out of date and should be updated.
6594 * The item at <code>position</code> retains the same identity.</p>
6596 * @param position Position of the item that has changed
6600 public final void notifyItemChanged(int position) {
6601 mObservable.notifyItemRangeChanged(position, 1);
6605 * Notify any registered observers that the item at <code>position</code> has changed with
6609 * reflection of the data at <code>position</code> is out of date and should be updated.
6610 * The item at <code>position</code> retains the same identity.
6623 * @param position Position of the item that has changed
6628 public final void notifyItemChanged(int position, Object payload) {
6629 mObservable.notifyItemRangeChanged(position, 1, payload);
6634 * position <code>positionStart</code> have changed.
6635 * Equivalent to calling <code>notifyItemRangeChanged(position, itemCount, null);</code>.
6638 * any reflection of the data in the given position range is out of date and should
6652 * position <code>positionStart</code> have changed. An optional payload can be
6656 * reflection of the data in the given position range is out of date and should be updated.
6681 * Notify any registered observers that the item reflected at <code>position</code>
6682 * has been newly inserted. The item previously at <code>position</code> is now at
6683 * position <code>position + 1</code>.
6689 * @param position Position of the newly inserted item in the data set
6693 public final void notifyItemInserted(int position) {
6694 mObservable.notifyItemRangeInserted(position, 1);
6705 * @param fromPosition Previous position of the item.
6706 * @param toPosition New position of the item.
6716 * at position <code>positionStart + itemCount</code>.
6732 * Notify any registered observers that the item previously located at <code>position</code>
6734 * <code>position</code> may now be found at <code>oldPosition - 1</code>.
6740 * @param position Position of the item that has now been removed
6744 public final void notifyItemRemoved(int position) {
6745 mObservable.notifyItemRangeRemoved(position, 1);
6758 * @param positionStart Previous position of the first item that was removed
6863 * Interface for LayoutManagers to request items to be prefetched, based on position, with
6871 * Requests an an item to be prefetched, based on position, with a specified distance,
7388 * pre-layout offscreen position can be determined given the extra
7395 * layout (referred to as DISAPPEARING views), and to position/layout those views
7407 * position
7421 * position, saved state etc.
7504 * @param dx distance to scroll by in pixels. X increases as scroll position
7507 * position
7521 * @param dy distance to scroll in pixels. Y increases as scroll position
7524 * position
7555 * Scroll to the specified adapter position.
7557 * Actual position of the item on the screen depends on the LayoutManager implementation.
7558 * @param position Scroll to this adapter position.
7560 public void scrollToPosition(int position) {
7567 * <p>Smooth scroll to the specified adapter position.</p>
7573 * @param position Scroll to this adapter position.
7576 int position) {
7709 // ensure in correct position
7788 * Returns the adapter position of the item represented by the given View. This does not
7792 * @return The adapter position of the item which is rendered by this View.
7839 * Finds the view which represents the given adapter position.
7847 * @param position Position of the item in adapter
7848 * @return The child view that represents the given position or null if the position is not
7851 public View findViewByPosition(int position) {
7859 if (vh.getLayoutPosition() == position && !vh.shouldIgnore()
7971 * Moves a View from one position to another.
8244 * Scope of ignoring a child is strictly restricted to position tracking, scrapping and
9111 * Note that, an item may also change position in response to another ADD/REMOVE/MOVE
9259 * scroll position, configuration and anything else that may be required to restore the same
9737 * {@link RecyclerView#getChildAdapterPosition(View)} to get the adapter position of the
9872 * its adapter position.
9928 * This ViewHolder has been bound to a position; mPosition, mItemId and mItemViewType
9980 * Set when we can no longer determine the adapter position of this ViewHolder until it is
9981 * rebound to a new position. It is different than FLAG_INVALID because FLAG_INVALID is
9994 * Used by ItemAnimator when a ViewHolder's position changes
10011 * b) LayoutManager asks for the View for that position while the ViewHolder is hidden.
10107 * Returns the position of the ViewHolder in terms of the latest layout pass.
10109 * This position is mostly used by RecyclerView components to be consistent while
10113 * next layout pass. This may cause mismatches between the Adapter position of the item and
10114 * the position it had in the latest layout calculations.
10118 * {@link RecyclerView.Recycler} that receive a position expect it to be the layout position
10121 * If LayoutManager needs to call an external method that requires the adapter position of
10125 * @return Returns the adapter position of the ViewHolder in the latest layout pass.
10133 * Returns the Adapter position of the item represented by this ViewHolder.
10141 * 16ms but it might be a problem if you want to use ViewHolder position to access the
10142 * adapter. Sometimes, you may need to get the exact adapter position to do
10144 * will calculate the Adapter position of the ViewHolder.
10149 * @return The adapter position of the item if it still exists in the adapter.
10165 * If a ViewHolder was laid out in the previous onLayout call, old position will keep its
10169 * {@link #NO_POSITION} if old position does not exists or cleared (pre-layout is
10333 + Integer.toHexString(hashCode()) + " position=" + mPosition + " id=" + mItemId
10346 if (isAdapterPositionUnknown()) sb.append(" undefined adapter position");
10544 * Returns the adapter position that the view this LayoutParams is attached to corresponds
10547 * @return the adapter position this view as of latest layout pass
10554 * Returns the up-to-date adapter position that the view this LayoutParams is attached to
10557 * @return the up-to-date adapter position this view. It may return
10559 * its up-to-date position cannot be calculated.
10599 * <p>Base class for smooth scrolling. Handles basic tracking of the target view position and
10625 * Starts a smooth scroll for the given target position.
10640 throw new IllegalArgumentException("Invalid target position");
10706 * Returns the adapter position of the target item
10708 * @return Adapter position of the target item or
10722 // verify target position
10728 Log.e(TAG, "Passed over target position while smooth scrolling.");
10765 public View findViewByPosition(int position) {
10766 return mRecyclerView.mLayout.findViewByPosition(position);
10774 public void instantScrollToPosition(int position) {
10775 mRecyclerView.scrollToPosition(position);
10789 * @param scrollVector The vector that points to the target scroll position
10811 * position in the layout.</p>
10824 * Called when the target position is laid out. This is the last callback SmoothScroller
10827 * @param targetView The view element which render the target position.
10878 * @param interpolator Interpolator to be used when calculating scroll position in each
10889 * Instead of specifying pixels to scroll, use the target position to jump using
10901 * @param targetPosition The target item position to scroll to using instant scrolling.
10913 final int position = mJumpToPosition;
10915 recyclerView.jumpToPositionForSmoothScroller(position);
11000 * @param interpolator Interpolator to be used when calculating scroll position in each
11014 * to provide a hint to a {@link SmoothScroller} about the location of the target position.
11018 * Should calculate the vector that points to the direction where the target position
11022 * the target position.
11027 * LayoutManager should not check whether the position exists in the adapter or not.
11029 * @param targetPosition the target position to which the returned vector should point
11031 * @return the scroll vector for a given position.
11140 * position or view focus. State object can also keep arbitrary data, identified by resource
11351 * position.
11358 * Returns if current scroll has a target position.
11359 * @return true if scroll is being triggered to make a certain position visible
11377 * number for your position calculations and never access the adapter directly.
11518 * The position of the Item represented by this ViewHolder has been changed. This flag is
11785 * started but its position / size may be changed by the LayoutManager.
11787 * If the Item's layout position didn't change, RecyclerView still calls this method because