Search in sources :

Example 1 with Job

use of com.firebase.jobdispatcher.Job in project Applozic-Android-SDK by AppLozic.

the class PushNotificationDispatcher method scheduleJob.

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(// the JobService that will be called
        pushNotificationJobServiceClass).setTag(// uniquely identifies the job
        MobiComKitConstants.PUSH_NOTIFICATION_DISPATCHER).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();
    }
}
Also used : FirebaseJobDispatcher(com.firebase.jobdispatcher.FirebaseJobDispatcher) Bundle(android.os.Bundle) GooglePlayDriver(com.firebase.jobdispatcher.GooglePlayDriver) Job(com.firebase.jobdispatcher.Job)

Example 2 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class BackupJobsTest method shouldScheduleContentUriTriggerForCallLogIfEnabled.

@Test
public void shouldScheduleContentUriTriggerForCallLogIfEnabled() throws Exception {
    when(preferences.isCallLogBackupAfterCallEnabled()).thenReturn(true);
    when(dataTypePreferences.isBackupEnabled(CALLLOG)).thenReturn(true);
    Job job = subject.scheduleContentTriggerJob();
    assertThat(job.getTrigger()).isInstanceOf(JobTrigger.ContentUriTrigger.class);
    JobTrigger.ContentUriTrigger contentUriTrigger = (JobTrigger.ContentUriTrigger) job.getTrigger();
    assertThat(contentUriTrigger.getUris()).containsExactly(new ObservedUri(SMS_PROVIDER, FLAG_NOTIFY_FOR_DESCENDANTS), new ObservedUri(CALLLOG_PROVIDER, FLAG_NOTIFY_FOR_DESCENDANTS));
}
Also used : ObservedUri(com.firebase.jobdispatcher.ObservedUri) Job(com.firebase.jobdispatcher.Job) JobTrigger(com.firebase.jobdispatcher.JobTrigger) Test(org.junit.Test)

Example 3 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class BackupJobsTest method shouldCancelAllJobsAfterBootIfAutoBackupDisabled.

@Test
public void shouldCancelAllJobsAfterBootIfAutoBackupDisabled() throws Exception {
    when(preferences.isAutoBackupEnabled()).thenReturn(false);
    Job job = subject.scheduleBootup();
    assertThat(job).isNull();
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Example 4 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class BackupJobsTest method shouldScheduleImmediate.

@Test
public void shouldScheduleImmediate() throws Exception {
    Job job = subject.scheduleImmediate();
    verifyJobScheduled(job, -1, "BROADCAST_INTENT");
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Example 5 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class BackupJobsTest method shouldScheduleNothingAfterBootForNewScheduler.

@Test
public void shouldScheduleNothingAfterBootForNewScheduler() throws Exception {
    when(preferences.isAutoBackupEnabled()).thenReturn(true);
    when(preferences.isUseOldScheduler()).thenReturn(false);
    Job job = subject.scheduleBootup();
    assertThat(job).isNull();
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Aggregations

Job (com.firebase.jobdispatcher.Job)20 Test (org.junit.Test)12 FirebaseJobDispatcher (com.firebase.jobdispatcher.FirebaseJobDispatcher)7 GooglePlayDriver (com.firebase.jobdispatcher.GooglePlayDriver)7 Bundle (android.os.Bundle)3 JobTrigger (com.firebase.jobdispatcher.JobTrigger)3 ObservedUri (com.firebase.jobdispatcher.ObservedUri)3 SharedPreferences (android.content.SharedPreferences)2 View (android.view.View)2 TextView (android.widget.TextView)2 AdView (com.google.android.gms.ads.AdView)2 CurrencyEnum (it.angelic.mpw.model.enums.CurrencyEnum)2 PoolEnum (it.angelic.mpw.model.enums.PoolEnum)2 Intent (android.content.Intent)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 NavigationView (android.support.design.widget.NavigationView)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 EditTextPreference (android.support.v7.preference.EditTextPreference)1 ListPreference (android.support.v7.preference.ListPreference)1