Interface ListPreloader.PreloadModelProvider<U>
- Type Parameters:
U- The type of the model being preloaded.
- Enclosing class:
- ListPreloader<T>
-
Method Summary
Modifier and TypeMethodDescriptiongetPreloadItems(int position) Returns aListof models that need to be loaded for the list to display adapter items in positions betweenstartandend.getPreloadRequestBuilder(U item) Returns aRequestBuilderfor a given item on whichRequestBuilder.load(Object)} has been called ornullif no valid load can be started.
-
Method Details
-
getPreloadItems
Returns aListof models that need to be loaded for the list to display adapter items in positions betweenstartandend.positionis the position in the view. If the view contains a mix of types (e.g. headers and images) then not every view position will actually have any model to return here. If that's the case for the givenposition, then return an empty list.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
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.
-