public class ImageMemoryCache extends PreloadDataCache<java.lang.String,Bitmap>
ImageSDCardCache
.setOnImageCallbackListener(OnImageCallbackListener)
set callback interface when getting imageget(String, List, View)
get image asynchronous and preload other images asynchronous according to
urlListget(String, View)
get image asynchronoussetHttpReadTimeOut(int)
set http read image time out, if less than 0, not set. default is not setPreloadDataCache.setContext(Context)
and PreloadDataCache.setAllowedNetworkTypes(int)
restrict
the types of networks over which this data can get.setOpenWaitingQueue(boolean)
set whether open waiting queue, default is true. If true, save all view
waiting for image loaded, else only save the newest onePreloadDataCache.setOnGetDataListener(OnGetDataListener)
set how to get image, this cache will get image
and preload images by itSimpleCache.setCacheFullRemoveType(CacheFullRemoveType)
set remove type when cache is fullPreloadDataCache
and SimpleCache
Modifier and Type | Class and Description |
---|---|
static interface |
ImageMemoryCache.OnImageCallbackListener
callback interface when getting image
|
PreloadDataCache.OnGetDataListener<K,V>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_SIZE
recommend default max cache size according to dalvik max memory
|
DEFAULT_BACKWARD_CACHE_NUMBER, DEFAULT_FORWARD_CACHE_NUMBER, DEFAULT_THREAD_POOL_SIZE, NETWORK_MOBILE, NETWORK_WIFI
Constructor and Description |
---|
ImageMemoryCache()
Get data listener is
getDefaultOnGetImageListener()
callback interface when getting image is null, can set by
setOnImageCallbackListener(OnImageCallbackListener)
Maximum size of the cache is DEFAULT_MAX_SIZE
Elements of the cache will not invalid
Remove type is RemoveTypeUsedCountSmall when cache is full
|
ImageMemoryCache(int maxSize)
Get data listener is
getDefaultOnGetImageListener()
callback interface when getting image is null, can set by
setOnImageCallbackListener(OnImageCallbackListener)
Elements of the cache will not invalid
Remove type is RemoveTypeUsedCountSmall when cache is full
|
ImageMemoryCache(int maxSize,
int threadPoolSize)
Get data listener is
getDefaultOnGetImageListener()
callback interface when getting image is null, can set by
setOnImageCallbackListener(OnImageCallbackListener)
Elements of the cache will not invalid
Remove type is RemoveTypeUsedCountSmall when cache is full
|
Modifier and Type | Method and Description |
---|---|
boolean |
get(java.lang.String imageUrl,
java.util.List<java.lang.String> urlList,
View view)
get image asynchronous and preload other images asynchronous according to urlList
|
boolean |
get(java.lang.String imageUrl,
View view)
get image asynchronous. when get image success, it will pass to
ImageMemoryCache.OnImageCallbackListener.onGetSuccess(String, Bitmap, View, boolean) |
PreloadDataCache.OnGetDataListener<java.lang.String,Bitmap> |
getDefaultOnGetImageListener()
default get image listener
|
int |
getHttpReadTimeOut()
get http read image time out, if less than 0, not set. default is not set
|
ImageMemoryCache.OnImageCallbackListener |
getOnImageCallbackListener()
get callback interface when getting image
|
java.util.Map<java.lang.String,java.lang.String> |
getRequestProperties()
get http request properties
|
boolean |
isOpenWaitingQueue()
get whether open waiting queue, default is true.
|
void |
setHttpReadTimeOut(int readTimeOutMillis)
set http read image time out, if less than 0, not set. default is not set, in mills
|
void |
setOnImageCallbackListener(ImageMemoryCache.OnImageCallbackListener onImageCallbackListener)
set callback interface when getting image
|
void |
setOpenWaitingQueue(boolean isOpenWaitingQueue)
set whether open waiting queue, default is true.
|
void |
setRequestProperties(java.util.Map<java.lang.String,java.lang.String> requestProperties)
set http request properties
If image is from the different server, setRequestProperty("Connection", "false") is recommended.
|
void |
setRequestProperty(java.lang.String field,
java.lang.String newValue)
Sets the value of the http request header field
|
java.util.List<java.lang.Runnable> |
shutdownNow() |
checkIsNetworkTypeAllowed, get, getAllowedNetworkTypes, getBackwardCacheNumber, getContext, getForwardCacheNumber, getOnGetDataListener, isCheckNetwork, isExistGettingDataThread, loadCache, setAllowedNetworkTypes, setBackwardCacheNumber, setCheckNetwork, setContext, setForwardCacheNumber, setOnGetDataListener
clear, containsKey, entrySet, getCacheFullRemoveType, getHitCount, getHitRate, getMaxSize, getMissCount, getSize, getValidTime, keySet, put, put, putAll, remove, saveCache, setCacheFullRemoveType, setValidTime, values
public static final int DEFAULT_MAX_SIZE
public ImageMemoryCache()
getDefaultOnGetImageListener()
setOnImageCallbackListener(OnImageCallbackListener)
DEFAULT_MAX_SIZE
RemoveTypeUsedCountSmall
when cache is fullPreloadDataCache.PreloadDataCache()
public ImageMemoryCache(int maxSize)
getDefaultOnGetImageListener()
setOnImageCallbackListener(OnImageCallbackListener)
RemoveTypeUsedCountSmall
when cache is fullmaxSize
- maximum size of the cachePreloadDataCache.PreloadDataCache(int)
public ImageMemoryCache(int maxSize, int threadPoolSize)
getDefaultOnGetImageListener()
setOnImageCallbackListener(OnImageCallbackListener)
RemoveTypeUsedCountSmall
when cache is fullmaxSize
- maximum size of the cachethreadPoolSize
- getting data thread pool sizePreloadDataCache.PreloadDataCache(int, int)
public boolean get(java.lang.String imageUrl, View view)
ImageMemoryCache.OnImageCallbackListener.onGetSuccess(String, Bitmap, View, boolean)
imageUrl
- view
- public boolean get(java.lang.String imageUrl, java.util.List<java.lang.String> urlList, View view)
imageUrl
- urlList
- url list, if is null, not preload, else preload forward by
PreloadDataCache.preloadDataForward(Object, List, int)
, preload backward by
PreloadDataCache.preloadDataBackward(Object, List, int)
view
- public ImageMemoryCache.OnImageCallbackListener getOnImageCallbackListener()
public void setOnImageCallbackListener(ImageMemoryCache.OnImageCallbackListener onImageCallbackListener)
onImageCallbackListener
- public int getHttpReadTimeOut()
public void setHttpReadTimeOut(int readTimeOutMillis)
readTimeOutMillis
- public boolean isOpenWaitingQueue()
public void setOpenWaitingQueue(boolean isOpenWaitingQueue)
isOpenWaitingQueue
- public void setRequestProperties(java.util.Map<java.lang.String,java.lang.String> requestProperties)
requestProperties
- public java.util.Map<java.lang.String,java.lang.String> getRequestProperties()
public void setRequestProperty(java.lang.String field, java.lang.String newValue)
field
- the request header field to be setnewValue
- the new value of the specified property#setRequestProperties(Map)}
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow
in class PreloadDataCache<java.lang.String,Bitmap>
ExecutorService.shutdownNow()
public PreloadDataCache.OnGetDataListener<java.lang.String,Bitmap> getDefaultOnGetImageListener()