ScrollOptimizedLoadingStrategy

class ScrollOptimizedLoadingStrategy(defaultPreloadItemCount: Int = DEFAULT_PRELOAD_ITEM_COUNT, scrollInProgressPreloadItemCount: Int = SCROLL_IN_PROGRESS_PRELOAD_ITEM_COUNT, primaryPreloadItemCount: Int = PRIMARY_PRELOAD_ITEM_COUNT, secondaryPreloadItemCount: Int = SECONDARY_PRELOAD_ITEM_COUNT) : LoadingStrategy

A loading strategy that preloads items above and below the visible range.

When scrolling, this loads more items in the direction the user is scrolling to.

The size of the loading window is kept small while scrolling. It grows when scrolling stops.

This will retain already-loaded items that it wouldn't load otherwise.

Constructors

Link copied to clipboard
constructor(defaultPreloadItemCount: Int = DEFAULT_PRELOAD_ITEM_COUNT, scrollInProgressPreloadItemCount: Int = SCROLL_IN_PROGRESS_PRELOAD_ITEM_COUNT, primaryPreloadItemCount: Int = PRIMARY_PRELOAD_ITEM_COUNT, secondaryPreloadItemCount: Int = SECONDARY_PRELOAD_ITEM_COUNT)

Properties

Link copied to clipboard
open override var firstVisibleIndex: Int

Bounds of what the user is looking at. Everything else is placeholders!

Link copied to clipboard
open override var lastVisibleIndex: Int

Returns the index of the last item that is visible on screen. The item may be partially visible.

Link copied to clipboard

Update this to trigger a programmatic scroll. This may be updated multiple times, including when the previous scroll state is restored.

Functions

Link copied to clipboard
open override fun loadRange(itemCount: Int): IntRange

Returns the range of items to render into the view tree. This should be a slice of 0..(itemCount - 1). It should cover the most-recently scrolled to firstIndex..lastIndex range, plus any adjacent indexes to preload.

Link copied to clipboard
open override fun onUserScroll(firstVisibleIndex: Int, lastVisibleIndex: Int)

React to a user-initiated scroll to the target range.

Link copied to clipboard
open override fun scrollTo(firstVisibleIndex: Int)

Perform a programmatic scroll to firstVisibleIndex.