类 EaseImageWorker

  • 直接已知子类:
    EaseImageResizer

    public abstract class EaseImageWorker
    extends java.lang.Object
    This 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 EaseImageWorker​(android.content.Context context)  
    • 方法概要

      所有方法 静态方法 实例方法 抽象方法 具体方法 
      修饰符和类型 方法 说明
      void addImageCache​(androidx.fragment.app.FragmentManager fragmentManager, EaseImageCache.ImageCacheParams cacheParams)
      Adds an EaseImageCache to this EaseImageWorker to handle disk and memory bitmap caching.
      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.
      static void cancelWork​(android.widget.ImageView imageView)
      Cancels any pending work attached to the provided ImageView.
      void clearCache()  
      protected void clearCacheInternal()  
      void closeCache()  
      void flushCache()  
      protected EaseImageCache getImageCache()  
      void loadImage​(java.lang.Object data, android.widget.ImageView imageView)
      Load an image specified by the data parameter into an ImageView (override processBitmap(Object) to define the processing logic).
      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.
      void setExitTasksEarly​(boolean exitTasksEarly)  
      void setImageFadeIn​(boolean fadeIn)
      If set to true, the image will fade-in once it has been loaded by the background thread.
      void setLoadingImage​(int resId)
      Set placeholder bitmap that shows when the the background thread is running.
      void setLoadingImage​(android.graphics.Bitmap bitmap)
      Set placeholder bitmap that shows when the the background thread is running.
      void setPauseWork​(boolean pauseWork)
      Pause any ongoing background work.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • mPauseWork

        protected boolean mPauseWork
      • mResources

        protected android.content.res.Resources mResources
      • DUAL_THREAD_EXECUTOR

        public static final java.util.concurrent.Executor DUAL_THREAD_EXECUTOR
    • 构造器详细资料

      • EaseImageWorker

        protected EaseImageWorker​(android.content.Context context)
    • 方法详细资料

      • loadImage

        public void loadImage​(java.lang.Object data,
                              android.widget.ImageView imageView)
        Load an image specified by the data parameter into an ImageView (override processBitmap(Object) to define the processing logic). A memory and disk cache will be used if an EaseImageWorker has been added using . If the image is found in the memory cache, it is set immediately, otherwise an AsyncTask will 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 an EaseImageCache to this EaseImageWorker to 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 by loadImage(Object, ImageView)
        返回:
        The processed bitmap
      • 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 a AbsListView.OnScrollListener to 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()