-
- All Implemented Interfaces:
-
com.mobwith.imgmodule.ListPreloader.PreloadSizeProvider,com.mobwith.imgmodule.request.target.SizeReadyCallback
public class ViewPreloadSizeProvider<T> implements ListPreloader.PreloadSizeProvider<T>, SizeReadyCallback
A ListPreloader.PreloadSizeProvider that will extract the preload size from a given View.
-
-
Constructor Summary
Constructors Constructor Description ViewPreloadSizeProvider()Constructor that does nothing by default and requires users to call when a View is available to registerComponents the dimensionsreturned by this class. ViewPreloadSizeProvider(View view)Constructor that will extract the preload size from a given View.
-
Method Summary
Modifier and Type Method Description Array<int>getPreloadSize(@NonNull() T item, int adapterPosition, int itemPosition)Returns the size of the view in the list where the resources will be displayed in pixels inthe format [x, y], or {@code null}if no size is currently available.voidonSizeReady(int width, int height)A callback called on the main thread. voidsetView(@NonNull() View view)Sets the View the size will be extracted. -
-
Method Detail
-
getPreloadSize
@Nullable() Array<int> getPreloadSize(@NonNull() T item, int adapterPosition, int itemPosition)
Returns the size of the view in the list where the resources will be displayed in pixels inthe format [x, y], or
{@code null}if no size is currently available.Note - The dimensions returned here must precisely match those of the view in the list.
If this method returns
{@code null}, then no request will be started for the given item.- Parameters:
item- A model
-
onSizeReady
void onSizeReady(int width, int height)
A callback called on the main thread.
- Parameters:
width- The width in pixels of the target, or SIZE_ORIGINAL to indicatethat we want the resource at its original width.height- The height in pixels of the target, or SIZE_ORIGINAL to indicatethat we want the resource at its original height.
-
-
-
-