|
|
|
@ -15,8 +15,8 @@ import javax.mail.event.StoreListener;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.work.Data;
|
|
|
|
|
import androidx.work.ExistingWorkPolicy;
|
|
|
|
|
import androidx.work.OneTimeWorkRequest;
|
|
|
|
|
import androidx.work.WorkInfo;
|
|
|
|
|
import androidx.work.WorkManager;
|
|
|
|
|
import androidx.work.Worker;
|
|
|
|
|
import androidx.work.WorkerParameters;
|
|
|
|
@ -121,23 +121,13 @@ public class WorkerOperations extends Worker {
|
|
|
|
|
String tag = WorkerOperations.class.getSimpleName() + ":" + fid;
|
|
|
|
|
Log.i("Queuing " + tag);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
for (WorkInfo info : WorkManager.getInstance().getWorkInfosByTag(tag).get())
|
|
|
|
|
if (!info.getState().isFinished()) {
|
|
|
|
|
Log.i("Already queued " + tag);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Data data = new Data.Builder().putLong("folder", fid).build();
|
|
|
|
|
OneTimeWorkRequest workRequest =
|
|
|
|
|
new OneTimeWorkRequest.Builder(WorkerOperations.class)
|
|
|
|
|
.addTag(tag)
|
|
|
|
|
.setInputData(data)
|
|
|
|
|
.build();
|
|
|
|
|
WorkManager.getInstance().enqueue(workRequest);
|
|
|
|
|
WorkManager.getInstance().enqueueUniqueWork(tag, ExistingWorkPolicy.KEEP, workRequest);
|
|
|
|
|
|
|
|
|
|
Log.i("Queued " + tag);
|
|
|
|
|
}
|
|
|
|
|