java.lang.Object | |||
↳ | android.graphics.drawable.Drawable | ||
↳ | com.facebook.drawee.drawable.ArrayDrawable | ||
↳ | com.facebook.drawee.drawable.FadeDrawable |
A drawable that fades to the specific layer.
Arbitrary number of layers is supported. 5 Different fade methods are supported. Once the transition starts we will animate layers in or out based on used fade method. fadeInLayer fades in specified layer to full opacity. fadeOutLayer fades out specified layer to zero opacity. fadeOutAllLayers fades out all layers to zero opacity. fadeToLayer fades in specified layer to full opacity, fades out all other layers to zero opacity. fadeUpToLayer fades in all layers up to specified layer to full opacity and fades out all other layers to zero opacity.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | FadeDrawable.OnFadeListener |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | TRANSITION_NONE | No transition will be applied. | |||||||||
int | TRANSITION_RUNNING | The transition has started and the animation is in progress. | |||||||||
int | TRANSITION_STARTING | A transition is about to start. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FadeDrawable(Drawable[] layers)
Creates a new fade drawable.
| |||||||||||
FadeDrawable(Drawable[] layers, boolean allLayersVisible, int actualImageLayer)
Creates a new fade drawable.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
beginBatchMode()
Begins the batch mode so that it doesn't invalidate self on every operation.
| ||||||||||
void | draw(Canvas canvas) | ||||||||||
void |
endBatchMode()
Ends the batch mode and invalidates.
| ||||||||||
void |
fadeInAllLayers()
Starts fading in all layers.
| ||||||||||
void |
fadeInLayer(int index)
Starts fading in the specified layer.
| ||||||||||
void |
fadeOutAllLayers()
Starts fading out all layers.
| ||||||||||
void |
fadeOutLayer(int index)
Starts fading out the specified layer.
| ||||||||||
void |
fadeToLayer(int index)
Starts fading to the specified layer.
| ||||||||||
void |
fadeUpToLayer(int index)
Starts fading up to the specified layer.
| ||||||||||
void |
finishTransitionImmediately()
Finishes transition immediately.
| ||||||||||
int | getAlpha() | ||||||||||
int |
getTransitionDuration()
Gets the transition duration.
| ||||||||||
int |
getTransitionState()
Gets the transition state (STARTING, RUNNING, NONE).
| ||||||||||
void |
hideLayerImmediately(int index)
Makes the specified layer fully transparent
| ||||||||||
void | invalidateSelf() | ||||||||||
boolean | isDefaultLayerIsOn() | ||||||||||
boolean | isLayerOn(int index) | ||||||||||
void |
reset()
Resets to the initial state.
| ||||||||||
void | setAlpha(int alpha) | ||||||||||
void | setOnFadeListener(FadeDrawable.OnFadeListener onFadeListener) | ||||||||||
void |
setTransitionDuration(int durationMs)
Sets the duration of the current transition in milliseconds.
| ||||||||||
void |
showLayerImmediately(int index)
Makes the specified layer fully opaque
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
long |
getCurrentTimeMs()
Returns current time.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.facebook.drawee.drawable.ArrayDrawable
| |||||||||||
From class
android.graphics.drawable.Drawable
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.graphics.drawable.Drawable.Callback
| |||||||||||
From interface
com.facebook.drawee.drawable.TransformAwareDrawable
| |||||||||||
From interface
com.facebook.drawee.drawable.TransformCallback
|
No transition will be applied.
The transition has started and the animation is in progress.
A transition is about to start.
Creates a new fade drawable. The first layer is displayed with full opacity whereas all other layers are invisible.
layers | layers to fade between |
---|
Creates a new fade drawable. The first layer is displayed with full opacity whereas all other layers are invisible if allLayersVisible is false. Otherwise, all layers will be displayed with full opacity.
layers | layers to fade between |
---|---|
allLayersVisible | true if all layers should be visible per default |
actualImageLayer | The index of the layer that contains the actual image |
Begins the batch mode so that it doesn't invalidate self on every operation.
Ends the batch mode and invalidates.
Starts fading in all layers.
Starts fading in the specified layer.
index | the index of the layer to fade in. |
---|
Starts fading out all layers.
Starts fading out the specified layer.
index | the index of the layer to fade out. |
---|
Starts fading to the specified layer.
index | the index of the layer to fade to |
---|
Starts fading up to the specified layer.
Layers up to the specified layer inclusive will fade in, other layers will fade out.
index | the index of the layer to fade up to. |
---|
Finishes transition immediately.
Gets the transition duration.
Gets the transition state (STARTING, RUNNING, NONE). Useful for testing purposes.
Makes the specified layer fully transparent
index | the index of the layer to be hidden |
---|
Resets to the initial state.
Sets the duration of the current transition in milliseconds.
Makes the specified layer fully opaque
index | the index of the layer to be shown |
---|
Returns current time. Absolute reference is not important as only time deltas are used. Extracting this to a separate method allows better testing.