3.1 Events
This Core Library provides several events that are triggered by the NIMMSTA Smart Watch. In this section, we will describe the most important ones.
Scan Event
The most important event for a barcode scanner is the ScanEvent. The ScanEvent provides the barcode that was scanned.
In a future release, we will also provide information about the barcode type to the user. This can be currently tested as pre-release. Please ask one of the developers about this.
Note
If you want to learn more about barcode encodings, have a look at the section under "Advanced Topics".
Button Click Event
A ButtonClickEvent is fired once a Button was clicked.
The sender of the event will be the button object.
Note
The name of the button in this example corresponds to the attribute "name" of the button in the layout.
class ExampleEventHandler implements NIMMSTAEventHandler {
@Override
public void didClickButton(
@NotNull NIMMSTADevice nimmstaDevice,
@Nullable Button button,
@NotNull ButtonClickEvent buttonClickEvent
) {
if (button != null) {
if (Objects.equals(button.getName(), "next_task")) {
// go to next task
}
}
}
}
Touch Event
A TouchEvent represents a single tap on the screen of the NIMMSTA Smart Watch. At the moment, every touch leads to a TouchEvent.
Battery Level Changed Event
A Battery Level Changed Event is fired if the battery level of the scanner changes.
Start Charging Event
A Start Charging Event is fired if the device is placed on the charging pad and starts charging.
Stop Charging Event
A Stop Charging Event is fired if the device is removed from the charging pad and stops charging.
Trigger Event
A Trigger Event is fired if the trigger is pressed on the device. The trigger is the button which is usually used to trigger a scan.
Double Trigger Event
A Double Trigger Event is fired if the trigger is pressed twice on the device in quick succession. The trigger is the button which is usually used to trigger a scan.
Note
Before receiving a Double Trigger Event, you will always receive a Trigger Event.
Triple Trigger Event
A Triple Trigger Event is fired if the trigger is pressed three times on the device in quick succession. The trigger is the button which is usually used to trigger a scan.
Note
Before receiving a Triple Trigger Event, you will always receive first a Trigger Event and then a Double Trigger Event.
Handling all Events
One possibility to handle all events is to use the didReceiveEvent method. There you can get all kinds of available events in one central method:
class ExampleEventHandler implements NIMMSTAEventHandler {
/* ... */
@Override
public void didReceiveEvent(
@NotNull NIMMSTADevice nimmstaDevice,
@NotNull Event event
) {
if (event instanceof BatterySOCChangedEvent) {
} else if (event instanceof TouchEvent) {
} else if (event instanceof ChargingEvent) {
} else if (event instanceof ButtonClickEvent) {
}
}
/* ... */
}