urbanairship-core/src/main/java/com/urbanairship/automation/AutomationEngine.java
public PendingResult<T> editSchedule(@NonNull final String scheduleId, @NonNull final ScheduleEdits edits) {
        final PendingResult<T> pendingResult = new PendingResult<>();

        backgroundHandler.post(new Runnable() {
            @Override
            public void run() {
                ScheduleEntry entry = dataManager.getScheduleEntry(scheduleId);

                if (entry == null) {
                    Logger.error("AutomationEngine - Schedule no longer exists. Unable to edit: " + scheduleId);
                    pendingResult.setResult(null);
                    return;
                }

                entry.applyEdits(edits);

                boolean subscribeForStateChanges = false;
                long stateChangeTimeStamp = -1;

                boolean isOverLimit = entry.isOverLimit();
                boolean isExpired = entry.isExpired();

                // Check if the schedule needs to be rehabilitated or finished due to the edits
                if (entry.getExecutionState() == ScheduleEntry.STATE_FINISHED && !isOverLimit && !isExpired) {
                    subscribeForStateChanges = true;
                    stateChangeTimeStamp = entry.getExecutionStateChangeDate();
                    entry.setExecutionState(ScheduleEntry.STATE_IDLE);
                } else if (entry.getExecutionState() != ScheduleEntry.STATE_FINISHED && (isOverLimit || isExpired)) {
                    entry.setExecutionState(ScheduleEntry.STATE_FINISHED);
                }

                dataManager.saveSchedule(entry);

                if (subscribeForStateChanges) {
                    subscribeStateObservables(entry, stateChangeTimeStamp);
                }

                List<T> result = convertEntries(dataManager.getScheduleEntries(Collections.singleton(scheduleId)));
                Logger.error("AutomationEngine - Updated schedule: " + result);
                pendingResult.setResult(result.size() > 0 ? result.get(0) : null);
            }
        });

        return pendingResult;
    }
/**
     * Edits a schedule.
     *
     * @param scheduleId The schedule ID.
     * @param edits The schedule edits.
     * @return Pending result with the updated schedule.
     */
Edits a schedule.
@param scheduleId The schedule ID.
@param edits The schedule edits.
@return Pending result with the updated schedule.
Edits a schedule . @param scheduleId The schedule ID . @param edits The schedule edits . @return Pending result with the updated schedule .
public PendingResult<T> editSchedule(@NonNull final String scheduleId, @NonNull final ScheduleEdits edits) {
        final PendingResult<T> pendingResult = new PendingResult<>();
        backgroundHandler.post(new Runnable() {
            @Override
            public void run() {
                ScheduleEntry entry = dataManager.getScheduleEntry(scheduleId);
                if (entry == null) {
                    Logger.error("AutomationEngine - Schedule no longer exists. Unable to edit: " + scheduleId);
                    pendingResult.setResult(null);
                    return;
                }
                entry.applyEdits(edits);
                boolean subscribeForStateChanges = false;
                long stateChangeTimeStamp = -1;
                boolean isOverLimit = entry.isOverLimit();
                boolean isExpired = entry.isExpired();
                if (entry.getExecutionState() == ScheduleEntry.STATE_FINISHED && !isOverLimit && !isExpired) {
                    subscribeForStateChanges = true;
                    stateChangeTimeStamp = entry.getExecutionStateChangeDate();
                    entry.setExecutionState(ScheduleEntry.STATE_IDLE);
                } else if (entry.getExecutionState() != ScheduleEntry.STATE_FINISHED && (isOverLimit || isExpired)) {
                    entry.setExecutionState(ScheduleEntry.STATE_FINISHED);
                }
                dataManager.saveSchedule(entry);
                if (subscribeForStateChanges) {
                    subscribeStateObservables(entry, stateChangeTimeStamp);
                }
                List<T> result = convertEntries(dataManager.getScheduleEntries(Collections.singleton(scheduleId)));
                Logger.error("AutomationEngine - Updated schedule: " + result);
                pendingResult.setResult(result.size() > 0 ? result.get(0) : null);
            }
        });
        return pendingResult;
    }
public PendingResult < T > editSchedule ( @ NonNull final String scheduleId , @ NonNull final ScheduleEdits edits ) { final PendingResult < T > pendingResult = new PendingResult < > ( ) ; backgroundHandler . post ( new Runnable ( ) { @ Override public void run ( ) { ScheduleEntry entry = dataManager . getScheduleEntry ( scheduleId ) ; if ( entry == null ) { Logger . error ( "AutomationEngine - Schedule no longer exists. Unable to edit: " + scheduleId ) ; pendingResult . setResult ( null ) ; return ; } entry . applyEdits ( edits ) ; boolean subscribeForStateChanges = false ; long stateChangeTimeStamp = - 1 ; boolean isOverLimit = entry . isOverLimit ( ) ; boolean isExpired = entry . isExpired ( ) ; if ( entry . getExecutionState ( ) == ScheduleEntry . STATE_FINISHED && ! isOverLimit && ! isExpired ) { subscribeForStateChanges = true ; stateChangeTimeStamp = entry . getExecutionStateChangeDate ( ) ; entry . setExecutionState ( ScheduleEntry . STATE_IDLE ) ; } else if ( entry . getExecutionState ( ) != ScheduleEntry . STATE_FINISHED && ( isOverLimit || isExpired ) ) { entry . setExecutionState ( ScheduleEntry . STATE_FINISHED ) ; } dataManager . saveSchedule ( entry ) ; if ( subscribeForStateChanges ) { subscribeStateObservables ( entry , stateChangeTimeStamp ) ; } List < T > result = convertEntries ( dataManager . getScheduleEntries ( Collections . singleton ( scheduleId ) ) ) ; Logger . error ( "AutomationEngine - Updated schedule: " + result ) ; pendingResult . setResult ( result . size ( ) > 0 ? result . get ( 0 ) : null ) ; } } ) ; return pendingResult ; }
Edits a schedule.
Edits a schedule .
// Check if the schedule needs to be rehabilitated or finished due to the edits