WearableLinearLayoutManager

public class WearableLinearLayoutManager extends RecyclerView.LayoutManager, LinearLayoutManager implements ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider


This wear-specific implementation of LinearLayoutManager provides basic offsetting logic for updating child layout. For round devices it offsets the children horizontally to make them appear to travel around a circle. For square devices it aligns them in a straight list. This functionality is provided by the CurvingLayoutCallback which is set when constructing the this class with its default constructor WearableLinearLayoutManager.

Summary

Nested types

WearableLinearLayoutManager.LayoutCallback

Callback for interacting with layout passes.

Public constructors

Creates a WearableLinearLayoutManager for a vertical list.

Creates a WearableLinearLayoutManager for a vertical list.

Public methods

@Nullable WearableLinearLayoutManager.LayoutCallback
@Override @NonNull void

Lay out all relevant child views from the given adapter.

@Override @NonNull int
scrollVerticallyBy(
    @NonNull int dy,
    @NonNull RecyclerView.Recycler recycler,
    @NonNull RecyclerView.State state
)

Scroll vertically by dy pixels in screen coordinates and return the distance traveled.

@NonNull void

Set a particular instance of the layout callback for this WearableLinearLayoutManager.

Inherited methods

From class LinearLayoutManager
@Override @NonNull void

Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is.

@Override @NonNull boolean
@Override @NonNull boolean
@Override @NonNull void
collectAdjacentPrefetchPositions(
    @NonNull int dx,
    @NonNull int dy,
    @NonNull RecyclerView.State state,
    @NonNull RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry
)

Gather all positions from the LayoutManager to be prefetched, given specified momentum.

@Override @NonNull void
collectInitialPrefetchPositions(
    @NonNull int adapterItemCount,
    @NonNull RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry
)

Gather all positions from the LayoutManager to be prefetched in preperation for its RecyclerView to come on screen, due to the movement of another, containing RecyclerView.

@Override @NonNull int

Override this method if you want to support scroll bars.

@Override @NonNull int

Override this method if you want to support scroll bars.

@Override @NonNull int

Override this method if you want to support scroll bars.

@Override @NonNull PointF

Should calculate the vector that points to the direction where the target position can be found.

@Override @NonNull int

Override this method if you want to support scroll bars.

@Override @NonNull int

Override this method if you want to support scroll bars.

@Override @NonNull int

Override this method if you want to support scroll bars.

@NonNull int

Returns the adapter position of the first fully visible view.

@NonNull int

Returns the adapter position of the first visible view.

@NonNull int

Returns the adapter position of the last fully visible view.

@NonNull int

Returns the adapter position of the last visible view.

@Override @NonNull View
findViewByPosition(@NonNull int position)

Finds the view which represents the given adapter position.

@Override @NonNull RecyclerView.LayoutParams

Create a default LayoutParams object for a child of the RecyclerView.

@NonNull int

Gets the number of items to prefetch in collectInitialPrefetchPositions, which defines how many inner items should be prefetched when this LayoutManager's RecyclerView is nested inside another RecyclerView.

@RecyclerView.Orientation @NonNull int

Returns the current orientation of the layout.

@NonNull boolean

Returns whether LayoutManager will recycle its children when it is detached from RecyclerView.

@NonNull boolean

Returns if views are laid out from the opposite direction of the layout.

@NonNull boolean
@Override @NonNull boolean

Returns whether the measuring pass of layout should use the AutoMeasure mechanism of RecyclerView or if it should be done by the LayoutManager's implementation of onMeasure.

@NonNull boolean

Returns the current state of the smooth scrollbar feature.

@Override @NonNull void

Called when this LayoutManager is detached from its parent RecyclerView or when its parent RecyclerView is detached from its window.

@Override @NonNull View
onFocusSearchFailed(
    @NonNull View focused,
    @NonNull int direction,
    @NonNull RecyclerView.Recycler recycler,
    @NonNull RecyclerView.State state
)

Called when searching for a focusable view in the given direction has failed for the current content of the RecyclerView.

@Override @NonNull void
@Override @NonNull void

Called after a full layout calculation is finished.

@Override @NonNull void

Called when the RecyclerView is ready to restore the state based on a previous RecyclerView.

@Override @NonNull Parcelable

Called when the LayoutManager should save its state.

@Override @NonNull void
prepareForDrop(
    @NonNull View view,
    @NonNull View target,
    @NonNull int x,
    @NonNull int y
)

Called by the after a View is dropped over another View.

@Override @NonNull int
scrollHorizontallyBy(
    @NonNull int dx,
    @NonNull RecyclerView.Recycler recycler,
    @NonNull RecyclerView.State state
)

Scroll horizontally by dx pixels in screen coordinates and return the distance traveled.

@Override @NonNull void
scrollToPosition(@NonNull int position)

Scroll the RecyclerView to make the position visible.

@NonNull void
scrollToPositionWithOffset(@NonNull int position, @NonNull int offset)

Scroll to the specified adapter position with the given offset from resolved layout start.

@NonNull void

Sets the number of items to prefetch in collectInitialPrefetchPositions, which defines how many inner items should be prefetched when this LayoutManager's RecyclerView is nested inside another RecyclerView.

@NonNull void

Sets the orientation of the layout.

@NonNull void
setRecycleChildrenOnDetach(@NonNull boolean recycleChildrenOnDetach)

Set whether LayoutManager will recycle its children when it is detached from RecyclerView.

@NonNull void
setReverseLayout(@NonNull boolean reverseLayout)

Used to reverse item traversal and layout order.

@NonNull void

When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed based on the number of visible pixels in the visible items.

@NonNull void
setStackFromEnd(@NonNull boolean stackFromEnd)

Compatibility support for setStackFromBottom

@Override @NonNull void
smoothScrollToPosition(
    @NonNull RecyclerView recyclerView,
    @NonNull RecyclerView.State state,
    @NonNull int position
)

Smooth scroll to the specified adapter position.

@Override @NonNull boolean

Returns whether this LayoutManager supports "predictive item animations".

From class RecyclerView.LayoutManager
@NonNull void

To be called only during onLayoutChildren to add a view to the layout that is known to be going away, either because it has been removed or because it is actually not in the visible portion of the container but is being laid out in order to inform RecyclerView in how to animate the item out of view.

@NonNull void
addDisappearingView(@NonNull View child, @NonNull int index)

To be called only during onLayoutChildren to add a view to the layout that is known to be going away, either because it has been removed or because it is actually not in the visible portion of the container but is being laid out in order to inform RecyclerView in how to animate the item out of view.

@NonNull void

Add a view to the currently attached RecyclerView if needed.

@NonNull void
addView(@NonNull View child, @NonNull int index)

Add a view to the currently attached RecyclerView if needed.

@NonNull void

Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is not.

@NonNull void