Skip to content

Commit

Permalink
Re-schedule next state
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkel committed Nov 30, 2017
1 parent ce214b6 commit eedc983
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void cancel(String tag) {

private Job schedule(Job job) {
if (LOCAL_LOGV) {
Log.v(TAG, "schedule "+job.getTag());
Log.v(TAG, "schedule job " + job.getTag());
}
final int result = firebaseJobDispatcher.schedule(job);
if (result == SCHEDULE_RESULT_SUCCESS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,7 @@ protected boolean isBackgroundTask() {
} else {
appLogDebug(state.toString());
appLog(state.isCanceled() ? R.string.app_log_backup_canceled : R.string.app_log_backup_finished);

if (getPreferences().isUseOldScheduler() && state.backupType == BackupType.REGULAR) {
scheduleNextBackup();
}
scheduleNextBackup(state);
stopForeground(true);
stopSelf();
}
Expand Down Expand Up @@ -269,16 +266,26 @@ private void notifyAboutBackup(BackupState state) {
startForeground(BACKUP_ID, notification);
}

private void scheduleNextBackup() {
Log.d(TAG, "scheduling next backup");
final Job nextSync = getBackupJobs().scheduleRegular();
if (nextSync != null) {
JobTrigger.ExecutionWindowTrigger trigger = (JobTrigger.ExecutionWindowTrigger) nextSync.getTrigger();
Date date = new Date(System.currentTimeMillis() + (trigger.getWindowStart() * 1000));
appLog(R.string.app_log_scheduled_next_sync,
DateFormat.format("kk:mm", date));
} else {
appLog(R.string.app_log_no_next_sync);
private void scheduleNextBackup(BackupState state) {
switch (state.backupType) {
case REGULAR:
if (getPreferences().isUseOldScheduler()) {
final Job nextSync = getBackupJobs().scheduleRegular();
if (nextSync != null) {
JobTrigger.ExecutionWindowTrigger trigger = (JobTrigger.ExecutionWindowTrigger) nextSync.getTrigger();
Date date = new Date(System.currentTimeMillis() + (trigger.getWindowStart() * 1000));
appLog(R.string.app_log_scheduled_next_sync,
DateFormat.format("kk:mm", date));
} else {
appLog(R.string.app_log_no_next_sync);
}
}
break;
case INCOMING:
if (!getPreferences().isUseOldScheduler()) {
getBackupJobs().scheduleContentTriggerJob();
}
default: break;
}
}

Expand Down

0 comments on commit eedc983

Please sign in to comment.