Imported JobManager as a source dependency.

We have to make some changes, and it's gotten to the point where
maintaining it as a separate library is more hassle than it's worth,
especially with Google releasing WorkManager as the preferred job
scheduling library.
This commit is contained in:
Greyson Parrelli
2018-06-18 12:27:04 -07:00
parent 5f99470226
commit 42f1baaf61
75 changed files with 2165 additions and 120 deletions

View File

@@ -0,0 +1,36 @@
package org.thoughtcrime.securesms.jobmanager.dependencies;
import android.content.Context;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.requirements.Requirement;
public class AggregateDependencyInjector {
private final DependencyInjector dependencyInjector;
public AggregateDependencyInjector(DependencyInjector dependencyInjector) {
this.dependencyInjector = dependencyInjector;
}
public void injectDependencies(Context context, Job job) {
if (job instanceof ContextDependent) {
((ContextDependent)job).setContext(context);
}
for (Requirement requirement : job.getRequirements()) {
if (requirement instanceof ContextDependent) {
((ContextDependent)requirement).setContext(context);
}
}
if (dependencyInjector != null) {
dependencyInjector.injectDependencies(job);
for (Requirement requirement : job.getRequirements()) {
dependencyInjector.injectDependencies(requirement);
}
}
}
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.jobmanager.dependencies;
import android.content.Context;
/**
* Any Job or Requirement that depends on {@link android.content.Context} can implement this
* interface to receive a Context after being deserialized.
*/
public interface ContextDependent {
public void setContext(Context context);
}

View File

@@ -0,0 +1,24 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.jobmanager.dependencies;
/**
* Interface responsible for injecting dependencies into Jobs.
*/
public interface DependencyInjector {
public void injectDependencies(Object object);
}