public class ComponentWarmer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ComponentWarmer.Cache |
static interface |
ComponentWarmer.CacheListener |
static interface |
ComponentWarmer.ComponentTreeHolderPreparer |
class |
ComponentWarmer.ComponentTreeHolderPreparerWithSizeImpl |
static interface |
ComponentWarmer.ComponentWarmerReadyListener |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMPONENT_WARMER_PREPARE_HANDLER |
static java.lang.String |
COMPONENT_WARMER_TAG |
static int |
DEFAULT_MAX_SIZE |
Constructor and Description |
---|
ComponentWarmer()
Creates a ComponentWarmer instance which is not ready to prepare items yet.
|
ComponentWarmer(ComponentContext c,
int widthSpec,
int heightSpec)
Sets up a
ComponentWarmer.ComponentTreeHolderPreparerWithSizeImpl as the ComponentWarmer.ComponentTreeHolderPreparer of this instance. |
ComponentWarmer(ComponentWarmer.Cache cache) |
ComponentWarmer(ComponentWarmer.ComponentTreeHolderPreparer factory)
Creates a ComponentWarmer which will use the provided ComponentTreeHolderPreparer instance to
create ComponentTreeHolder instances for preparing and caching items.
|
ComponentWarmer(ComponentWarmer.ComponentTreeHolderPreparer factory,
ComponentWarmer.Cache cache)
Same as
ComponentWarmer(ComponentTreeHolderPreparer) but uses the passed in Cache
instance to manage the internal cache. |
ComponentWarmer(RecyclerBinder recyclerBinder)
Creates a ComponentWarmer for this RecyclerBinder.
|
ComponentWarmer(RecyclerBinder recyclerBinder,
ComponentWarmer.Cache cache)
Same as
ComponentWarmer(RecyclerBinder) but uses the passed in Cache instance to
manage the internal cache. |
Modifier and Type | Method and Description |
---|---|
void |
cancelPrepare(java.lang.String tag)
Cancels the prepare execution for the item with the given tag if it's currently running and it
removes the item from the cache.
|
ComponentTreeHolder |
consume(java.lang.String tag)
If it exists, it returns the cached ComponentTreeHolder for this tag and removes it from cache.
|
void |
evictAll() |
boolean |
isReady() |
void |
prepare(java.lang.String tag,
ComponentRenderInfo componentRenderInfo,
Size size)
Synchronously prepare the ComponentTree for the given ComponentRenderInfo.
|
void |
prepare(java.lang.String tag,
ComponentRenderInfo componentRenderInfo,
Size size,
RunnableHandler handler)
Synchronously post preparing the ComponentTree for the given ComponentRenderInfo to the
handler.
|
void |
prepareAsync(java.lang.String tag,
ComponentRenderInfo componentRenderInfo)
Asynchronously prepare the ComponentTree for the given ComponentRenderInfo.
|
void |
remove(java.lang.String tag) |
void |
setComponentWarmerReadyListener(ComponentWarmer.ComponentWarmerReadyListener listener) |
void |
setReleaseEvictedEntries(boolean releaseEvictedEntries) |
public static final java.lang.String COMPONENT_WARMER_TAG
public static final java.lang.String COMPONENT_WARMER_PREPARE_HANDLER
public static final int DEFAULT_MAX_SIZE
public ComponentWarmer(ComponentContext c, int widthSpec, int heightSpec)
ComponentWarmer.ComponentTreeHolderPreparerWithSizeImpl
as the ComponentWarmer.ComponentTreeHolderPreparer
of this instance. All prepare calls will use the provided width
and height specs for preparing, until this instance is configured on a RecyclerBinder and a new
ComponentWarmer.ComponentTreeHolderPreparer
created by the RecyclerBinder is used, which uses the
RecyclerBinder's measurements.public ComponentWarmer()
Pass in a ComponentWarmer.ComponentWarmerReadyListener
instance to be notified when the instance is
ready. Uses a LruCache
to manage the internal cache.
public ComponentWarmer(ComponentWarmer.Cache cache)
public ComponentWarmer(RecyclerBinder recyclerBinder)
LruCache
to
manage the internal cache.public ComponentWarmer(RecyclerBinder recyclerBinder, ComponentWarmer.Cache cache)
ComponentWarmer(RecyclerBinder)
but uses the passed in Cache instance to
manage the internal cache.public ComponentWarmer(ComponentWarmer.ComponentTreeHolderPreparer factory)
LruCache
to manage the internal cache.public ComponentWarmer(ComponentWarmer.ComponentTreeHolderPreparer factory, ComponentWarmer.Cache cache)
ComponentWarmer(ComponentTreeHolderPreparer)
but uses the passed in Cache
instance to manage the internal cache.public void setComponentWarmerReadyListener(ComponentWarmer.ComponentWarmerReadyListener listener)
public void setReleaseEvictedEntries(boolean releaseEvictedEntries)
public boolean isReady()
public void prepare(java.lang.String tag, ComponentRenderInfo componentRenderInfo, Size size, RunnableHandler handler)
public void prepare(java.lang.String tag, ComponentRenderInfo componentRenderInfo, Size size)
tag
- Set a tag on the prepared ComponentTree so it can be retrieved from cache.componentRenderInfo
- to be prepared.size
- if not null, it will have the size result at the end of computing the layout.
Prepare calls which require a size result to be computed cannot be cancelled (@see cancelPrepare(String)
). Prepare calls which are not immediately executed because the
ComponentWarmer is not ready will not set a size.public void prepareAsync(java.lang.String tag, ComponentRenderInfo componentRenderInfo)
The thread on which this ComponentRenderInfo is prepared is the background thread that the
associated RecyclerBinder uses. To change it, you can implement a ComponentWarmer.ComponentTreeHolderPreparer
and configure the layout handler when creating the ComponentTree.
Alternatively you can use prepare(String, ComponentRenderInfo, Size,
RunnableHandler)
to synchronously post the prepare call to a custom handler.
public void evictAll()
public void remove(java.lang.String tag)
public ComponentTreeHolder consume(java.lang.String tag)
public void cancelPrepare(java.lang.String tag)