urbanairship-core/src/main/java/com/urbanairship/automation/AutomationEngine.java
private void updateTriggers(@NonNull final List<TriggerEntry> triggerEntries, final JsonSerializable json, final double value) {
        backgroundHandler.post(new Runnable() {
            @Override
            public void run() {
                if (isPaused.get() || triggerEntries.isEmpty()) {
                    return;
                }

                Set<String> triggeredSchedules = new HashSet<>();
                Set<String> cancelledSchedules = new HashSet<>();

                List<TriggerEntry> triggersToUpdate = new ArrayList<>();

                for (TriggerEntry trigger : triggerEntries) {
                    if ((json != null && (trigger.jsonPredicate != null && !trigger.jsonPredicate.apply(json)))) {
                        continue;
                    }

                    triggersToUpdate.add(trigger);
                    trigger.setProgress(trigger.getProgress() + value);

                    if (trigger.getProgress() >= trigger.goal) {
                        trigger.setProgress(0);

                        if (trigger.isCancellation) {
                            cancelledSchedules.add(trigger.scheduleId);
                            cancelScheduleAlarms(Collections.singletonList(trigger.scheduleId));
                        } else {
                            triggeredSchedules.add(trigger.scheduleId);
                        }
                    }
                }

                dataManager.saveTriggers(triggersToUpdate);

                if (!cancelledSchedules.isEmpty()) {
                    handleCancelledSchedules(dataManager.getScheduleEntries(cancelledSchedules));
                }

                if (!triggeredSchedules.isEmpty()) {
                    handleTriggeredSchedules(dataManager.getScheduleEntries(triggeredSchedules));
                }
            }
        });
    }
/**
     * Iterates through a list of triggers that need to respond to an event or state. If a trigger goal
     * is achieved, the correlated schedule is retrieved and the action is applied. The trigger progress
     * and schedule count will then either be incremented or reset / removed.
     *
     * @param triggerEntries The triggers
     * @param json The relevant event or state data.
     * @param value The trigger value to increment by.
     */
Iterates through a list of triggers that need to respond to an event or state. If a trigger goal
is achieved, the correlated schedule is retrieved and the action is applied. The trigger progress
and schedule count will then either be incremented or reset / removed.

@param triggerEntries The triggers
@param json The relevant event or state data.
@param value The trigger value to increment by.
Iterates through a list of triggers that need to respond to an event or state . If a trigger goal is achieved the correlated schedule is retrieved and the action is applied . The trigger progress and schedule count will then either be incremented or reset / removed . @param triggerEntries The triggers @param json The relevant event or state data . @param value The trigger value to increment by .
private void updateTriggers(@NonNull final List<TriggerEntry> triggerEntries, final JsonSerializable json, final double value) {
        backgroundHandler.post(new Runnable() {
            @Override
            public void run() {
                if (isPaused.get() || triggerEntries.isEmpty()) {
                    return;
                }
                Set<String> triggeredSchedules = new HashSet<>();
                Set<String> cancelledSchedules = new HashSet<>();
                List<TriggerEntry> triggersToUpdate = new ArrayList<>();
                for (TriggerEntry trigger : triggerEntries) {
                    if ((json != null && (trigger.jsonPredicate != null && !trigger.jsonPredicate.apply(json)))) {
                        continue;
                    }
                    triggersToUpdate.add(trigger);
                    trigger.setProgress(trigger.getProgress() + value);
                    if (trigger.getProgress() >= trigger.goal) {
                        trigger.setProgress(0);
                        if (trigger.isCancellation) {
                            cancelledSchedules.add(trigger.scheduleId);
                            cancelScheduleAlarms(Collections.singletonList(trigger.scheduleId));
                        } else {
                            triggeredSchedules.add(trigger.scheduleId);
                        }
                    }
                }
                dataManager.saveTriggers(triggersToUpdate);
                if (!cancelledSchedules.isEmpty()) {
                    handleCancelledSchedules(dataManager.getScheduleEntries(cancelledSchedules));
                }
                if (!triggeredSchedules.isEmpty()) {
                    handleTriggeredSchedules(dataManager.getScheduleEntries(triggeredSchedules));
                }
            }
        });
    }
private void updateTriggers ( @ NonNull final List < TriggerEntry > triggerEntries , final JsonSerializable json , final double value ) { backgroundHandler . post ( new Runnable ( ) { @ Override public void run ( ) { if ( isPaused . get ( ) || triggerEntries . isEmpty ( ) ) { return ; } Set < String > triggeredSchedules = new HashSet < > ( ) ; Set < String > cancelledSchedules = new HashSet < > ( ) ; List < TriggerEntry > triggersToUpdate = new ArrayList < > ( ) ; for ( TriggerEntry trigger : triggerEntries ) { if ( ( json != null && ( trigger . jsonPredicate != null && ! trigger . jsonPredicate . apply ( json ) ) ) ) { continue ; } triggersToUpdate . add ( trigger ) ; trigger . setProgress ( trigger . getProgress ( ) + value ) ; if ( trigger . getProgress ( ) >= trigger . goal ) { trigger . setProgress ( 0 ) ; if ( trigger . isCancellation ) { cancelledSchedules . add ( trigger . scheduleId ) ; cancelScheduleAlarms ( Collections . singletonList ( trigger . scheduleId ) ) ; } else { triggeredSchedules . add ( trigger . scheduleId ) ; } } } dataManager . saveTriggers ( triggersToUpdate ) ; if ( ! cancelledSchedules . isEmpty ( ) ) { handleCancelledSchedules ( dataManager . getScheduleEntries ( cancelledSchedules ) ) ; } if ( ! triggeredSchedules . isEmpty ( ) ) { handleTriggeredSchedules ( dataManager . getScheduleEntries ( triggeredSchedules ) ) ; } } } ) ; }
Iterates through a list of triggers that need to respond to an event or state.
Iterates through a list of triggers that need to respond to an event or state .