State

open class State(source)

Contains useful information about the current RecyclerView state like target scroll position or view focus. State object can also keep arbitrary data, identified by resource ids.

Often times, RecyclerView components will need to pass information between each other. To provide a well defined data bus between components, RecyclerView passes the same State object to component callbacks and these components can use it to exchange data.

If you implement custom components, you can use State's put/get/remove methods to pass data between your components without needing to manage their lifecycles.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
Link copied to clipboard
open fun <T> get(resourceId: Int): T
Gets the Object mapped from the specified id, or null if no such data exists.
Link copied to clipboard
open fun getItemCount(): Int
Returns the total number of items that can be laid out.
Link copied to clipboard
Returns remaining horizontal scroll distance of an ongoing scroll animation(fling/ smoothScrollTo/SmoothScroller) in pixels.
Link copied to clipboard
Returns remaining vertical scroll distance of an ongoing scroll animation(fling/ smoothScrollTo/SmoothScroller) in pixels.
Link copied to clipboard
If scroll is triggered to make a certain item visible, this value will return the adapter index of that item.
Link copied to clipboard
Returns if current scroll has a target position.
Link copied to clipboard
open fun isMeasuring(): Boolean
Returns true if the RecyclerView is currently measuring the layout.
Link copied to clipboard
open fun isPreLayout(): Boolean
Returns true if the RecyclerView is in the pre-layout step where it is having its LayoutManager layout items where they will be at the beginning of a set of predictive item animations.
Link copied to clipboard
open fun put(resourceId: Int, data: Any)
Adds a mapping from the specified id to the specified value, replacing the previous mapping from the specified key if there was one.
Link copied to clipboard
open fun remove(resourceId: Int)
Removes the mapping from the specified id, if there was any.
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
Returns whether RecyclerView will run predictive animations in this layout pass or not.
Link copied to clipboard
Returns whether RecyclerView will run simple animations in this layout pass or not.