Class SurfaceProgress
A progress indicator node. The value is a fraction between 0 and 1, supplied either literally, by state-map key, or as a date interval the OS animates natively (iOS only; other platforms freeze the interval's value as of the last refresh).
Determinate STYLE_CIRCULAR progress falls back to a linear bar on Android app widgets, which
only support indeterminate circular spinners.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA circular gauge.static final intA horizontal progress bar. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetColor()Returns the indicator color, or null for the platform default.Returns the animated interval end, or null.Returns the animated interval start, or null.intgetStyle()ReturnsSTYLE_LINEARorSTYLE_CIRCULAR.floatgetValue()Returns the literal progress fraction, or -1 when unset.Returns the state-map key of the progress value, or null.Assigns a tap action to this node.Assigns a tap action with parameters to this node.setAlignment(SurfaceAlignment alignment) Sets this node's alignment within its parent.setBackground(SurfaceColor background) Sets the background color of this node.setColor(SurfaceColor color) Sets the indicator color.setCornerRadius(int radius) Sets the corner radius applied to the node's background.setDateInterval(Date start, Date end) Animates progress across a date interval on the OS clock without app wakeups.setPadding(int all) Sets the same padding on all four sides.setPadding(int top, int right, int bottom, int left) Sets the padding of each side individually.setSize(int widthDips, int heightDips) Sets a fixed size for this node.setValue(float value) Sets a literal progress value.setValueState(String valueStateKey) Reads the progress value from the state map.setWeight(int weight) Sets the flexible-space weight of this node within a row or column.Methods inherited from class SurfaceNode
getActionId, getActionParams, getAlignment, getBackground, getCornerRadius, getHeightDips, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getWeight, getWidthDips
-
Field Details
-
STYLE_LINEAR
public static final int STYLE_LINEARA horizontal progress bar.- See Also:
-
STYLE_CIRCULAR
public static final int STYLE_CIRCULARA circular gauge. Falls back to linear on Android app widgets.- See Also:
-
-
Constructor Details
-
SurfaceProgress
public SurfaceProgress(int style) Creates a progress node.
Parameters
style:STYLE_LINEARorSTYLE_CIRCULAR
-
-
Method Details
-
setValue
Sets a literal progress value.
Parameters
value: the progress fraction between 0 and 1
Returns
this progress node, for chaining
-
setValueState
Reads the progress value from the state map. The state value is a
Numberbetween 0 and 1.Parameters
valueStateKey: the state-map key holding the fraction
Returns
this progress node, for chaining
-
setDateInterval
Animates progress across a date interval on the OS clock without app wakeups. Only iOS renders this natively; other platforms display the interval's fraction as of their last refresh.
Parameters
start: interval startend: interval end
Returns
this progress node, for chaining
-
setColor
Sets the indicator color.
Parameters
color: the color
Returns
this progress node, for chaining
-
getStyle
public int getStyle()ReturnsSTYLE_LINEARorSTYLE_CIRCULAR. -
getValue
public float getValue()Returns the literal progress fraction, or -1 when unset. -
getValueKey
Returns the state-map key of the progress value, or null. -
getIntervalStart
Returns the animated interval start, or null. -
getIntervalEnd
Returns the animated interval end, or null. -
getColor
Returns the indicator color, or null for the platform default. -
setPadding
Description copied from class:SurfaceNodeSets the same padding on all four sides.
Parameters
all: padding in dips
Returns
this node, for chaining
- Overrides:
setPaddingin classSurfaceNode
-
setPadding
Description copied from class:SurfaceNodeSets the padding of each side individually.
Parameters
top: top padding in dipsright: right padding in dipsbottom: bottom padding in dipsleft: left padding in dips
Returns
this node, for chaining
- Overrides:
setPaddingin classSurfaceNode
-
setBackground
Description copied from class:SurfaceNodeSets the background color of this node.
Parameters
color: the background color
Returns
this node, for chaining
- Overrides:
setBackgroundin classSurfaceNode
-
setCornerRadius
Description copied from class:SurfaceNodeSets the corner radius applied to the node's background. May render square on Android versions below 12.
Parameters
radius: the corner radius in dips
Returns
this node, for chaining
- Overrides:
setCornerRadiusin classSurfaceNode
-
setAlignment
Description copied from class:SurfaceNodeSets this node's alignment within its parent. In a
SurfaceBoxall nine positions apply; in rows and columns only the cross-axis component is used.Parameters
alignment: the alignment
Returns
this node, for chaining
- Overrides:
setAlignmentin classSurfaceNode
-
setWeight
Description copied from class:SurfaceNodeSets the flexible-space weight of this node within a row or column. Nodes with a weight share the leftover space of the parent proportionally; a weight of 0 (the default) sizes the node to its natural size.
Parameters
weight: the relative weight, 0 for natural sizing
Returns
this node, for chaining
- Overrides:
setWeightin classSurfaceNode
-
setSize
Description copied from class:SurfaceNodeSets a fixed size for this node. A value of 0 (the default) keeps the natural size of the respective axis.
Parameters
widthDips: fixed width in dips, 0 for natural widthheightDips: fixed height in dips, 0 for natural height
Returns
this node, for chaining
- Overrides:
setSizein classSurfaceNode
-
setAction
Description copied from class:SurfaceNodeAssigns a tap action to this node. Tapping the node opens (or foregrounds) the app and delivers the action id to the handler registered with
Surfaces.setActionHandler(...). Note that small iOS home-screen widgets only honor the action of the root node.Parameters
actionId: the app-defined action identifier
Returns
this node, for chaining
- Overrides:
setActionin classSurfaceNode
-
setAction
Description copied from class:SurfaceNodeAssigns a tap action with parameters to this node. The parameter map may contain
String,NumberandBooleanvalues and is delivered verbatim with theSurfaceActionEvent.Parameters
actionId: the app-defined action identifierparams: parameters delivered with the action, may be null
Returns
this node, for chaining
- Overrides:
setActionin classSurfaceNode
-