public static class ExtendedBitmapDrawable.ExtendedOptions extends Object
Modifier and Type | Field and Description |
---|---|
int |
backgroundColor
Optional field if
FEATURE_STATE_CHANGES is supported. |
DecodeAggregator |
decodeAggregator
Required field if
FEATURE_ORDERED_DISPLAY is supported. |
float |
decodeHorizontalCenter
Optional field for general decoding.
|
float |
decodeVerticalCenter
Optional field for general decoding.
|
static int |
FEATURE_ORDERED_DISPLAY
Summary:
This feature enables you to draw decoded bitmap in order on the screen, to give the
visual effect of a single decode thread.
|
static int |
FEATURE_PARALLAX
Summary:
This feature enables the image to move in parallax as the user scrolls, to give visual
flair to your images.
|
static int |
FEATURE_STATE_CHANGES
Summary:
This feature enables fading in between multiple decode states, to give smooth transitions
to and from the placeholder, progress bars, and decoded image.
|
int |
features
Non-changeable bit field describing the features you want the
ExtendedBitmapDrawable to support. |
float |
parallaxSpeedMultiplier
Required field if
FEATURE_PARALLAX is supported. |
Drawable |
placeholder
Optional field if
FEATURE_STATE_CHANGES is supported. |
int |
placeholderAnimationDuration
Optional field if
FEATURE_STATE_CHANGES is supported. |
Drawable |
progressBar
Optional field if
FEATURE_STATE_CHANGES is supported. |
Constructor and Description |
---|
ExtendedOptions(int features)
Use this constructor when all the feature parameters are changeable.
|
ExtendedOptions(int features,
Drawable placeholder,
Drawable progressBar)
Use this constructor when you have to specify non-changeable feature parameters.
|
public static final int FEATURE_ORDERED_DISPLAY
DecodeAggregator
to all
the ExtendedBitmapDrawables, and the decode aggregator will hold finished decodes so they
come back in order.
Pros:
Visual consistency. Images are not popping up randomly all over the place.
Cons:
Artificial delay. Images are not drawn as soon as they are decoded. They must wait
for their turn.
Requirements:
Set decodeAggregator
to a shared DecodeAggregator
.public static final int FEATURE_PARALLAX
parallaxSpeedMultiplier
to the ratio between the decoded height and the
visual bound height. Call ExtendedBitmapDrawable.setDecodeDimensions(int, int)
with the height multiplied by parallaxSpeedMultiplier
.
Call ExtendedBitmapDrawable.setParallaxFraction(float)
when the user scrolls.public static final int FEATURE_STATE_CHANGES
ExtendedBitmapDrawable.LOAD_STATE_UNINITIALIZED
,
ExtendedBitmapDrawable.LOAD_STATE_NOT_YET_LOADED
,
ExtendedBitmapDrawable.LOAD_STATE_LOADING
,
ExtendedBitmapDrawable.LOAD_STATE_LOADED
, and
ExtendedBitmapDrawable.LOAD_STATE_FAILED
. These states affect whether the
placeholder and/or the progress bar is showing and animating. We first show the
pulsating placeholder when an image begins decoding. After 2 seconds, we fade in a
spinning progress bar. When the decode completes, we fade in the image.
Pros:
Smooth, beautiful transitions avoid perceived jank. Progress indicator informs users that
work is being done and the app is not stalled.
Cons:
Very fast decodes' short decode time would be eclipsed by the animation duration. Static
placeholder could be accomplished by BasicBitmapDrawable
without the added
complexity of states.
Requirements:
Set backgroundColor
to the color used for the background of the placeholder and
progress bar. Use the alternative constructor to populate placeholder
and
progressBar
. Optionally set placeholderAnimationDuration
.public final int features
ExtendedBitmapDrawable
to support.
Example:
opts.features = FEATURE_ORDERED_DISPLAY | FEATURE_PARALLAX | FEATURE_STATE_CHANGES;
public float decodeHorizontalCenter
public float decodeVerticalCenter
ExtendedBitmapDrawable.setParallaxFraction(float)
. This field
determines the general section for decode. The parallax fraction then determines the
slice from within that section for display.public DecodeAggregator decodeAggregator
FEATURE_ORDERED_DISPLAY
is supported.public float parallaxSpeedMultiplier
FEATURE_PARALLAX
is supported.
A value of 1.5f gives a subtle parallax, and is a good value to
start with. 2.0f gives a more obvious parallax, arguably exaggerated. Some users report
motion sickness with 2.0f. A value of 1.0f is synonymous with no parallax. Be careful not
to set too high a value, since we will start cropping the widths if the image's height is
not sufficient.public int backgroundColor
FEATURE_STATE_CHANGES
is supported. Must be an opaque color.
See Color
.public Drawable placeholder
FEATURE_STATE_CHANGES
is supported.
If you modify this field you must call
ExtendedBitmapDrawable#onOptsChanged(Resources, ExtendedOptions)
on the
appropriate ExtendedBitmapDrawable.public int placeholderAnimationDuration
FEATURE_STATE_CHANGES
is supported.
Special value 0 means default animation duration. Special value -1 means disable the
animation (placeholder will be at maximum alpha always). Any value > 0 defines the
duration in milliseconds.public Drawable progressBar
FEATURE_STATE_CHANGES
is supported.
If you modify this field you must call
ExtendedBitmapDrawable#onOptsChanged(Resources, ExtendedOptions)
on the
appropriate ExtendedBitmapDrawable.