当前位置: 首页>>代码示例>>Java>>正文


Java Job类代码示例

本文整理汇总了Java中com.firebase.jobdispatcher.Job的典型用法代码示例。如果您正苦于以下问题:Java Job类的具体用法?Java Job怎么用?Java Job使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Job类属于com.firebase.jobdispatcher包,在下文中一共展示了Job类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupCinemaListUpdates

import com.firebase.jobdispatcher.Job; //导入依赖的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));
    }
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:23,代码来源:MovieNotifierApp.java

示例2: scheduleJob

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
private static boolean scheduleJob(Context context) {
    FirebaseJobDispatcher dispatcher = getDispatcher(context);
    Job job = dispatcher.newJobBuilder()
            .setService(UploadService.class)
            .setTag(context.getPackageName() + ".uploadqueue")
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .setTrigger(Trigger.NOW)
            .setLifetime(Lifetime.FOREVER)
            .setRecurring(false)
            .setReplaceCurrent(true)
            .build();
    int result = dispatcher.schedule(job);
    if (result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) {
        Logger.v("Job scheduled");
        return true;
    } else {
        Logger.v("Job not scheduled");
        return false;
    }
}
 
开发者ID:Nuvoex,项目名称:async-file-uploader,代码行数:21,代码来源:UploadQueue.java

示例3: syncImmediately

import com.firebase.jobdispatcher.Job; //导入依赖的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);

}
 
开发者ID:henriquenfaria,项目名称:stock-hawk,代码行数:23,代码来源:QuoteSyncJob.java

示例4: notifyOnComplete

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
public void notifyOnComplete(Dictionary data) {
	Utils.d("Setting new Job with message: " + data.toString());

	Bundle bundle = new Bundle();
	bundle.putString("message", (String) data.get("message"));
	bundle.putString("image_url", (String) data.get("image"));
	bundle.putString("title", (String) data.get("title"));
	bundle.putString("type", "image");

	int seconds = (int) data.get("secs");

	Job myJob = dispatcher.newJobBuilder()
	.setService(NotifyInTime.class)	// the JobService that will be called
	.setTrigger(Trigger.executionWindow(seconds, seconds+60))
	.setTag("firebase-notify-in-time-UID") // uniquely identifies the job
	.setReplaceCurrent(true)
	.setExtras(bundle)
	.build();

	dispatcher.mustSchedule(myJob);
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:22,代码来源:Notification.java

示例5: notifyInSecs

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
public void notifyInSecs(final String message, final int seconds) {
	Utils.d("Setting new Job with message: " + message);

	Bundle bundle = new Bundle();
	bundle.putString("message", message);
	bundle.putString("title", "FB Title");
	bundle.putString("type", "text");

	Job myJob = dispatcher.newJobBuilder()
	.setService(NotifyInTime.class)	// the JobService that will be called
	.setTrigger(Trigger.executionWindow(seconds, seconds+60))
	.setTag("firebase-notify-in-time-UID") // uniquely identifies the job
	.setReplaceCurrent(true)
	.setExtras(bundle)
	.build();

	dispatcher.mustSchedule(myJob);
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:19,代码来源:Notification.java

示例6: onSetupComplete

import com.firebase.jobdispatcher.Job; //导入依赖的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();
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:26,代码来源:OnBoardActivity.java

示例7: scheduleFirebaseJobDispatcherSync

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
static void scheduleFirebaseJobDispatcherSync(@NonNull final Context context) {

        Driver driver = new GooglePlayDriver(context);
        FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

        /* Create the Job to periodically sync Sunshine */
        Job syncSunshineJob = dispatcher.newJobBuilder()
                .setService(NewsFirebaseJobService.class)
                .setTag(NEWS_SYNC_TAG)
                .setConstraints(Constraint.ON_ANY_NETWORK)
                .setLifetime(Lifetime.FOREVER)
                .setRecurring(true)
                .setTrigger(Trigger.executionWindow(
                        REMINDER_INTERVAL_SECONDS,
                        REMINDER_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
                .setReplaceCurrent(true)
                .build();

        dispatcher.schedule(syncSunshineJob);
    }
 
开发者ID:vikasdesale,项目名称:News24x7-news-from-every-part-of-the-world,代码行数:21,代码来源:NewsSyncUtils.java

示例8: schedule

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
@Override
public int schedule(@NonNull Job job) {
  Log.i("TrackingBackend", "beginning schedule loop");

  synchronized (mStore) {
    final Iterator<JobHistory> it = mStore.iterator();
    while (it.hasNext()) {
      JobParameters j = it.next().job;

      if (j.getTag().equals(job.getTag()) && j.getService().equals(job.getService())) {
        it.remove();
      }
    }

    mStore.add(new JobHistory(job));
  }

  Log.i("TrackingBackend", "ending schedule loop");

  return mDriver.schedule(job);
}
 
开发者ID:firebase,项目名称:firebase-jobdispatcher-android,代码行数:22,代码来源:CentralContainer.java

示例9: scheduleJob

import com.firebase.jobdispatcher.Job; //导入依赖的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();
        }
    }
 
开发者ID:AppLozic,项目名称:Applozic-Android-Chat-Sample,代码行数:23,代码来源:PushNotificationDispatcher.java

示例10: startRest

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
void startRest(final Context context) {

        new ResetRoutes(new OnFinish() {
            @Override
            public void finished() {
                resetDone.postValue(true);
                FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
                Job myJob = dispatcher.newJobBuilder()
                        .setService(SyncJobs.class)
                        .setReplaceCurrent(true)
                        .setTrigger(Trigger.executionWindow(0, 1))
                        .setTag(SyncJobs.SINGLE_ROUTE_SYNC)
                        .build();
                dispatcher.mustSchedule(myJob);
            }

            @Override
            public void allRoutes(List<RouteData> routeDataList) {

            }
        }).execute(context);

    }
 
开发者ID:NCBSinfo,项目名称:NCBSinfo,代码行数:24,代码来源:SettingsViewModel.java

示例11: setup

import com.firebase.jobdispatcher.Job; //导入依赖的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);
}
 
开发者ID:canyapan,项目名称:DietDiaryApp,代码行数:24,代码来源:DailyReminderServiceHelper.java

示例12: schedulePeriodic

import com.firebase.jobdispatcher.Job; //导入依赖的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);
}
 
开发者ID:henriquenfaria,项目名称:stock-hawk,代码行数:19,代码来源:QuoteSyncJob.java

示例13: startSignInSocial

import com.firebase.jobdispatcher.Job; //导入依赖的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);
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:25,代码来源:SessionJobService.java

示例14: onStartJob

import com.firebase.jobdispatcher.Job; //导入依赖的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;
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:28,代码来源:SyncScheduler.java

示例15: scheduleUpdateProgressReminder

import com.firebase.jobdispatcher.Job; //导入依赖的package包/类
synchronized public static void scheduleUpdateProgressReminder(@NonNull final Context context) {
    if (sInitialized) {
        return;
    }
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.add(Calendar.MINUTE, 3);
    //could have done add(Calender.Date,1). I have trust issues
    Intent intentAlarm = new Intent(context, UpdateDayAlarmReciever.class);
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, PendingIntent.getBroadcast(context, 1, intentAlarm, PendingIntent.FLAG_CANCEL_CURRENT));

    Driver driver = new GooglePlayDriver(context);
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

    Job constraintReminderJob = dispatcher.newJobBuilder()
            .setService(UpdateProgressFirebaseJobService.class)
            .setTag(UPDATE_PROGRESS_JOB_TAG)
            .setLifetime(Lifetime.FOREVER)
            .setRecurring(true)
            .setTrigger(Trigger.executionWindow(
                    0,
                    UPDATE_INTERVAL_SECONDS))
            .setReplaceCurrent(true)
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .build();
    /* Schedule the Job with the dispatcher */
    dispatcher.schedule(constraintReminderJob);
    /* The job has been initialized */
    sInitialized = true;
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:35,代码来源:UpdateProgressUtilities.java


注:本文中的com.firebase.jobdispatcher.Job类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。