public class SurfaceProgress
- Object
- SurfaceNode
- 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.
Fields
public static final int STYLE_LINEAR = 0 | A horizontal progress bar. |
public static final int STYLE_CIRCULAR = 1 | A circular gauge. |
Constructors
public SurfaceProgress(int style) | Creates a progress node. |
Methods
Inherited methods
Field details
STYLE_LINEAR
public static final int STYLE_LINEAR = 0A horizontal progress bar.
STYLE_CIRCULAR
public static final int STYLE_CIRCULAR = 1A circular gauge. Falls back to linear on Android app widgets.
Constructor details
SurfaceProgress
public SurfaceProgress(int style)Creates a progress node.
Parameters
styleintSTYLE_LINEARorSTYLE_CIRCULAR
Method details
setValue
public SurfaceProgress setValue(float value)Sets a literal progress value.
Parameters
valuefloat- the progress fraction between 0 and 1
Returns
this progress node, for chaining
setValueState
public SurfaceProgress setValueState(String valueStateKey)Reads the progress value from the state map. The state value is a
Number between 0 and 1.Parameters
valueStateKeyString- the state-map key holding the fraction
Returns
this progress node, for chaining
setDateInterval
public SurfaceProgress setDateInterval(Date start, Date end)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
startDate- interval start
endDate- interval end
Returns
this progress node, for chaining
setColor
public SurfaceProgress setColor(SurfaceColor color)Sets the indicator color.
Parameters
colorSurfaceColor- the color
Returns
this progress node, for chaining
getStyle
public int getStyle()Returns
STYLE_LINEAR or STYLE_CIRCULAR.getValue
public float getValue()Returns the literal progress fraction, or -1 when unset.
getValueKey
public String getValueKey()Returns the state-map key of the progress value, or null.
getIntervalStart
public Date getIntervalStart()Returns the animated interval start, or null.
getIntervalEnd
public Date getIntervalEnd()Returns the animated interval end, or null.
getColor
public SurfaceColor getColor()Returns the indicator color, or null for the platform default.
setPadding
public SurfaceProgress setPadding(int all)Sets the same padding on all four sides.
Parameters
allint- padding in dips
Returns
this node, for chaining
setPadding
public SurfaceProgress setPadding(int top, int right, int bottom, int left)Sets the padding of each side individually.
Parameters
topint- top padding in dips
rightint- right padding in dips
bottomint- bottom padding in dips
leftint- left padding in dips
Returns
this node, for chaining
setBackground
public SurfaceProgress setBackground(SurfaceColor background)Sets the background color of this node.
Parameters
backgroundSurfaceColor- the background color
Returns
this node, for chaining
setCornerRadius
public SurfaceProgress setCornerRadius(int radius)Sets the corner radius applied to the node’s background. May render square on Android
versions below 12.
Parameters
radiusint- the corner radius in dips
Returns
this node, for chaining
setAlignment
public SurfaceProgress setAlignment(SurfaceAlignment alignment)Sets this node’s alignment within its parent. In a
SurfaceBox all nine positions apply;
in rows and columns only the cross-axis component is used.Parameters
alignmentSurfaceAlignment- the alignment
Returns
this node, for chaining
setWeight
public SurfaceProgress setWeight(int weight)Sets 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
weightint- the relative weight, 0 for natural sizing
Returns
this node, for chaining
setSize
public SurfaceProgress setSize(int widthDips, int heightDips)Sets a fixed size for this node. A value of 0 (the default) keeps the natural size of the
respective axis.
Parameters
widthDipsint- fixed width in dips, 0 for natural width
heightDipsint- fixed height in dips, 0 for natural height
Returns
this node, for chaining
setAction
public SurfaceProgress setAction(String actionId)Assigns 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
actionIdString- the app-defined action identifier
Returns
this node, for chaining
setAction
public SurfaceProgress setAction(String actionId, Map<String, Object> params)Assigns a tap action with parameters to this node. The parameter map may contain
String,
Number and Boolean values and is delivered verbatim with the SurfaceActionEvent.Parameters
actionIdString- the app-defined action identifier
paramsMap<String, Object>- parameters delivered with the action, may be null
Returns
this node, for chaining