/** * Specify that this job should recur with the provided interval and flex, not more than once per period. * The flex controls how close to the end of a period the job can run. For example, specifying an interval * of 60 seconds and a flex of 15 seconds will allow the scheduler to determine the best moment between * the 45th and 60th second at which to execute your job. * * <br> * <br> * * As default a job isn't periodic. It isn't allowed to specify a time window for a periodic job. * Instead you set an interval with this function. Since {@link Job.Result#RESCHEDULE} is ignored for * periodic jobs, setting a back-off criteria is illegal as well. * * @param intervalMs The job should run at most once every {@code intervalMs}. The minimum value is {@code 15min}. * @param flexMs How close to the end of the period the job should run. The minimum value is {@code 5min}. * @see #MIN_INTERVAL * @see #MIN_FLEX */ public Builder setPeriodic(long intervalMs, long flexMs) { mIntervalMs = JobPreconditions.checkArgumentInRange(intervalMs, getMinInterval(), Long.MAX_VALUE, "intervalMs"); mFlexMs = JobPreconditions.checkArgumentInRange(flexMs, getMinFlex(), mIntervalMs, "flexMs"); return this; }
public void setTime(int hour, int minute) { JobPreconditions.checkArgumentInRange(hour, 0, 23, "hour"); JobPreconditions.checkArgumentInRange(minute, 0, 59, "minute"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); setTime(calendar.getTimeInMillis()); } }
mEndMs = JobPreconditions.checkArgumentInRange(endInMs, startInMs, Long.MAX_VALUE, "endInMs");
JobPreconditions.checkArgumentInRange(mIntervalMs, getMinInterval(), Long.MAX_VALUE, "intervalMs"); JobPreconditions.checkArgumentInRange(mFlexMs, getMinFlex(), mIntervalMs, "flexMs");
/** * Specify that this job should recur with the provided interval and flex, not more than once per period. * The flex controls how close to the end of a period the job can run. For example, specifying an interval * of 60 seconds and a flex of 15 seconds will allow the scheduler to determine the best moment between * the 45th and 60th second at which to execute your job. * * <br> * <br> * * As default a job isn't periodic. It isn't allowed to specify a time window for a periodic job. * Instead you set an interval with this function. Since {@link Job.Result#RESCHEDULE} is ignored for * periodic jobs, setting a back-off criteria is illegal as well. * * @param intervalMs The job should run at most once every {@code intervalMs}. The minimum value is {@code 15min}. * @param flexMs How close to the end of the period the job should run. The minimum value is {@code 5min}. * @see #MIN_INTERVAL * @see #MIN_FLEX */ public Builder setPeriodic(long intervalMs, long flexMs) { mIntervalMs = JobPreconditions.checkArgumentInRange(intervalMs, getMinInterval(), Long.MAX_VALUE, "intervalMs"); mFlexMs = JobPreconditions.checkArgumentInRange(flexMs, getMinFlex(), mIntervalMs, "flexMs"); return this; }
mEndMs = JobPreconditions.checkArgumentInRange(endInMs, startInMs, Long.MAX_VALUE, "endInMs");
JobPreconditions.checkArgumentInRange(mIntervalMs, getMinInterval(), Long.MAX_VALUE, "intervalMs"); JobPreconditions.checkArgumentInRange(mFlexMs, getMinFlex(), mIntervalMs, "flexMs");