mirror of https://github.com/M66B/FairEmail.git
Added worker constraints
This commit is contained in:
parent
cd1e265271
commit
ad5812f4f8
|
@ -12,7 +12,9 @@ import javax.mail.Session;
|
||||||
import javax.mail.Store;
|
import javax.mail.Store;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.work.Constraints;
|
||||||
import androidx.work.Data;
|
import androidx.work.Data;
|
||||||
|
import androidx.work.NetworkType;
|
||||||
import androidx.work.OneTimeWorkRequest;
|
import androidx.work.OneTimeWorkRequest;
|
||||||
import androidx.work.WorkInfo;
|
import androidx.work.WorkInfo;
|
||||||
import androidx.work.WorkManager;
|
import androidx.work.WorkManager;
|
||||||
|
@ -98,10 +100,14 @@ public class WorkerFolderSync extends Worker {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Constraints.Builder constraints = new Constraints.Builder();
|
||||||
|
constraints.setRequiredNetworkType(NetworkType.CONNECTED);
|
||||||
|
|
||||||
Data data = new Data.Builder().putLong("account", aid).build();
|
Data data = new Data.Builder().putLong("account", aid).build();
|
||||||
OneTimeWorkRequest workRequest =
|
OneTimeWorkRequest workRequest =
|
||||||
new OneTimeWorkRequest.Builder(WorkerFolderSync.class)
|
new OneTimeWorkRequest.Builder(WorkerFolderSync.class)
|
||||||
.addTag(tag)
|
.addTag(tag)
|
||||||
|
.setConstraints(constraints.build())
|
||||||
.setInputData(data)
|
.setInputData(data)
|
||||||
.build();
|
.build();
|
||||||
WorkManager.getInstance().enqueue(workRequest);
|
WorkManager.getInstance().enqueue(workRequest);
|
||||||
|
|
|
@ -15,7 +15,9 @@ import javax.mail.event.StoreEvent;
|
||||||
import javax.mail.event.StoreListener;
|
import javax.mail.event.StoreListener;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.work.Constraints;
|
||||||
import androidx.work.Data;
|
import androidx.work.Data;
|
||||||
|
import androidx.work.NetworkType;
|
||||||
import androidx.work.OneTimeWorkRequest;
|
import androidx.work.OneTimeWorkRequest;
|
||||||
import androidx.work.WorkInfo;
|
import androidx.work.WorkInfo;
|
||||||
import androidx.work.WorkManager;
|
import androidx.work.WorkManager;
|
||||||
|
@ -132,10 +134,14 @@ public class WorkerOperations extends Worker {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Constraints.Builder constraints = new Constraints.Builder();
|
||||||
|
constraints.setRequiredNetworkType(NetworkType.CONNECTED);
|
||||||
|
|
||||||
Data data = new Data.Builder().putLong("folder", fid).build();
|
Data data = new Data.Builder().putLong("folder", fid).build();
|
||||||
OneTimeWorkRequest workRequest =
|
OneTimeWorkRequest workRequest =
|
||||||
new OneTimeWorkRequest.Builder(WorkerOperations.class)
|
new OneTimeWorkRequest.Builder(WorkerOperations.class)
|
||||||
.addTag(tag)
|
.addTag(tag)
|
||||||
|
.setConstraints(constraints.build())
|
||||||
.setInputData(data)
|
.setInputData(data)
|
||||||
.build();
|
.build();
|
||||||
WorkManager.getInstance().enqueue(workRequest);
|
WorkManager.getInstance().enqueue(workRequest);
|
||||||
|
|
Loading…
Reference in New Issue