|
WIMM Labs |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.view.View
android.view.ViewGroup
android.widget.RelativeLayout
com.wimm.framework.watches.BaseWatchView
public abstract class BaseWatchView
BaseWatchView
is the base class for AnalogWatchView
and DigitalWatchView
.
Nested Class Summary | |
---|---|
static class |
BaseWatchView.UpdateResolution
Enum containing the String constants "SECOND" and "MINUTE". |
Nested classes/interfaces inherited from class android.widget.RelativeLayout |
---|
RelativeLayout.LayoutParams |
Nested classes/interfaces inherited from class android.view.ViewGroup |
---|
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener |
Nested classes/interfaces inherited from class android.view.View |
---|
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener |
Field Summary | |
---|---|
static int |
DRAW_BACKGROUND_ACTIVE
Tag for the watchface background drawable in active mode. |
static int |
DRAW_BACKGROUND_PASSIVE
Tag for the watchface background drawable in passive mode. |
Fields inherited from class android.widget.RelativeLayout |
---|
ABOVE, ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_LEFT, ALIGN_PARENT_BOTTOM, ALIGN_PARENT_LEFT, ALIGN_PARENT_RIGHT, ALIGN_PARENT_TOP, ALIGN_RIGHT, ALIGN_TOP, BELOW, CENTER_HORIZONTAL, CENTER_IN_PARENT, CENTER_VERTICAL, LEFT_OF, RIGHT_OF, TRUE |
Fields inherited from class android.view.ViewGroup |
---|
CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE |
Constructor Summary | |
---|---|
BaseWatchView(Context context,
AttributeSet attrs)
Instantiates a new watch view. |
Method Summary | |
---|---|
void |
animateFromPreview()
Called when the watchface is selected from the watchface picker. |
protected void |
drawComplications(Canvas canvas)
Called by drawWatch(android.graphics.Canvas, android.text.format.Time) and drawPassiveWatch(android.graphics.Canvas, android.text.format.Time) to draw subviews within
BaseWatchView Layout. |
protected void |
drawPassiveWatch(Canvas canvas,
Time time)
Draw the passive watchface on the given canvas set to the given time. |
protected void |
drawWatch(Canvas canvas,
Time time)
Draw the watch face onto the given canvas set to the given time. |
BaseWatchView.UpdateResolution |
getActiveUpdateResolution()
Return how often the watchface should be updated (SECOND or MINUTE). |
Drawable |
getDrawable(int tag)
Retrieves the Drawable watchface asset. |
Time |
getTime()
Convenience method that retrieves the current time. |
boolean |
isAnimatingFromPreview()
Checks if preview animation is running. |
boolean |
isDisplayActive()
Checks whether the screen is in active or passive mode. |
void |
setDisplayActive(boolean isActive)
Called by the system when the screen changes between active and passive mode. |
void |
setDrawable(int tag,
Drawable drawable)
Sets a watchface asset from a Drawable. |
void |
setDrawable(int tag,
int resId)
Sets a watchface asset using a resource ID. |
protected boolean |
shouldDrawPassiveComplications()
Return whether complications should be drawn while in passive mode. |
boolean |
use24HourTime()
Convenience method for checking if the system is set to use 24-hour time. |
Methods inherited from class android.widget.RelativeLayout |
---|
checkLayoutParams, dispatchPopulateAccessibilityEvent, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getBaseline, onLayout, onMeasure, requestLayout, setGravity, setHorizontalGravity, setIgnoreGravity, setVerticalGravity |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface android.view.ViewParent |
---|
createContextMenu, getParent, isLayoutRequested |
Field Detail |
---|
public static final int DRAW_BACKGROUND_ACTIVE
setDrawable(int, int)
,
Constant Field Valuespublic static final int DRAW_BACKGROUND_PASSIVE
setDrawable(int, int)
,
Constant Field ValuesConstructor Detail |
---|
public BaseWatchView(Context context, AttributeSet attrs)
context
- The Context
.attrs
- The AttributeSet
.Method Detail |
---|
public void setDrawable(int tag, int resId)
The following example sets the DRAW_BACKGROUND_PASSIVE
watchface asset to the resource named "my_passive_background":
setDrawable(BaseWatchView.DRAW_BACKGROUND_PASSIVE, R.drawable.my_passive_background);
tag
- The asset constant.resId
- The asset's resource ID.public void setDrawable(int tag, Drawable drawable)
The following example sets the DRAW_BACKGROUND_PASSIVE
watchface asset to the color black:
setDrawable(BaseWatchView.DRAW_BACKGROUND_PASSIVE, new ColorDrawable(Color.BLACK));
tag
- The asset constant.drawable
- The drawable.public Drawable getDrawable(int tag)
tag
- The tag associated with the drawable asset to be retrieved.
public boolean use24HourTime()
protected void drawWatch(Canvas canvas, Time time)
Draw the watch face onto the given canvas set to the given time. This is called just before
the view should render its content (View.onDraw(android.graphics.Canvas)
will be call next).
This is called at a frequency of once every BaseWatchView.UpdateResolution.MINUTE
or once every
BaseWatchView.UpdateResolution.SECOND
determined by the return value of getActiveUpdateResolution()
in active mode.
protected void drawPassiveWatch(Canvas canvas, Time time)
Draw the passive watchface on the given canvas set to the given time. This is called just before
the view should render its content (View.onDraw(android.graphics.Canvas)
will be call next). This is
called at least once every 60 seconds when the device is in Passive mode.
protected void drawComplications(Canvas canvas)
Called by drawWatch(android.graphics.Canvas, android.text.format.Time)
and drawPassiveWatch(android.graphics.Canvas, android.text.format.Time)
to draw subviews within
BaseWatchView Layout.
Note: subviews would note be drawn during passive mode if
shouldDrawPassiveComplications()
return false
public Time getTime()
Time
.public boolean isDisplayActive()
public void setDisplayActive(boolean isActive)
isActive
- true if the screen is in active mode.public BaseWatchView.UpdateResolution getActiveUpdateResolution()
Override this method and return UpdateResolution.MINUTE to switch to per minute update in Active mode.
Default: UpdateResolution.SECOND
protected boolean shouldDrawPassiveComplications()
Return whether complications should be drawn while in passive mode.
Override this and returns false to stop View.dispatchDraw(android.graphics.Canvas)
from being called in passive mode.
public void animateFromPreview()
Override to control the transition from the watchface preview to the current time.
public boolean isAnimatingFromPreview()
|
WIMM Labs |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |