ItemType - The type of the items, which should be visualized by inflated viewsParamType - The type of the optional parameters, which may be passed when inflating a viewpublic abstract class AbstractViewRecycler<ItemType,ParamType>
extends java.lang.Object
AbstractViewRecycler.Adapter, the views, which should be used to visualize a
specific item, can be inflated and adapted in their appearance. The recycler supports to inflate
different layouts for individual items by overriding an adapter's getViewType- and
getViewTypeCount-method.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractViewRecycler.Adapter<ItemType,ParamType>
An abstract base class for all adapters, which are responsible for inflating views, which
should be used to visualize the items of a view recycler.
|
| Constructor and Description |
|---|
AbstractViewRecycler(android.view.LayoutInflater inflater)
Creates a new recycler, which allows to cache views in order to be able to reuse them later,
instead of inflating new instances.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addUnusedView(android.view.View view,
int viewType)
Adds an unused view to the cache.
|
void |
clearCache()
Removes all unused views from the cache.
|
void |
clearCache(int viewType)
Removes all unused views, which correspond to a specific view type, from the cache.
|
protected java.util.Map<ItemType,android.view.View> |
getActiveViews()
Returns the map, which manages the views, which are currently used to visualize items.
|
AbstractViewRecycler.Adapter<ItemType,ParamType> |
getAdapter()
Returns the adapter, which is used to inflate and adapt the appearance of views.
|
android.content.Context |
getContext()
Returns the context, which is used by the view recycler.
|
protected android.view.LayoutInflater |
getLayoutInflater()
Returns the layout inflater, which is used to inflate views.
|
protected Logger |
getLogger()
Returns the logger, which is used by the recycler.
|
LogLevel |
getLogLevel()
Returns the log level, which is used for logging.
|
android.view.View |
getView(ItemType item)
Returns the view, which is currently used to visualize a specific item.
|
abstract <any> |
inflate(ItemType item,
boolean useCache,
ParamType... params)
Inflates the view, which is used to visualize a specific item.
|
<any> |
inflate(ItemType item,
ParamType... params)
Inflates the view, which is used to visualize a specific item.
|
boolean |
isCacheUsed()
Returns, whether unused views are cached, or not.
|
boolean |
isInflated(ItemType item)
Returns, whether a view is currently inflated to visualize a specific item.
|
protected android.view.View |
pollUnusedView(int viewType)
Retrieves an unused view, which corresponds to a specific view type, from the cache, if any
is available.
|
abstract void |
remove(ItemType item)
Removes a previously inflated view, which is used to visualize a specific item.
|
abstract void |
removeAll()
Removes all previously inflated views.
|
void |
setAdapter(AbstractViewRecycler.Adapter<ItemType,ParamType> adapter)
Sets the adapter, which should be used to inflate and adapt the appearance of views.
|
void |
setLogLevel(LogLevel logLevel)
Sets the log level, which should be used for logging.
|
void |
useCache(boolean useCache)
Sets, whether unused views should be cached, or not.
|
public AbstractViewRecycler(android.view.LayoutInflater inflater)
inflater - The layout inflater, which should be used to inflate views, as an instance of the
class LayoutInflater. The layout inflater may not be nullprotected final void addUnusedView(android.view.View view,
int viewType)
view - The unused view, which should be added to the cache, as an instance of the class
View. The view may not be nullviewType - The view type, the unused view corresponds to, as an Integer valueprotected final android.view.View pollUnusedView(int viewType)
viewType - The view type of the unused view, which should be retrieved, as an Integer
valueView or null, if no such view is available in the cacheprotected final Logger getLogger()
Logger. The logger may not be nullprotected final android.view.LayoutInflater getLayoutInflater()
LayoutInflater. The layout inflater may not be nullprotected java.util.Map<ItemType,android.view.View> getActiveViews()
Map. The map may not be nullpublic abstract <any> inflate(ItemType item, boolean useCache, ParamType... params)
item - The item, which should be visualized by the inflated view, as an instance of the
generic type ItemType. The item may not be nulluseCache - True, if an unused view should retrieved from the cache, if possible, false, if a new
instance should be inflated insteadparams - An array, which may contain optional parameters, as an array of the generic type
ParamType or an empty array, if no optional parameters are availablepublic abstract void remove(ItemType item)
item - The item, which is visualized by the view, which should be removed, as an instance of
the generic type ItemType. The item may not be nullpublic abstract void removeAll()
public final <any> inflate(ItemType item, ParamType... params)
item - The item, which should be visualized by the inflated view, as an instance of the
generic type ItemType. The item may not be nullparams - An array, which may contain optional parameters, as an array of the generic type
ParamType or an empty array, if no optional parameters are availablepublic final android.content.Context getContext()
Context. The context may not be nullpublic final AbstractViewRecycler.Adapter<ItemType,ParamType> getAdapter()
AbstractViewRecycler.Adapter or null, if no adapter is setpublic final void setAdapter(AbstractViewRecycler.Adapter<ItemType,ParamType> adapter)
adapter - The adapter, which should be set, as an instance of the class AbstractViewRecycler.Adapter or
null, if no adapter should be setpublic final LogLevel getLogLevel()
LogLevel.
The log level may not be nullpublic final void setLogLevel(LogLevel logLevel)
logLevel - The log level, which should be set, as a value of the enum LogLevel. The log
level may not be nullpublic final android.view.View getView(ItemType item)
item - The item, whose view should be returned, as an instance of the generic type ItemType.
The item may not be nullpublic final boolean isInflated(ItemType item)
item - The item, which should be checked, as an instance of the generic type ItemType. The
item may not be nullpublic final void clearCache()
public final void clearCache(int viewType)
viewType - The view type of the unused views, which should be removed from the cache, as an
Integer valuepublic final boolean isCacheUsed()
public final void useCache(boolean useCache)
useCache - True, if unused views should be cached, false otherwise