U
- The type of the model being preloaded.public static interface ListPreloader.PreloadModelProvider<U>
Modifier and Type | Method and Description |
---|---|
java.util.List<U> |
getPreloadItems(int position)
Returns a
List of models that need to be loaded for the list to display adapter items
in positions between start and end . |
RequestBuilder<?> |
getPreloadRequestBuilder(U item)
Returns a
RequestBuilder for a given item on which RequestBuilder.load(Object) } has been called or null if no valid load can be
started. |
@NonNull java.util.List<U> getPreloadItems(int position)
List
of models that need to be loaded for the list to display adapter items
in positions between start
and end
.
A list of any size can be returned so there can be multiple models per adapter position.
Every model returned by this method is expected to produce a valid RequestBuilder
in getPreloadRequestBuilder(Object)
. If that's not possible for any set of models,
avoid including them in the List
returned by this method.
Although it's acceptable for the returned List
to contain null
models,
it's best to filter them from the list instead of adding null
to avoid unnecessary
logic and expanding the size of the List
position
- The adapter position.@Nullable RequestBuilder<?> getPreloadRequestBuilder(@NonNull U item)
RequestBuilder
for a given item on which RequestBuilder.load(Object)
} has been called or null
if no valid load can be
started.
For the preloader to be effective, the RequestBuilder
returned here must use
exactly the same size and set of options as the RequestBuilder
used when the ``View``
is bound. You may need to specify a size in both places to ensure that the width and height
match exactly. If so, you can use BaseRequestOptions.override(int, int)
to do so.
The target and context will be provided by the preloader.
If RequestBuilder.load(Object)
is not called by this method, the preloader will
trigger a RuntimeException
. If you don't want to load a particular item or position,
filter it from the list returned by getPreloadItems(int)
.
item
- The model to load.