Interface ListPreloader.PreloadModelProvider<U>
-
- Type Parameters:
U- The type of the model being preloaded.
- Enclosing class:
- ListPreloader<T>
public static interface ListPreloader.PreloadModelProvider<U>An implementation of PreloadModelProvider should provide all the models that should be preloaded.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<U>getPreloadItems(int position)Returns aListof models that need to be loaded for the list to display adapter items in positions betweenstartandend.RequestBuilder<?>getPreloadRequestBuilder(U item)Returns aRequestBuilderfor a given item on whichRequestBuilder.load(Object)} has been called ornullif no valid load can be started.
-
-
-
Method Detail
-
getPreloadItems
@NonNull java.util.List<U> getPreloadItems(int position)
Returns aListof models that need to be loaded for the list to display adapter items in positions betweenstartandend.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
RequestBuilderingetPreloadRequestBuilder(Object). If that's not possible for any set of models, avoid including them in theListreturned by this method.Although it's acceptable for the returned
Listto containnullmodels, it's best to filter them from the list instead of addingnullto avoid unnecessary logic and expanding the size of theList- Parameters:
position- The adapter position.
-
getPreloadRequestBuilder
@Nullable RequestBuilder<?> getPreloadRequestBuilder(@NonNull U item)
Returns aRequestBuilderfor a given item on whichRequestBuilder.load(Object)} has been called ornullif no valid load can be started.For the preloader to be effective, the
RequestBuilderreturned here must use exactly the same size and set of options as theRequestBuilderused 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 useBaseRequestOptions.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 aRuntimeException. If you don't want to load a particular item or position, filter it from the list returned bygetPreloadItems(int).- Parameters:
item- The model to load.
-
-