public final class FileEncodedImageAsync

  1. Object
  2. Image
  3. EncodedImage
  4. FileEncodedImageAsync

ImplementsActionSource

This class is identical to FileEncodedImage with the difference of using asynchronous loading for files (and the animation framework) which will not work for all cases (e.g. renderers) but could improve some performance/RAM aspects.

Methods

public static FileEncodedImageAsync create(String fileName, byte[] placeholder, int width, int height)Deprecated Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
public static FileEncodedImageAsync create(String fileName, Image placeholder)Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
protected void resetCache()A subclass might choose to load asynchroniously and reset the cache when the image is ready.
protected Image getInternal()Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally.
public byte[] getImageData()Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.
public boolean animate()Advances this image’s animation state, if it is animated.
public boolean isAnimation()Returns true if this is an animated image

Inherited methods

Method details

create

public static FileEncodedImageAsync create(String fileName, byte[] placeholder, int width, int height)
Deprecated. use the version that accepts a name and a placeholderImage
Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed. This only works reasonably well for very small files.

Parameters

fileName String
the name of the file
placeholder byte[]
a placeholder image until the actual image loads
width int
the width of the file or -1 if unknown (notice that this will improve performance)
height int
the height of the file or -1 if unknown (notice that this will improve performance)

Returns

image that will load the file seamlessly

create

public static FileEncodedImageAsync create(String fileName, Image placeholder)
Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed. This only works reasonably well for very small files.

Parameters

fileName String
the name of the file
placeholder Image
an image that will occupy the space

Returns

image that will load the file seamlessly

resetCache

protected void resetCache()
A subclass might choose to load asynchroniously and reset the cache when the image is ready.

getInternal

protected Image getInternal()
Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally. This method is useful to detect when the system actually created an image instance. You shouldn’t invoke this method manually!

Returns

drawable image instance

getImageData

public byte[] getImageData()
Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.

Returns

byte array used to create the image, e.g. encoded PNG, JPEG etc.

animate

public boolean animate()
Advances this image’s animation state, if it is animated.

Returns

true if the animation state changed.

isAnimation

public boolean isAnimation()
Returns true if this is an animated image

Returns

true if this image represents an animation