Use a Thread instead of an AsyncTask to delete downloads

This commit is contained in:
Gabriele M
2017-07-04 19:05:04 +02:00
parent 4dcf4199f1
commit c13d79b39c

View File

@@ -17,7 +17,6 @@ package org.lineageos.updater.controller;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.PowerManager;
import android.os.SystemClock;
import android.support.v4.content.LocalBroadcastManager;
@@ -305,17 +304,17 @@ public class UpdaterController implements UpdaterControllerInt {
}
private void deleteUpdateAsync(final String downloadId) {
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... voids) {
new Thread(new Runnable() {
@Override
public void run() {
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
File file = update.getFile();
if (file.exists() && !file.delete()) {
Log.e(TAG, "Could not delete " + file.getAbsolutePath());
}
mUpdatesDbHelper.removeUpdate(downloadId);
return null;
}
}.execute();
}).start();
}
@Override