本文整理汇总了Java中com.firebase.jobdispatcher.FirebaseJobDispatcher.mustSchedule方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseJobDispatcher.mustSchedule方法的具体用法?Java FirebaseJobDispatcher.mustSchedule怎么用?Java FirebaseJobDispatcher.mustSchedule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.firebase.jobdispatcher.FirebaseJobDispatcher
的用法示例。
在下文中一共展示了FirebaseJobDispatcher.mustSchedule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupCinemaListUpdates
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
private void setupCinemaListUpdates() {
long lastUpdated = getSharedPreferences("settings", MODE_PRIVATE).getLong("cinemasUpdated", -1);
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
if(lastUpdated < (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7))) {
// It's been more than a week since the last update, so setup/reset job because it should have run by now
Job updateJob = dispatcher.newJobBuilder()
.setService(CinemaUpdateJob.class)
.setTag("cinemasListUpdate")
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(0, (int) TimeUnit.DAYS.toSeconds(7)))
.setReplaceCurrent(true)
.build();
dispatcher.mustSchedule(updateJob);
}
// Also run immediately if the list has never been updated
if(lastUpdated == -1) {
dispatcher.mustSchedule(CinemaUpdateJob.getJobToUpdateImmediately(dispatcher));
}
}
示例2: syncImmediately
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
synchronized public static void syncImmediately(Context context, String tag) {
Timber.d("Scheduling a immediate sync");
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver
(context));
Bundle bundle = new Bundle();
Job myJob = dispatcher.newJobBuilder()
.setService(QuoteJobService.class)
.setTag(tag)
.setExtras(bundle)
.setRecurring(false)
.setTrigger(Trigger.executionWindow(0, 0))
.setLifetime(Lifetime.UNTIL_NEXT_BOOT)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.setReplaceCurrent(true)
.build();
dispatcher.mustSchedule(myJob);
}
示例3: onSetupComplete
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
@SuppressLint("ApplySharedPref")
private void onSetupComplete() {
//download whole leaderboards data asynchronously
new FetchLeaderBoardDataAsync(this).execute();
//schedule daily sync at 3:00 am local time
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
DateTime now = new DateTime();
DateTime tomorrow = now.plusDays(1).withTimeAtStartOfDay().plusHours(3);
int windowStart = Hours.hoursBetween(now, tomorrow).getHours() * 60 * 60;
Job synJob = dispatcher.newJobBuilder()
.setService(SyncScheduler.class)
.setTag(Constants.PERIODIC_SYNC_SCHEDULE_KEY)
.setReplaceCurrent(true)
.setTrigger(Trigger.executionWindow(windowStart, windowStart + 10))
.setConstraints(Constraint.ON_ANY_NETWORK)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.build();
dispatcher.mustSchedule(synJob);
sharedPreferences.edit().putBoolean(Constants.PREF_FIREBASE_SETUP, true).commit();
startActivity(new Intent(this, PreChecksActivity.class));
finish();
}
示例4: scheduleJob
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public static void scheduleJob(Context context, Message message) {
try {
Bundle bundle = new Bundle();
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
bundle.putString(MobiComKitConstants.AL_MESSAGE_KEY, message.getKeyString());
Class pushNotificationJobServiceClass = Class.forName("com.applozic.mobicomkit.uiwidgets.notification.PushNotificationJobService");
Job myJob = dispatcher.newJobBuilder()
.setService(pushNotificationJobServiceClass) // the JobService that will be called
.setTag(MobiComKitConstants.PUSH_NOTIFICATION_DISPATCHER) // uniquely identifies the job
.setRecurring(false)
.setTrigger(Trigger.executionWindow(0, 0))
.setReplaceCurrent(true)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setExtras(bundle)
.build();
dispatcher.mustSchedule(myJob);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: setup
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
private static void setup(@NonNull final Context context, final int timeInSeconds) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
Job myJob = dispatcher.newJobBuilder()
// the JobService that will be called
.setService(DailyReminderService.class)
// uniquely identifies the job
.setTag(DailyReminderService.TAG)
// one-off job
.setRecurring(false)
// persist past a device reboot (requires boot receiver permission)
.setLifetime(Lifetime.FOREVER)
// start between 0 and 60 seconds from now
.setTrigger(Trigger.executionWindow(timeInSeconds, timeInSeconds + 30))
// overwrite an existing job with the same tag
.setReplaceCurrent(true)
// retry with exponential backoff
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
//.setExtras(myExtrasBundle)
.build();
dispatcher.mustSchedule(myJob);
}
示例6: queuePostCore
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public void queuePostCore(@NonNull FirebaseJobDispatcher dispatcher, @NonNull PostRequest postRequest) {
Bundle extras = new Bundle(2);
extras.putString(GenericJobService.JOB_TYPE, GenericJobService.POST);
extras.putParcelable(GenericJobService.PAYLOAD, postRequest);
dispatcher.mustSchedule(dispatcher.newJobBuilder()
.setService(GenericJobService.class)
.setTag(GenericJobService.POST)
.setRecurring(false)
.setLifetime(Lifetime.UNTIL_NEXT_BOOT)
.setTrigger(Trigger.executionWindow(0, 60))
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.setConstraints(Constraint.ON_ANY_NETWORK, Constraint.DEVICE_CHARGING)
.setExtras(extras)
.build());
Log.d("FBJD", postRequest.getMethod() + " request is queued successfully!");
}
示例7: queueFileIOCore
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public void queueFileIOCore(@NonNull FirebaseJobDispatcher dispatcher, boolean isDownload,
@NonNull FileIORequest fileIORequest) {
Bundle extras = new Bundle(2);
extras.putString(GenericJobService.JOB_TYPE, isDownload ?
GenericJobService.DOWNLOAD_FILE : GenericJobService.UPLOAD_FILE);
extras.putParcelable(GenericJobService.PAYLOAD, fileIORequest);
dispatcher.mustSchedule(dispatcher.newJobBuilder()
.setService(GenericJobService.class)
.setTag(isDownload ? GenericJobService.DOWNLOAD_FILE : GenericJobService.UPLOAD_FILE)
.setRecurring(false)
.setLifetime(Lifetime.FOREVER)
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.setConstraints(fileIORequest.onWifi() ? Constraint.ON_UNMETERED_NETWORK : Constraint.ON_ANY_NETWORK,
fileIORequest.isWhileCharging() ? Constraint.DEVICE_CHARGING : 0)
.setExtras(extras)
.build());
Log.d("FBJD", String.format("%s file request is queued successfully!", isDownload ?
"Download" : "Upload"));
}
示例8: schedulePeriodic
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public static void schedulePeriodic(Context context, String tag, int period) {
Timber.d("Scheduling a periodic sync every " + period + " seconds");
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
Job myJob = dispatcher.newJobBuilder()
.setService(QuoteJobService.class)
.setTag(tag)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(period, period))
.setLifetime(Lifetime.UNTIL_NEXT_BOOT)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.setReplaceCurrent(true)
.build();
dispatcher.mustSchedule(myJob);
}
示例9: startSignInSocial
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public static void startSignInSocial(Context context, Bundle bundle){
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
Job myJob = dispatcher.newJobBuilder()
// the JobService that will be called
.setService(SessionJobService.class)
// uniquely identifies the job
.setTag(SIGN_IN_SOCIAL_ACTION)
// one-off job
.setRecurring(false)
// start between 0 and 60 seconds from now
.setTrigger(Trigger.executionWindow(0, 60))
// don't overwrite an existing job with the same tag
.setReplaceCurrent(false)
// constraints that need to be satisfied for the job to run
.setConstraints(
// only run on an unmetered network
Constraint.ON_UNMETERED_NETWORK
)
.setExtras(bundle)
.build();
dispatcher.mustSchedule(myJob);
}
示例10: onStartJob
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
@Override
public boolean onStartJob(JobParameters job) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
/* Schedule the job once now*/
Job oneTimeJob = dispatcher.newJobBuilder()
.setService(WakatimeDataSyncJob.class)
.setTag("OneTimeJob")
.setTrigger(Trigger.executionWindow(0, 60))
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.build();
dispatcher.mustSchedule(oneTimeJob);
/* Schedule a recurring job everyday */
Job synJob = dispatcher.newJobBuilder()
.setService(WakatimeDataSyncJob.class)
.setTag(Constants.WAKATIME_DATA_SYNC_JOB_TAG)
.setReplaceCurrent(true)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(Constants.SYNC_PERIOD, Constants.SYNC_TOLERANCE))
.setConstraints(Constraint.ON_ANY_NETWORK)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.build();
dispatcher.mustSchedule(synJob);
return false;
}
示例11: scheduleJob
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
static void scheduleJob(Context context, String tag) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
dispatcher.cancel(tag);
Job myJob = dispatcher.newJobBuilder()
.setService(SyncJobService.class) // the JobService that will be called
.setTag(tag) // uniquely identifies the job
.setRecurring(false)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.NOW)
.setConstraints(Constraint.ON_ANY_NETWORK)
.build();
dispatcher.mustSchedule(myJob);
}
示例12: startNotificationService
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
private void startNotificationService() {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job job = dispatcher.newJobBuilder()
.setService(NotificationService.class)
.setTag("notification-polling-job")
.setRecurring(true)
.setReplaceCurrent(true)
.setTrigger(Trigger.executionWindow(3540, 3600)) //trigger every 59 - 60 minutes
.build();
dispatcher.mustSchedule(job);
}
示例13: onCreate
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
daysTextView = (TextView) findViewById(R.id.daysTextView);
dateTextView = (TextView) findViewById(R.id.dateTextView);
dateCalculations = new DateCalculations();
dispatcher = new FirebaseJobDispatcher( new GooglePlayDriver(MainActivity.this));
dispatcher.mustSchedule(
dispatcher.newJobBuilder()
.setService(UpdateDaysJobService.class)
.setTag("HELLO")
.build()
);
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
if (sharedPref.contains(getString(R.string.dayOfMonth))) {
displayDays(getCurrentFocus());
}
}
示例14: onReceive
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.inform("App updated and sync service started");
// restart SyncServices
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
Job myJob = dispatcher.newJobBuilder()
.setService(SyncJobs.class)
.setReplaceCurrent(true)
.setTrigger(Trigger.executionWindow(0, 1))
.setTag(SyncJobs.RESET_ALL_JOBS)
.build();
dispatcher.mustSchedule(myJob);
new AppPrefs(context).activateSpecialNotice();
}
示例15: startService
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public static void startService (Context context)
{
FirebaseJobDispatcher dispatcher =
new FirebaseJobDispatcher( new GooglePlayDriver( context ) );
Job myJob = dispatcher.newJobBuilder( )
// the JobService that will be called
.setService( SyncService.class )
// uniquely identifies the job
.setTag( "sync-service-tag" )
// one-off job
.setRecurring( false )
// persist past a device reboot
.setLifetime( Lifetime.FOREVER )
// don't overwrite an existing job with the same tag
.setReplaceCurrent( true )
// retry with exponential backoff
.setRetryStrategy( RetryStrategy.DEFAULT_EXPONENTIAL )
// constraints that need to be satisfied for the job to run
.setConstraints(
Constraint.ON_ANY_NETWORK
)
//start job immediately
.setTrigger( Trigger.executionWindow( 0, 0 ) )
.build( );
dispatcher.mustSchedule( myJob );
}