mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Ensure jobs have a Context during onAdded().
Fixes a crash.
This commit is contained in:
parent
0dd7b39bb1
commit
ae9c53bdf8
@ -171,7 +171,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
.setMinimumLoggingLevel(android.util.Log.DEBUG)
|
||||
.build());
|
||||
|
||||
this.jobManager = new JobManager(WorkManager.getInstance());
|
||||
this.jobManager = new JobManager(this, WorkManager.getInstance());
|
||||
}
|
||||
|
||||
public void initializeMessageRetrieval() {
|
||||
|
@ -107,8 +107,13 @@ public abstract class Job extends Worker implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
final void onSubmit(UUID id) {
|
||||
final void onSubmit(@NonNull Context context, @NonNull UUID id) {
|
||||
Log.i(TAG, buildLog(id, "onSubmit()"));
|
||||
|
||||
if (this instanceof ContextDependent) {
|
||||
((ContextDependent) this).setContext(context);
|
||||
}
|
||||
|
||||
onAdded();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.jobmanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
@ -22,10 +23,12 @@ public class JobManager {
|
||||
|
||||
private final Executor executor = Executors.newSingleThreadExecutor();
|
||||
|
||||
private final Context context;
|
||||
private final WorkManager workManager;
|
||||
|
||||
public JobManager(@NonNull WorkManager workManager) {
|
||||
this.workManager = workManager;
|
||||
public JobManager(@NonNull Context context, @NonNull WorkManager workManager) {
|
||||
this.context = context;
|
||||
this.workManager = workManager;
|
||||
}
|
||||
|
||||
public void add(Job job) {
|
||||
@ -56,7 +59,7 @@ public class JobManager {
|
||||
|
||||
OneTimeWorkRequest request = requestBuilder.build();
|
||||
|
||||
job.onSubmit(request.getId());
|
||||
job.onSubmit(context, request.getId());
|
||||
|
||||
String groupId = jobParameters.getGroupId();
|
||||
if (groupId != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user