fedilab-Android-App/app/src/main/java/fr/gouv/etalab/mastodon/jobs/ApplicationJob.java

51 lines
1.7 KiB
Java
Raw Normal View History

2017-05-05 16:36:04 +02:00
package fr.gouv.etalab.mastodon.jobs;
/* Copyright 2017 Thomas Schneider
*
2017-07-10 10:33:24 +02:00
* This file is a part of Mastalab
2017-05-05 16:36:04 +02:00
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
2017-07-10 10:33:24 +02:00
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
2017-05-05 16:36:04 +02:00
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
2017-08-04 11:11:27 +02:00
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
2017-05-05 16:36:04 +02:00
* see <http://www.gnu.org/licenses>. */
2017-12-17 14:20:04 +01:00
import android.support.annotation.NonNull;
2017-05-05 16:36:04 +02:00
import com.evernote.android.job.Job;
import com.evernote.android.job.JobCreator;
import com.evernote.android.job.JobManager;
/**
* Created by Thomas on 29/04/2017.
* Notification job
*/
public class ApplicationJob implements JobCreator {
@Override
2017-12-17 14:20:04 +01:00
public Job create(@NonNull String tag) {
2017-05-05 16:36:04 +02:00
switch (tag) {
2017-08-29 16:22:57 +02:00
case NotificationsSyncJob.NOTIFICATION_REFRESH:
return new NotificationsSyncJob();
case HomeTimelineSyncJob.HOME_TIMELINE:
return new HomeTimelineSyncJob();
2017-07-16 17:09:35 +02:00
case ScheduledTootsSyncJob.SCHEDULED_TOOT:
return new ScheduledTootsSyncJob();
2017-05-05 16:36:04 +02:00
default:
return null;
}
}
2017-08-26 11:04:48 +02:00
@SuppressWarnings("unused")
2017-05-05 16:36:04 +02:00
public static void cancelAllJob(String TAG){
JobManager.instance().cancelAllForTag(TAG);
}
2017-07-16 17:09:35 +02:00
2017-07-17 18:53:12 +02:00
public static void cancelJob(int jobId) {
2017-07-16 17:09:35 +02:00
JobManager.instance().cancel(jobId);
}
2017-05-05 16:36:04 +02:00
}