public class ComponentWarmer extends 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 String |
COMPONENT_WARMER_PREPARE_HANDLER |
static 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(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(String tag)
If it exists, it returns the cached ComponentTreeHolder for this tag and removes it from cache.
|
void |
evictAll() |
boolean |
isReady() |
void |
prepare(String tag,
ComponentRenderInfo componentRenderInfo,
Size size)
Synchronously prepare the ComponentTree for the given ComponentRenderInfo.
|
void |
prepare(String tag,
ComponentRenderInfo componentRenderInfo,
Size size,
LithoHandler handler)
Synchronously post preparing the ComponentTree for the given ComponentRenderInfo to the
handler.
|
void |
prepareAsync(String tag,
ComponentRenderInfo componentRenderInfo)
Asynchronously prepare the ComponentTree for the given ComponentRenderInfo.
|
void |
remove(String tag) |
void |
setComponentWarmerReadyListener(ComponentWarmer.ComponentWarmerReadyListener listener) |
void |
setReleaseEvictedEntries(boolean releaseEvictedEntries) |
void |
setSkipAlreadyPreparedKeys(boolean skipAlreadyPreparedKeys) |
public static final String COMPONENT_WARMER_TAG
public static final 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 setSkipAlreadyPreparedKeys(boolean skipAlreadyPreparedKeys)
public void setReleaseEvictedEntries(boolean releaseEvictedEntries)
public boolean isReady()
public void prepare(String tag, ComponentRenderInfo componentRenderInfo, Size size, LithoHandler handler)
public void prepare(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(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, LithoHandler)
to synchronously post the prepare call to a custom handler.
public void evictAll()
public void remove(String tag)
public ComponentTreeHolder consume(String tag)
public void cancelPrepare(String tag)