Class: Toybox.WatchUi.DataField
- Inherits:
-
Toybox.WatchUi.View
Overview
Create a Data Field.
A DataField is a special View that automatically provides Activity.Info once per second via the compute() method. A DataField requires the implementation of the compute() method to handle the incoming Activity info, and otherwise provides a significant amount of flexibility regarding the way the information is displayed. If less complexity is required, consider a SimpleDataField.
See Also:
The system will call the onUpdate() method inherited from View when a Data Field is displayed by the system. Because compute() and onUpdate() are asynchronous, there is no guarantee that compute() will be called before onUpdate(). For this reason, variables should never be initialized in compute().
Direct Known Subclasses
Constant Summary
-
Obscurity
Name | Value | Since | Description | See Also |
---|---|---|---|---|
OBSCURE_LEFT | 1 | API Level 1.0.0 |
Some of the left edge of the device context is obscured |
|
OBSCURE_TOP | 2 | API Level 1.0.0 |
Some of the top edge of the device context is obscured |
|
OBSCURE_RIGHT | 4 | API Level 1.0.0 |
Some of the right edge of the device context is obscured |
|
OBSCURE_BOTTOM | 8 | API Level 1.0.0 |
Some of the bottom edge of the device context is obscured |
Instance Method Summary collapse
-
compute(info as Activity.Info)
Retrieve Activity.Info in a DataField.
-
createField(name as Lang.String, fieldId as Lang.Number, type as FitContributor.DataType, options as { :count as Lang.Number, :mesgType as FitContributor.MessageType, :units as Lang.String }) as FitContributor.Field
Create a new custom FIT Field.
-
getBackgroundColor() as Graphics.ColorType
Get the current Data Field background color.
-
getObscurityFlags() as DataField.Obscurity
Get the screen regions that are obscured.
-
initialize()
Constructor.
-
onNextMultisportLeg() as Void
The device has transitioned to the next multisport leg.
-
onTimerLap() as Void
A lap event has occurred.
-
onTimerPause() as Void
The activity timer is paused.
-
onTimerReset() as Void
The current activity has ended.
-
onTimerResume() as Void
The activity time has resumed.
-
onTimerStart() as Void
The activity timer has started.
-
onTimerStop() as Void
The activity timer has stopped.
-
onWorkoutStarted() as Void
The current workout is started.
-
onWorkoutStepComplete() as Void
The current workout step is complete.
-
showAlert(alertView as WatchUi.DataFieldAlert) as Void
Show an alert.
Instance Method Details
compute(info as Activity.Info)
Retrieve Activity.Info in a DataField.
This method is called once per second and automatically provides
Activity.Info to the DataField object for
display or additional computation. It is necessary to override
compute()
when implementing a DataField.
createField(name as Lang.String, fieldId as Lang.Number, type as FitContributor.DataType, options as { :count as Lang.Number, :mesgType as FitContributor.MessageType, :units as Lang.String }) as FitContributor.Field
getBackgroundColor() as Graphics.ColorType
Get the current Data Field background color.
Some devices provide a global Data Field background color setting. This method will return the current value of that setting as a value of either Graphics.COLOR_WHITE or Graphics.COLOR_BLACK.
getObscurityFlags() as DataField.Obscurity
Get the screen regions that are obscured.
Non-rectangular screens have certain portions of the screen obscured. For example, a round screen effectively cuts off the corners of a square screen. This method returns a sum of the enumerated values defined by the WatchUi.DataField.OBSCURE_* constants that match the obscured screen regions on the device. Use of this method is only valid during the call to onUpdate().
initialize()
Constructor
onNextMultisportLeg() as Void
The device has transitioned to the next multisport leg.
This method is called when the device transitions to the next multisport leg.
onTimerLap() as Void
A lap event has occurred.
This method is called when a lap is added to the current activity. A notification is triggered after the lap record has been written to the FIT file.
onTimerPause() as Void
The activity timer is paused.
This method is called when the activity timer goes from a running state to a paused state. The paused state occurs when the auto-pause feature pauses the timer. If the activity timer is paused when the app is loaded, this event will run immediately after startup.
onTimerReset() as Void
The current activity has ended.
This method is called when the time has stopped and current activity is ended.
onTimerResume() as Void
The activity time has resumed.
This method is called when the activity timer goes from a paused state to a running state.
onTimerStart() as Void
The activity timer has started.
This method is called when the activity timer goes from a stopped state to a started state. If the activity timer is running when the app is loaded, this event will run immediately after startup.
onTimerStop() as Void
The activity timer has stopped.
This method is called when the activity timer goes from a running state to a stopped state.
onWorkoutStarted() as Void
The current workout is started.
This method is called when the a workout is started.
onWorkoutStepComplete() as Void
The current workout step is complete.
This method is called when the a workout step has been completed.
showAlert(alertView as WatchUi.DataFieldAlert) as Void
Show an alert.