Class ImageData

java.lang.Object
com.my.target.core.models.MediaData<android.graphics.Bitmap>
com.my.target.common.models.ImageData

public final class ImageData extends com.my.target.core.models.MediaData<android.graphics.Bitmap>
Data class for image content
  • Field Summary

    Fields inherited from class com.my.target.core.models.MediaData

    height, url, width
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clears in-memory cache
    boolean
    equals(Object object)
     
    android.graphics.Bitmap
    Image bitmap, null if not loaded yet
    android.graphics.Bitmap
     
    int
     
    boolean
    Memory cache is disabled by default, bitmaps saves with strong link, but it is possible to turn in on with useCache(boolean) method
    static ImageData
     
    static ImageData
    newImageData(String url, int width, int height)
     
    void
    setBitmap(android.graphics.Bitmap bitmap)
     
    static void
    setCacheSize(int sizeInBytes)
    Maximum in-memory cache size for images.
    void
    setData(android.graphics.Bitmap data)
     
     
    void
    useCache(boolean use)
    By default, memory cache for images is disabled and bitmaps keeps by strong link.

    Methods inherited from class com.my.target.core.models.MediaData

    getHeight, getUrl, getWidth, setHeight, setWidth

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • setCacheSize

      @AnyThread public static void setCacheSize(int sizeInBytes)
      Maximum in-memory cache size for images. Minimum size is 5 MiB, values less will be ignored. Default cache size is 30 MiB
      Parameters:
      sizeInBytes - cache size in bytes
    • clearCache

      @AnyThread public static void clearCache()
      Clears in-memory cache
    • newImageData

      @NonNull public static ImageData newImageData(@NonNull String url)
    • newImageData

      @NonNull public static ImageData newImageData(@NonNull String url, int width, int height)
    • isUseCache

      public boolean isUseCache()
      Memory cache is disabled by default, bitmaps saves with strong link, but it is possible to turn in on with useCache(boolean) method
      Returns:
      is image using memory cache or not
    • getBitmap

      @Nullable public android.graphics.Bitmap getBitmap()
      Image bitmap, null if not loaded yet
      Returns:
      image bitmap
    • setBitmap

      public void setBitmap(@Nullable android.graphics.Bitmap bitmap)
    • getData

      @Nullable public android.graphics.Bitmap getData()
      Overrides:
      getData in class com.my.target.core.models.MediaData<android.graphics.Bitmap>
    • setData

      public void setData(@Nullable android.graphics.Bitmap data)
      Overrides:
      setData in class com.my.target.core.models.MediaData<android.graphics.Bitmap>
    • equals

      public boolean equals(@Nullable Object object)
      Overrides:
      equals in class com.my.target.core.models.MediaData<android.graphics.Bitmap>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class com.my.target.core.models.MediaData<android.graphics.Bitmap>
    • useCache

      public void useCache(boolean use)
      By default, memory cache for images is disabled and bitmaps keeps by strong link. It is possible to turn on memory cache for image, regulated by system. Size of cache can be defined with setCacheSize(int)
      Parameters:
      use - should this ImageData use memory cache or not
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object