类 EaseImageCache

    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void addBitmapToCache​(java.lang.String data, android.graphics.drawable.BitmapDrawable value)
      Adds a bitmap to both memory and disk cache.
      void clearCache()
      Clears both the memory and disk cache associated with this ImageCache object.
      android.graphics.drawable.BitmapDrawable getBitmapFromMemCache​(java.lang.String data)
      Get from memory cache.
      protected android.graphics.Bitmap getBitmapFromReusableSet​(android.graphics.BitmapFactory.Options options)  
      static int getBitmapSize​(android.graphics.drawable.BitmapDrawable value)
      Get the size in bytes of a bitmap in a BitmapDrawable.
      static java.io.File getDiskCacheDir​(android.content.Context context, java.lang.String uniqueName)
      Get a usable cache directory (external if available, internal otherwise).
      static java.io.File getExternalCacheDir​(android.content.Context context)
      Get the external app cache directory.
      static EaseImageCache getInstance​(androidx.fragment.app.FragmentManager fragmentManager, EaseImageCache.ImageCacheParams cacheParams)
      Return an EaseImageCache instance.
      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.
      static boolean isExternalStorageRemovable()
      Check if external storage is built-in or removable.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 方法详细资料

      • getInstance

        public static EaseImageCache getInstance​(androidx.fragment.app.FragmentManager fragmentManager,
                                                 EaseImageCache.ImageCacheParams cacheParams)
        Return an EaseImageCache instance. A EaseImageCache.RetainFragment is 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 store
        value - 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 use
        uniqueName - 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