|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.ignition.support.cache.CachedModel
com.github.ignition.support.cache.CachedList<CO>
CO - Type of cached models to be stored in listpublic class CachedList<CO extends CachedModel>
Superclass of all list objects to be stored in ModelCache.
Operates just as standard cached object, and contains an array list of objects.
Must be initialized with the class of the objects stored, as this is used in
parcelling/unparcelling.
In order to ensure thread-safe use of list (such as iteration), use the getList()
method, creating a copy of the list in its current state.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
android.os.Parcelable.Creator<T> |
| Field Summary | |
|---|---|
protected Class<? extends CachedModel> |
clazz
Class type of object list |
static android.os.Parcelable.Creator<CachedList<CachedModel>> |
CREATOR
Creator object used for parcelling |
protected ArrayList<CO> |
list
List of objects. |
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Constructor Summary | |
|---|---|
CachedList()
Simple parameter-less constructor. |
|
CachedList(Class<? extends CachedModel> clazz)
Constructor initializing class of objects stored. |
|
CachedList(Class<? extends CachedModel> clazz,
int initialLength)
Constructor initializing class of objects stored as well as initial length of list. |
|
CachedList(Class<? extends CachedModel> clazz,
String id)
Constructor initializing class of objects stored as well as id used in key generation. |
|
CachedList(android.os.Parcel source)
Constructor setting variables from parcel. |
|
| Method Summary | |
|---|---|
void |
add(CO cachedObject)
Synchronized method used to append an object to the list. |
String |
createKey(String id)
Method called to determine a key in the cache using the object's id e.g.: |
boolean |
equals(Object o)
|
CO |
get(int index)
Synchronized method used to get an object from the live list. |
ArrayList<CO> |
getList()
Synchronized method to get a copy of the list in its current state. |
void |
readFromParcel(android.os.Parcel source)
Saves data to parcel. |
boolean |
reload(ModelCache modelCache)
Attempts to reload any new data from cache. |
boolean |
reloadFromCachedModel(ModelCache modelCache,
CachedModel cachedModel)
Method called to reload any data from a more recently stored object e.g.: |
void |
set(int index,
CO cachedObject)
Synchronized method used to set an object at a location in the list. |
int |
size()
Synchronized method used to return size of list. |
void |
writeToParcel(android.os.Parcel dest,
int flags)
|
| Methods inherited from class com.github.ignition.support.cache.CachedModel |
|---|
describeContents, find, getId, getKey, save, save, setId |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Class<? extends CachedModel> clazz
protected ArrayList<CO extends CachedModel> list
public static final android.os.Parcelable.Creator<CachedList<CachedModel>> CREATOR
| Constructor Detail |
|---|
public CachedList()
public CachedList(android.os.Parcel source)
throws IOException
source - Parcel to be read from.
IOExceptionpublic CachedList(Class<? extends CachedModel> clazz)
clazz - Required for parcelling and unparcelling of list
public CachedList(Class<? extends CachedModel> clazz,
int initialLength)
clazz - Required for parcelling and unparcelling of listinitialLength - Initial length of list
public CachedList(Class<? extends CachedModel> clazz,
String id)
clazz - Required for parcelling and unparcelling of listid - ID of new list (used when generating cache key).| Method Detail |
|---|
public ArrayList<CO> getList()
public void add(CO cachedObject)
cachedObject - Object to add to list
public void set(int index,
CO cachedObject)
index - Index of item to setcachedObject - Object to set in listpublic CO get(int index)
index - Index of item in list
public int size()
public boolean equals(Object o)
equals in class ObjectObject.equals(java.lang.Object)public String createKey(String id)
CachedModel
public String createKey(String id) {
"example_object_" + id;
}
createKey in class CachedModelid - ID of object to be stored.
com.github.droidfu.cachefu.CachedModel#createKey(java.lang.String)public boolean reload(ModelCache modelCache)
CachedModel
reload in class CachedModelmodelCache - Cache to be reloaded from.
public boolean reloadFromCachedModel(ModelCache modelCache,
CachedModel cachedModel)
CachedModel
public boolean reloadFromCachedModel(ModelCache modelCache, CachedModel cachedModel) {
ExampleObject cachedExampleObject = (ExampleObject) cachedModel;
this.exampleVariable = cachedExampleObject.exampleVariable;
return false;
}
Can also be used to reload internal cached objects. e.g.:
public boolean reloadFromCachedModel(ModelCache modelCache, CachedModel cachedModel) {
ExampleObject cachedExampleObject = (ExampleObject) cachedModel;
this.exampleInternalCachedObject = cachedExampleObject.exampleInternalCachedObject;
return this.exampleInternalCachedObject.reload(modelCache);
}
reloadFromCachedModel in class CachedModelmodelCache - Cache that is currently being reloaded from.cachedModel - Latest version of object in cache.
com.github.droidfu.cachefu.CachedModel#reloadFromCachedModel(com.github.droidfu.cachefu.ModelCache,
com.github.droidfu.cachefu.CachedModel)
public void readFromParcel(android.os.Parcel source)
throws IOException
CachedModel
readFromParcel in class CachedModelsource - Parcel to save to.
IOExceptioncom.github.droidfu.cachefu.CachedModel#readFromParcel(android.os.Parcel)
public void writeToParcel(android.os.Parcel dest,
int flags)
writeToParcel in interface android.os.ParcelablewriteToParcel in class CachedModelcom.github.droidfu.cachefu.CachedModel#writeToParcel(android.os.Parcel, int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||