类 EaseImageCache
- java.lang.Object
-
- io.agora.chat.uikit.widget.video.EaseImageCache
-
public class EaseImageCache extends java.lang.ObjectThis class memory caching of bitmaps in conjunction with theEaseImageWorkerclass and its subclasses. UsegetInstance(FragmentManager, ImageCacheParams)to get an instance of this class, although usually a cache should be added directly to anEaseImageWorkerby callingEaseImageWorker.addImageCache(FragmentManager, ImageCacheParams).
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classEaseImageCache.ImageCacheParamsA holder class that contains cache parameters.static classEaseImageCache.RetainFragmentA simple non-UI Fragment that stores a single Object and is retained over configuration changes.
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddBitmapToCache(java.lang.String data, android.graphics.drawable.BitmapDrawable value)Adds a bitmap to both memory and disk cache.voidclearCache()Clears both the memory and disk cache associated with this ImageCache object.android.graphics.drawable.BitmapDrawablegetBitmapFromMemCache(java.lang.String data)Get from memory cache.protected android.graphics.BitmapgetBitmapFromReusableSet(android.graphics.BitmapFactory.Options options)static intgetBitmapSize(android.graphics.drawable.BitmapDrawable value)Get the size in bytes of a bitmap in a BitmapDrawable.static java.io.FilegetDiskCacheDir(android.content.Context context, java.lang.String uniqueName)Get a usable cache directory (external if available, internal otherwise).static java.io.FilegetExternalCacheDir(android.content.Context context)Get the external app cache directory.static EaseImageCachegetInstance(androidx.fragment.app.FragmentManager fragmentManager, EaseImageCache.ImageCacheParams cacheParams)Return anEaseImageCacheinstance.static java.lang.StringhashKeyForDisk(java.lang.String key)A hashing method that changes a string (like a URL) into a hash suitable for using as a disk filename.static booleanisExternalStorageRemovable()Check if external storage is built-in or removable.
-
-
-
方法详细资料
-
getInstance
public static EaseImageCache getInstance(androidx.fragment.app.FragmentManager fragmentManager, EaseImageCache.ImageCacheParams cacheParams)
Return anEaseImageCacheinstance. AEaseImageCache.RetainFragmentis used to retain the ImageCache object across configuration changes such as a change in device orientation.- 参数:
fragmentManager- The fragment manager to use when dealing with the retained fragment.cacheParams- The cache parameters to use if the ImageCache needs instantiation.- 返回:
- An existing retained ImageCache object or a new one if one did not exist
-
addBitmapToCache
public void addBitmapToCache(java.lang.String data, android.graphics.drawable.BitmapDrawable value)Adds a bitmap to both memory and disk cache.- 参数:
data- Unique identifier for the bitmap to storevalue- The bitmap drawable to store
-
getBitmapFromMemCache
public android.graphics.drawable.BitmapDrawable getBitmapFromMemCache(java.lang.String data)
Get from memory cache.- 参数:
data- Unique identifier for which item to get- 返回:
- The bitmap drawable if found in cache, null otherwise
-
getBitmapFromReusableSet
protected android.graphics.Bitmap getBitmapFromReusableSet(android.graphics.BitmapFactory.Options options)
- 参数:
options- - BitmapFactory.Options with out* options populated- 返回:
- Bitmap that case be used for inBitmap
-
clearCache
public void clearCache()
Clears both the memory and disk cache associated with this ImageCache object. Note that this includes disk access so this should not be executed on the main/UI thread.
-
getDiskCacheDir
public static java.io.File getDiskCacheDir(android.content.Context context, java.lang.String uniqueName)Get a usable cache directory (external if available, internal otherwise).- 参数:
context- The context to useuniqueName- A unique directory name to append to the cache dir- 返回:
- The cache dir
-
hashKeyForDisk
public static java.lang.String hashKeyForDisk(java.lang.String key)
A hashing method that changes a string (like a URL) into a hash suitable for using as a disk filename.
-
getBitmapSize
public static int getBitmapSize(android.graphics.drawable.BitmapDrawable value)
Get the size in bytes of a bitmap in a BitmapDrawable. Note that from Android 4.4 (KitKat) onward this returns the allocated memory size of the bitmap which can be larger than the actual bitmap data byte count (in the case it was re-used).- 参数:
value-- 返回:
- size in bytes
-
isExternalStorageRemovable
public static boolean isExternalStorageRemovable()
Check if external storage is built-in or removable.- 返回:
- True if external storage is removable (like an SD card), false otherwise.
-
getExternalCacheDir
public static java.io.File getExternalCacheDir(android.content.Context context)
Get the external app cache directory.- 参数:
context- The context to use- 返回:
- The external cache dir
-
-