类 EaseImageWorker
- java.lang.Object
-
- io.agora.chat.uikit.widget.video.EaseImageWorker
-
- 直接已知子类:
EaseImageResizer
public abstract class EaseImageWorker extends java.lang.ObjectThis class wraps up completing some arbitrary long running work when loading a bitmap to an ImageView. It handles things like using a memory and disk cache, running the work in a background thread and setting a placeholder image.
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected classEaseImageWorker.CacheAsyncTask
-
字段概要
字段 修饰符和类型 字段 说明 static java.util.concurrent.ExecutorDUAL_THREAD_EXECUTORprotected booleanmPauseWorkprotected android.content.res.ResourcesmResources
-
构造器概要
构造器 限定符 构造器 说明 protectedEaseImageWorker(android.content.Context context)
-
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 voidaddImageCache(androidx.fragment.app.FragmentManager fragmentManager, EaseImageCache.ImageCacheParams cacheParams)Adds anEaseImageCacheto thisEaseImageWorkerto handle disk and memory bitmap caching.static booleancancelPotentialWork(java.lang.Object data, android.widget.ImageView imageView)Returns true if the current work has been canceled or if there was no work in progress on this image view.static voidcancelWork(android.widget.ImageView imageView)Cancels any pending work attached to the provided ImageView.voidclearCache()protected voidclearCacheInternal()voidcloseCache()voidflushCache()protected EaseImageCachegetImageCache()voidloadImage(java.lang.Object data, android.widget.ImageView imageView)Load an image specified by the data parameter into an ImageView (overrideprocessBitmap(Object)to define the processing logic).protected abstract android.graphics.BitmapprocessBitmap(java.lang.Object data)Subclasses should override this to define any processing or work that must happen to produce the final bitmap.voidsetExitTasksEarly(boolean exitTasksEarly)voidsetImageFadeIn(boolean fadeIn)If set to true, the image will fade-in once it has been loaded by the background thread.voidsetLoadingImage(int resId)Set placeholder bitmap that shows when the the background thread is running.voidsetLoadingImage(android.graphics.Bitmap bitmap)Set placeholder bitmap that shows when the the background thread is running.voidsetPauseWork(boolean pauseWork)Pause any ongoing background work.
-
-
-
方法详细资料
-
loadImage
public void loadImage(java.lang.Object data, android.widget.ImageView imageView)Load an image specified by the data parameter into an ImageView (overrideprocessBitmap(Object)to define the processing logic). A memory and disk cache will be used if anEaseImageWorkerhas been added using . If the image is found in the memory cache, it is set immediately, otherwise anAsyncTaskwill be created to asynchronously load the bitmap.- 参数:
data- The URL of the image to download.imageView- The ImageView to bind the downloaded image to.
-
setLoadingImage
public void setLoadingImage(android.graphics.Bitmap bitmap)
Set placeholder bitmap that shows when the the background thread is running.- 参数:
bitmap-
-
setLoadingImage
public void setLoadingImage(int resId)
Set placeholder bitmap that shows when the the background thread is running.- 参数:
resId-
-
addImageCache
public void addImageCache(androidx.fragment.app.FragmentManager fragmentManager, EaseImageCache.ImageCacheParams cacheParams)Adds anEaseImageCacheto thisEaseImageWorkerto handle disk and memory bitmap caching.- 参数:
fragmentManager-cacheParams- The cache parameters to use for the image cache.
-
setImageFadeIn
public void setImageFadeIn(boolean fadeIn)
If set to true, the image will fade-in once it has been loaded by the background thread.
-
setExitTasksEarly
public void setExitTasksEarly(boolean exitTasksEarly)
-
processBitmap
protected abstract android.graphics.Bitmap processBitmap(java.lang.Object data)
Subclasses should override this to define any processing or work that must happen to produce the final bitmap. This will be executed in a background thread and be long running. For example, you could resize a large bitmap here, or pull down an image from the network.- 参数:
data- The data to identify which image to process, as provided byloadImage(Object, ImageView)- 返回:
- The processed bitmap
-
getImageCache
protected EaseImageCache getImageCache()
- 返回:
- The
EaseImageCacheobject currently being used by this ImageWorker.
-
cancelWork
public static void cancelWork(android.widget.ImageView imageView)
Cancels any pending work attached to the provided ImageView.- 参数:
imageView-
-
cancelPotentialWork
public static boolean cancelPotentialWork(java.lang.Object data, android.widget.ImageView imageView)Returns true if the current work has been canceled or if there was no work in progress on this image view. Returns false if the work in progress deals with the same data. The work is not stopped in that case.
-
setPauseWork
public void setPauseWork(boolean pauseWork)
Pause any ongoing background work. This can be used as a temporary measure to improve performance. For example background work could be paused when a ListView or GridView is being scrolled using aAbsListView.OnScrollListenerto keep scrolling smooth.If work is paused, be sure setPauseWork(false) is called again before your fragment or activity is destroyed (for example during ), or there is a risk the background thread will never finish.
-
clearCacheInternal
protected void clearCacheInternal()
-
clearCache
public void clearCache()
-
flushCache
public void flushCache()
-
closeCache
public void closeCache()
-
-