Add doWork method to jobintentservice

pull/699/head
Alex Baker 6 years ago
parent 0f41b26600
commit e37e7e4099

@ -22,9 +22,7 @@ public class GeofenceTransitionsIntentService extends InjectingJobIntentService
@Inject Notifier notifier;
@Override
protected void onHandleWork(Intent intent) {
super.onHandleWork(intent);
protected void doWork(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent.hasError()) {
Timber.e("geofence error code %s", geofencingEvent.getErrorCode());

@ -38,6 +38,8 @@ public class Tasks extends InjectingApplication {
AndroidThreeTen.init(this);
jobManager.addJobCreator(jobCreator);
flavorSetup.setup();
badger.setEnabled(preferences.getBoolean(R.string.p_badges_enabled, true));
@ -46,10 +48,11 @@ public class Tasks extends InjectingApplication {
startupService.onStartupApplication();
jobManager.addJobCreator(jobCreator);
gtasksPreferenceService.stopOngoing(); // if sync ongoing flag was set, clear it
jobManager.updateBackgroundSync();
jobManager.scheduleMidnightRefresh();
jobManager.scheduleBackup();
}
@Override

@ -3,14 +3,24 @@ package org.tasks.injection;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.JobIntentService;
import javax.annotation.Nonnull;
import timber.log.Timber;
public abstract class InjectingJobIntentService extends JobIntentService {
@Override
protected void onHandleWork(@NonNull Intent intent) {
protected final void onHandleWork(@NonNull Intent intent) {
inject(
((InjectingApplication) getApplication()).getComponent().plus(new IntentServiceModule()));
try {
doWork(intent);
} catch (Exception e) {
Timber.e(e, e.getMessage());
}
}
protected abstract void doWork(@Nonnull Intent intent);
protected abstract void inject(IntentServiceComponent component);
}

@ -49,9 +49,7 @@ public class AfterSaveIntentService extends InjectingJobIntentService {
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
super.onHandleWork(intent);
protected void doWork(@NonNull Intent intent) {
Task task = intent.getParcelableExtra(EXTRA_CURRENT);
if (task == null) {
Timber.e("Missing saved task");

@ -115,11 +115,6 @@ public class JobManager {
jobManager.cancelAllForTag(JobCreator.TAG_NOTIFICATION);
}
public void cancelRefresh() {
Timber.d("cancelRefresh");
jobManager.cancelAllForTag(JobCreator.TAG_REFRESH);
}
private long calculateDelay(long time) {
return Math.max(5000, time - currentTimeMillis());
}

@ -26,9 +26,7 @@ public class TaskerIntentService extends InjectingJobIntentService {
@Inject Tracker tracker;
@Override
protected void onHandleWork(@NonNull Intent intent) {
super.onHandleWork(intent);
protected void doWork(@NonNull Intent intent) {
final Bundle bundle = intent.getBundleExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
if (null == bundle) {

@ -25,19 +25,13 @@ public class BackgroundScheduler extends InjectingJobIntentService {
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
super.onHandleWork(intent);
protected void doWork(@NonNull Intent intent) {
Timber.d("onHandleWork(%s)", intent);
NotificationSchedulerIntentService.enqueueWork(context, false);
CalendarNotificationIntentService.enqueueWork(context);
GeofenceSchedulingIntentService.enqueueWork(context);
jobManager.scheduleBackup();
jobManager.scheduleMidnightRefresh();
refreshScheduler.clear();
for (Task task : taskDao.needsRefresh()) {
refreshScheduler.scheduleRefresh(task);
}

@ -23,9 +23,7 @@ public class GeofenceSchedulingIntentService extends InjectingJobIntentService {
}
@Override
protected void onHandleWork(Intent intent) {
super.onHandleWork(intent);
protected void doWork(Intent intent) {
Timber.d("onHandleWork(%s)", intent);
geofenceService.cancelGeofences();

@ -33,9 +33,7 @@ public class NotificationSchedulerIntentService extends InjectingJobIntentServic
}
@Override
protected void onHandleWork(Intent intent) {
super.onHandleWork(intent);
protected void doWork(Intent intent) {
Timber.d("onHandleWork(%s)", intent);
notificationQueue.clear();

@ -20,9 +20,7 @@ public abstract class RecurringIntervalIntentService extends InjectingJobIntentS
@Inject AlarmManager alarmManager;
@Override
protected void onHandleWork(Intent intent) {
super.onHandleWork(intent);
protected void doWork(Intent intent) {
long interval = intervalMillis();
if (interval <= 0) {

@ -22,11 +22,6 @@ public class RefreshScheduler {
this.jobManager = jobManager;
}
public void clear() {
jobs.clear();
jobManager.cancelRefresh();
}
public void scheduleRefresh(Task task) {
if (task.isCompleted()) {
scheduleRefresh(task.getCompletionDate() + ONE_MINUTE);

Loading…
Cancel
Save