use of net.osmand.plus.backup.ThreadPoolTaskExecutor in project Osmand by osmandapp.
the class BaseDeleteFilesCommand method deleteFiles.
protected void deleteFiles(@NonNull List<RemoteFile> remoteFiles) {
Map<String, String> commonParameters = new HashMap<>();
commonParameters.put("deviceid", getHelper().getDeviceId());
commonParameters.put("accessToken", getHelper().getAccessToken());
List<DeleteRemoteFileTask> tasks = new ArrayList<>();
for (RemoteFile remoteFile : remoteFiles) {
Map<String, String> parameters = new HashMap<>(commonParameters);
parameters.put("name", remoteFile.getName());
parameters.put("type", remoteFile.getType());
if (byVersion) {
parameters.put("updatetime", String.valueOf(remoteFile.getUpdatetimems()));
}
Request r = new Request(byVersion ? DELETE_FILE_VERSION_URL : DELETE_FILE_URL, parameters, null, false, true);
tasks.add(new DeleteRemoteFileTask(getApp(), r, remoteFile, byVersion));
}
ThreadPoolTaskExecutor<DeleteRemoteFileTask> executor = new ThreadPoolTaskExecutor<>(new OnThreadPoolTaskExecutorListener<DeleteRemoteFileTask>() {
@Override
public void onTaskStarted(@NonNull DeleteRemoteFileTask task) {
}
@Override
public void onTaskFinished(@NonNull DeleteRemoteFileTask task) {
publishProgress(task);
}
@Override
public void onTasksFinished(@NonNull List<DeleteRemoteFileTask> tasks) {
BaseDeleteFilesCommand.this.tasks = tasks;
}
});
executor.run(tasks);
}
Aggregations