T
- The type of the model being displayed in the RecyclerView
.public final class RecyclerViewPreloader<T> extends RecyclerView.OnScrollListener
RecyclerView
so that
images are in the memory cache just before the corresponding view in created in the list. Gives
the appearance of an infinitely large image cache, depending on scrolling speed, cpu speed, and
cache size.
Must be added as a listener to the RecyclerView
using
RecyclerView.addOnScrollListener(RecyclerView.OnScrollListener)
, or have its
corresponding methods called from another
RecyclerView.OnScrollListener
to function.
This class only works with LinearLayoutManager
and
subclasses of LinearLayoutManager
.
Constructor and Description |
---|
RecyclerViewPreloader(Activity activity,
ListPreloader.PreloadModelProvider<T> preloadModelProvider,
ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider,
int maxPreload)
Helper constructor that accepts an
Activity . |
RecyclerViewPreloader(FragmentActivity fragmentActivity,
ListPreloader.PreloadModelProvider<T> preloadModelProvider,
ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider,
int maxPreload)
Helper constructor that accepts an
FragmentActivity . |
RecyclerViewPreloader(Fragment fragment,
ListPreloader.PreloadModelProvider<T> preloadModelProvider,
ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider,
int maxPreload)
Helper constructor that accepts an
Fragment . |
RecyclerViewPreloader(Fragment fragment,
ListPreloader.PreloadModelProvider<T> preloadModelProvider,
ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider,
int maxPreload)
Helper constructor that accepts an
Fragment . |
RecyclerViewPreloader(RequestManager requestManager,
ListPreloader.PreloadModelProvider<T> preloadModelProvider,
ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider,
int maxPreload)
Constructor that accepts interfaces for providing the dimensions of images to preload, the list
of models to preload for a given position, and the request to use to load images.
|
Modifier and Type | Method and Description |
---|---|
void |
onScrolled(RecyclerView recyclerView,
int dx,
int dy) |
onScrollStateChanged
public RecyclerViewPreloader(@NonNull Activity activity, @NonNull ListPreloader.PreloadModelProvider<T> preloadModelProvider, @NonNull ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload)
Activity
.public RecyclerViewPreloader(@NonNull FragmentActivity fragmentActivity, @NonNull ListPreloader.PreloadModelProvider<T> preloadModelProvider, @NonNull ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload)
FragmentActivity
.public RecyclerViewPreloader(@NonNull Fragment fragment, @NonNull ListPreloader.PreloadModelProvider<T> preloadModelProvider, @NonNull ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload)
Fragment
.public RecyclerViewPreloader(@NonNull Fragment fragment, @NonNull ListPreloader.PreloadModelProvider<T> preloadModelProvider, @NonNull ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload)
Fragment
.public RecyclerViewPreloader(@NonNull RequestManager requestManager, @NonNull ListPreloader.PreloadModelProvider<T> preloadModelProvider, @NonNull ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload)
preloadModelProvider
- Provides models to load and requests capable of loading them.preloadDimensionProvider
- Provides the dimensions of images to load.maxPreload
- Maximum number of items to preload.public void onScrolled(RecyclerView recyclerView, int dx, int dy)
onScrolled
in class RecyclerView.OnScrollListener