(Redirected from Actions)
Actions
Actions define what happens after an event has occurred. They are bound to certain events (clicks; swipes; long clicks; after load; before load etc...)
Combined together, actions and events form an interaction with the app on a global level. Some actions can be used by only one widget while some others by all widgets.
In the Action Library all actions are described in detail.
Actions can be clearing data from widgets, saving data to database, switching to another screen, loading data to widget, etc…
All actions that are set to widgets are bound to an event. If an action is not bound to an event it can’t be used.
Signature
[gn:act_actionName]|[parameters]
Action types
Regular actions
- They can only be used within an event or another conditional action that accepts actions. In the following example, nothing will happen since the actions are not bound to any event.
- Those actions do not have an event description in Widget Library.
Actions list
- All actions except
Conditional actions
andRepetitive actions
Conditional actions
- Conditional actions are a special type of action and can be used within other actions or events.
- Depending on the outcome of a certain action it executes other actions. Conditional actions work like an 'if' statement. More about conditional actions in Action Library.
Actions list
Repetitive actions
- Conditional actions are a special type of action and can be used within other actions or events.
- Depending on the number of elements in a list or outcome of a certain comparsion result it executes other actions. Conditional actions work like an 'while' or 'for each' statement. More about conditional actions in Action Library.
Actions list
Actions usage best practices
- In order to more efficiently use actions, the following best practices are suggested to all developers:
- Group business logic in a single location in XML file. Use helper views to store business logic code or separate it by functionality and use triggers to call it. This ensures the logic can be more easily understood in one single location and allows reusable components of your business logic to be called upon later via trigger somewhere else.
- In the following example,
FrameLayout
with"@+id/invalidateRecord"
is used to hold a "block" of business logic which is then called when necessary to invalidate record, by action[gn:act_trigger]|[@+invalidateRecord,gn:act_set]
<FrameLayout android:id="@+id/invalidateRecordReloadPointerDataCleanScreen" android:layout_width="wrap_content" android:layout_height="wrap_content" gn:act_set="[gn:act_trigger]|[@+id/invalidateRecord,gn:act_set], [gn:act_cleanWidgets]|[], [gn:act_fill_dropdown]|[@+id/ddCleaningReport_visibleDamages], [gn:act_setVariable]|[@variable/screen2NfcTag, @variable/visitNfcTag], [gn:act_trigger]|@+id/newOrExistingReading, gn:act_set]" /> <!--invalidates record--> <FrameLayout android:id="@+id/invalidateRecord" android:layout_width="wrap_content" android:layout_height="wrap_content" gn:act_set="[gn:act_showSingleChoiceDialog]|[@string/msgBoxInvalidTag, @string/msgBoxDifferentWorkplaceConfirmation,a,a]::], [gn:act_reloadAutoFilledWidgets]|[@+id/timeOutDATA], [gn:act_calculate]|[@+id/workTime, (((@+id/timeOutDATA-@+id/timeInDATA)/1000)/3600)], [gn:act_rawUpdateValues]|[cleaningReports, @variable/reportId; cleaningReport_toiletNumber, cleaningReport_toiletCleaningCompleted, cleaningReport_toiletsShowers, cleaningReport_toiletPaperFilled, cleaningReport_handTowels, cleaningReport_soapFilled, cleaningReport_visibleDamage, cleaningReport_visibleDamageComment, cleaningReport_visibleDamageOtherComments, cleaningReport_employeeInitials, cleaningReport_timeOut, cleaningReport_workingTime, cleaningReport_status; @+id/txtToiletNumberDATA, @+id/txtToiletServiceToiletCleaningCompletedDATA, @+id/txtToiletServiceShowersCleanedDATA, @+id/txtToiletServiceToiletPaperFilledDATA, @+id/txtToiletServiceHandTowelsFilledDATA, @+id/txtToiletServiceSoapFilledDATA, @+id/ddCleaningReport_visibleDamages, @+id/txtToiletServiceDamageCommentsDATA, @id/txtToiletServiceOtherCommentsDATA, @+id/txtEmployeesInitialsDATA, @+id/timeOutDATA, @+id/workTime,2]" />