public class ExtendedBitmapDrawable extends BasicBitmapDrawable implements Runnable, Parallaxable, DecodeAggregator.Callback
The actual bitmap decode work is handled by DecodeTask
.
Modifier and Type | Class and Description |
---|---|
static class |
ExtendedBitmapDrawable.ExtendedOptions
This class contains the features a client can specify, and arguments to those features.
|
Drawable.Callback, Drawable.ConstantState
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static int |
LOAD_STATE_FAILED |
static int |
LOAD_STATE_LOADED |
static int |
LOAD_STATE_LOADING |
static int |
LOAD_STATE_NOT_YET_LOADED |
static int |
LOAD_STATE_UNINITIALIZED |
mCurrKey, mDecodeHeight, mDecodeWidth, mPaint, mPrevKey
Constructor and Description |
---|
ExtendedBitmapDrawable(Resources res,
BitmapCache cache,
boolean limitDensity,
ExtendedBitmapDrawable.ExtendedOptions opts) |
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas canvas)
Instead of overriding this method, subclasses should override
onDraw(Canvas) . |
protected float |
getDecodeHorizontalCenter()
Clients can override this to specify which section of the source image to decode from.
|
protected float |
getDecodeVerticalCenter()
Clients can override this to specify which section of the source image to decode from.
|
float |
getDrawVerticalCenter() |
protected float |
getDrawVerticalOffsetMultiplier() |
ExtendedBitmapDrawable.ExtendedOptions |
getExtendedOptions()
Get the ExtendedOptions used to instantiate this ExtendedBitmapDrawable.
|
int |
getLoadState()
Get the load state of this drawable.
|
protected void |
loadFileDescriptorFactory()
Should only be overriden, not called.
|
void |
onBecomeFirstExpected(RequestKey key)
The key you declared as expected has become the first expected key in this aggregator.
|
protected void |
onBoundsChange(Rect bounds)
Override this in your subclass to change appearance if you vary based on
the bounds.
|
void |
onDecodeBegin(RequestKey key)
Notifies that the async task's work is about to begin.
|
void |
onDecodeCancel(RequestKey key)
The task has been canceled, and
DecodeTask.DecodeCallback.onDecodeComplete(RequestKey, ReusableBitmap)
will not be called. |
void |
onDecodeComplete(RequestKey key,
ReusableBitmap result)
The task is now complete and the ReusableBitmap is available for use.
|
protected void |
onDecodeFailed()
Called when the decode process is cancelled at any time.
|
protected void |
onDraw(Canvas canvas)
Overriding this method to add your own custom drawing.
|
protected void |
onDrawPlaceholderOrProgress(Canvas canvas,
TileDrawable drawable)
Overriding this method to add your own custom placeholder or progress drawing.
|
void |
onOptsChanged()
Called after a field is changed in an
ExtendedBitmapDrawable.ExtendedOptions , if that field requests this
method to be called. |
void |
run()
When an object implementing interface
Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread. |
void |
setAlpha(int alpha)
Specify an alpha value for the drawable. 0 means fully transparent, and
255 means fully opaque.
|
protected void |
setBitmap(ReusableBitmap bmp)
Should only be overriden, not called.
|
void |
setColorFilter(ColorFilter cf)
Specify an optional color filter for the drawable.
|
void |
setDecodeDimensions(int width,
int height)
Set the dimensions to decode into.
|
void |
setExactDecodeDimensions(int width,
int height)
Directly sets the decode width and height.
|
protected void |
setImage(RequestKey key)
Should only be overriden, not called.
|
void |
setParallaxFraction(float fraction) |
protected boolean |
shouldExecuteStateChange() |
void |
showStaticPlaceholder()
This sets the drawable to the failed state, which remove all animations from the placeholder.
|
bind, decode, fileDescriptorFactoryCreated, getBitmap, getDecodeStrategy, getExecutor, getKey, getLayoutDirectionLocal, getOpacity, getPreviousKey, hasBitmap, invalidateDrawable, onDrawBitmap, onLayoutDirectionChangeLocal, scheduleDrawable, setLayoutDirectionLocal, unbind, unbind, unscheduleDrawable
applyTheme, canApplyTheme, clearColorFilter, clearMutated, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isStateful, isVisible, jumpToCurrentState, mutate, obtainAttributes, onLayoutDirectionChanged, onLevelChange, onStateChange, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setVisible, setXfermode, unscheduleSelf
public static final int LOAD_STATE_UNINITIALIZED
public static final int LOAD_STATE_NOT_YET_LOADED
public static final int LOAD_STATE_LOADING
public static final int LOAD_STATE_LOADED
public static final int LOAD_STATE_FAILED
public static final boolean DEBUG
public ExtendedBitmapDrawable(Resources res, BitmapCache cache, boolean limitDensity, ExtendedBitmapDrawable.ExtendedOptions opts)
public void onOptsChanged()
ExtendedBitmapDrawable.ExtendedOptions
, if that field requests this
method to be called.public void setParallaxFraction(float fraction)
setParallaxFraction
in interface Parallaxable
fraction
- the vertical center point for the viewport, in the range [0,1]public ExtendedBitmapDrawable.ExtendedOptions getExtendedOptions()
public void showStaticPlaceholder()
public void setExactDecodeDimensions(int width, int height)
public void setDecodeDimensions(int width, int height)
setDecodeDimensions
in class BasicBitmapDrawable
protected void setImage(RequestKey key)
BasicBitmapDrawable
setImage
in class BasicBitmapDrawable
protected void setBitmap(ReusableBitmap bmp)
BasicBitmapDrawable
setBitmap
in class BasicBitmapDrawable
protected void loadFileDescriptorFactory()
BasicBitmapDrawable
loadFileDescriptorFactory
in class BasicBitmapDrawable
protected void onDecodeFailed()
BasicBitmapDrawable
onDecodeFailed
in class BasicBitmapDrawable
protected boolean shouldExecuteStateChange()
public float getDrawVerticalCenter()
getDrawVerticalCenter
in class BasicBitmapDrawable
protected final float getDrawVerticalOffsetMultiplier()
getDrawVerticalOffsetMultiplier
in class BasicBitmapDrawable
protected float getDecodeHorizontalCenter()
BasicBitmapDrawable
getDecodeHorizontalCenter
in class BasicBitmapDrawable
protected float getDecodeVerticalCenter()
BasicBitmapDrawable
getDecodeVerticalCenter
in class BasicBitmapDrawable
public void draw(Canvas canvas)
onDraw(Canvas)
.
The reason for this is that we need the placeholder and progress bar to be drawn over our
content. Those two drawables fade out, giving the impression that our content is fading in.
Only override this method for custom drawings on top of all the drawable layers.draw
in class BasicBitmapDrawable
canvas
- The canvas to draw intoprotected void onDraw(Canvas canvas)
protected void onDrawPlaceholderOrProgress(Canvas canvas, TileDrawable drawable)
public void setAlpha(int alpha)
Drawable
setAlpha
in class BasicBitmapDrawable
public void setColorFilter(ColorFilter cf)
Drawable
If a Drawable has a ColorFilter, each output pixel of the Drawable's drawing contents will be modified by the color filter before it is blended onto the render target of a Canvas.
Pass null
to remove any existing color filter.
Note: Setting a non-null
color
filter disables tint
.
setColorFilter
in class BasicBitmapDrawable
cf
- The color filter to apply, or null
to remove the
existing color filterprotected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class Drawable
public void onDecodeBegin(RequestKey key)
DecodeTask.DecodeCallback
N.B. this method runs on the UI thread.
onDecodeBegin
in interface DecodeTask.DecodeCallback
onDecodeBegin
in class BasicBitmapDrawable
public void onBecomeFirstExpected(RequestKey key)
ContiguousFIFOAggregator.Callback
ContiguousFIFOAggregator.forget(Object)
or a task
assigned and executed with ContiguousFIFOAggregator.execute(Object, Runnable)
.onBecomeFirstExpected
in interface ContiguousFIFOAggregator.Callback<RequestKey>
key
- The key that became first. We provide the key so the callback can either not
keep state, or it can keep state which may have changed so the callback can do
a comparison.public void run()
Runnable
Runnable
is used
to create a thread, starting the thread causes the object's
run
method to be called in that separately executing
thread.
The general contract of the method run
is that it may
take any action whatsoever.
run
in interface Runnable
Thread.run()
public void onDecodeComplete(RequestKey key, ReusableBitmap result)
DecodeTask.DecodeCallback
onDecodeComplete
in interface DecodeTask.DecodeCallback
onDecodeComplete
in class BasicBitmapDrawable
public void onDecodeCancel(RequestKey key)
DecodeTask.DecodeCallback
DecodeTask.DecodeCallback.onDecodeComplete(RequestKey, ReusableBitmap)
will not be called.onDecodeCancel
in interface DecodeTask.DecodeCallback
onDecodeCancel
in class BasicBitmapDrawable
public int getLoadState()