urbanairship-core/src/main/java/com/urbanairship/automation/AutomationEngine.java
@WorkerThread
    private void prepareSchedules(@NonNull final List<ScheduleEntry> entries) {
        if (entries.isEmpty()) {
            return;
        }
        sortSchedulesByPriority(entries);
        for (T schedule : convertEntries(entries)) {
            final String scheduleId = schedule.getId();
            driver.onPrepareSchedule(schedule, new AutomationDriver.PrepareScheduleCallback() {
                @Override
                public void onFinish(@AutomationDriver.PrepareResult final int result) {
                    backgroundHandler.post(new Runnable() {
                        @Override
                        public void run() {

                            // Grab the updated entry
                            ScheduleEntry scheduleEntry = dataManager.getScheduleEntry(scheduleId);

                            // Make sure we are still suppose to be preparing the schedule
                            if (scheduleEntry == null || scheduleEntry.getExecutionState() != ScheduleEntry.STATE_PREPARING_SCHEDULE) {
                                return;
                            }

                            // Verify the schedule is not expired
                            if (scheduleEntry.isExpired()) {
                                handleExpiredEntry(scheduleEntry);
                                return;
                            }

                            switch (result) {
                                case AutomationDriver.RESULT_CANCEL:
                                    dataManager.deleteSchedule(scheduleId);
                                    break;

                                case AutomationDriver.RESULT_CONTINUE:
                                    scheduleEntry.setExecutionState(ScheduleEntry.STATE_WAITING_SCHEDULE_CONDITIONS);
                                    dataManager.saveSchedule(scheduleEntry);
                                    attemptExecution(scheduleEntry);
                                    break;

                                case AutomationDriver.RESULT_SKIP:
                                    scheduleEntry.setExecutionState(ScheduleEntry.STATE_IDLE);
                                    dataManager.saveSchedule(scheduleEntry);
                                    break;

                                case AutomationDriver.RESULT_PENALIZE:
                                    onScheduleFinishedExecuting(scheduleEntry);
                                    break;
                            }
                        }
                    });
                }
            });
        }
    }
/**
     * Called to prepare the schedules after they have been triggered.
     *
     * @param entries The entries to prepare.
     */
Called to prepare the schedules after they have been triggered.
@param entries The entries to prepare.
Called to prepare the schedules after they have been triggered . @param entries The entries to prepare .
@WorkerThread
    private void prepareSchedules(@NonNull final List<ScheduleEntry> entries) {
        if (entries.isEmpty()) {
            return;
        }
        sortSchedulesByPriority(entries);
        for (T schedule : convertEntries(entries)) {
            final String scheduleId = schedule.getId();
            driver.onPrepareSchedule(schedule, new AutomationDriver.PrepareScheduleCallback() {
                @Override
                public void onFinish(@AutomationDriver.PrepareResult final int result) {
                    backgroundHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            ScheduleEntry scheduleEntry = dataManager.getScheduleEntry(scheduleId);
                            if (scheduleEntry == null || scheduleEntry.getExecutionState() != ScheduleEntry.STATE_PREPARING_SCHEDULE) {
                                return;
                            }
                            if (scheduleEntry.isExpired()) {
                                handleExpiredEntry(scheduleEntry);
                                return;
                            }
                            switch (result) {
                                case AutomationDriver.RESULT_CANCEL:
                                    dataManager.deleteSchedule(scheduleId);
                                    break;
                                case AutomationDriver.RESULT_CONTINUE:
                                    scheduleEntry.setExecutionState(ScheduleEntry.STATE_WAITING_SCHEDULE_CONDITIONS);
                                    dataManager.saveSchedule(scheduleEntry);
                                    attemptExecution(scheduleEntry);
                                    break;
                                case AutomationDriver.RESULT_SKIP:
                                    scheduleEntry.setExecutionState(ScheduleEntry.STATE_IDLE);
                                    dataManager.saveSchedule(scheduleEntry);
                                    break;
                                case AutomationDriver.RESULT_PENALIZE:
                                    onScheduleFinishedExecuting(scheduleEntry);
                                    break;
                            }
                        }
                    });
                }
            });
        }
    }
@ WorkerThread private void prepareSchedules ( @ NonNull final List < ScheduleEntry > entries ) { if ( entries . isEmpty ( ) ) { return ; } sortSchedulesByPriority ( entries ) ; for ( T schedule : convertEntries ( entries ) ) { final String scheduleId = schedule . getId ( ) ; driver . onPrepareSchedule ( schedule , new AutomationDriver . PrepareScheduleCallback ( ) { @ Override public void onFinish ( @ AutomationDriver . PrepareResult final int result ) { backgroundHandler . post ( new Runnable ( ) { @ Override public void run ( ) { ScheduleEntry scheduleEntry = dataManager . getScheduleEntry ( scheduleId ) ; if ( scheduleEntry == null || scheduleEntry . getExecutionState ( ) != ScheduleEntry . STATE_PREPARING_SCHEDULE ) { return ; } if ( scheduleEntry . isExpired ( ) ) { handleExpiredEntry ( scheduleEntry ) ; return ; } switch ( result ) { case AutomationDriver . RESULT_CANCEL : dataManager . deleteSchedule ( scheduleId ) ; break ; case AutomationDriver . RESULT_CONTINUE : scheduleEntry . setExecutionState ( ScheduleEntry . STATE_WAITING_SCHEDULE_CONDITIONS ) ; dataManager . saveSchedule ( scheduleEntry ) ; attemptExecution ( scheduleEntry ) ; break ; case AutomationDriver . RESULT_SKIP : scheduleEntry . setExecutionState ( ScheduleEntry . STATE_IDLE ) ; dataManager . saveSchedule ( scheduleEntry ) ; break ; case AutomationDriver . RESULT_PENALIZE : onScheduleFinishedExecuting ( scheduleEntry ) ; break ; } } } ) ; } } ) ; } }
Called to prepare the schedules after they have been triggered.
Called to prepare the schedules after they have been triggered .
// Grab the updated entry // Make sure we are still suppose to be preparing the schedule // Verify the schedule is not expired