Package com.bumptech.glide.util
Class ViewPreloadSizeProvider<T>
- java.lang.Object
-
- com.bumptech.glide.util.ViewPreloadSizeProvider<T>
-
- Type Parameters:
T- The type of the model the size should be provided for.
- All Implemented Interfaces:
ListPreloader.PreloadSizeProvider<T>,SizeReadyCallback
public class ViewPreloadSizeProvider<T> extends java.lang.Object implements ListPreloader.PreloadSizeProvider<T>, SizeReadyCallback
AListPreloader.PreloadSizeProviderthat will extract the preload size from a givenView.
-
-
Constructor Summary
Constructors Constructor Description ViewPreloadSizeProvider()Constructor that does nothing by default and requires users to callsetView(android.view.View)when a View is available to registerComponents the dimensions returned by this class.ViewPreloadSizeProvider(android.view.View view)Constructor that will extract the preload size from a givenView.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]getPreloadSize(T item, int adapterPosition, int itemPosition)Returns the size of the view in the list where the resources will be displayed in pixels in the format [x, y], ornullif no size is currently available.voidonSizeReady(int width, int height)A callback called on the main thread.voidsetView(android.view.View view)Sets theViewthe size will be extracted.
-
-
-
Constructor Detail
-
ViewPreloadSizeProvider
public ViewPreloadSizeProvider()
Constructor that does nothing by default and requires users to callsetView(android.view.View)when a View is available to registerComponents the dimensions returned by this class.
-
ViewPreloadSizeProvider
public ViewPreloadSizeProvider(@NonNull android.view.View view)Constructor that will extract the preload size from a givenView.- Parameters:
view- A not null View the size will be extracted from async using an.OnPreDrawListener
-
-
Method Detail
-
getPreloadSize
@Nullable public int[] getPreloadSize(@NonNull T item, int adapterPosition, int itemPosition)Description copied from interface:ListPreloader.PreloadSizeProviderReturns the size of the view in the list where the resources will be displayed in pixels in the format [x, y], ornullif no size is currently available.Note - The dimensions returned here must precisely match those of the view in the list.
If this method returns
null, then no request will be started for the given item.- Specified by:
getPreloadSizein interfaceListPreloader.PreloadSizeProvider<T>- Parameters:
item- A model
-
onSizeReady
public void onSizeReady(int width, int height)Description copied from interface:SizeReadyCallbackA callback called on the main thread.- Specified by:
onSizeReadyin interfaceSizeReadyCallback- Parameters:
width- The width in pixels of the target, orTarget.SIZE_ORIGINALto indicate that we want the resource at its original width.height- The height in pixels of the target, orTarget.SIZE_ORIGINALto indicate that we want the resource at its original height.
-
setView
public void setView(@NonNull android.view.View view)Sets theViewthe size will be extracted.Note - only the first call to this method will be obeyed, subsequent requests will be ignored.
- Parameters:
view- A not null View the size will be extracted async with an.OnPreDrawListener
-
-