From 29788254ddde594ab96ba23d35dbc11053aacf96 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 29 Mar 2016 20:40:42 +0200 Subject: [PATCH] use background thread for swap icons instead of AsyncTask An AsyncTask ties into the UI thread for things like onPostExecute(). If it is run within an AsyncTask, then it freaks out because it can't tie into the UI thread. We don't need it to do that here anyway, so just use a plain Thread, and set the priority to background. --- .../fdroid/views/swap/SwapWorkflowActivity.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java b/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java index a3b521f21..711226362 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java @@ -702,16 +702,13 @@ public class SwapWorkflowActivity extends AppCompatActivity { lrm.copyApksToRepo(); broadcast(TYPE_STATUS, getString(R.string.copying_icons)); // run the icon copy without progress, its not a blocker - // TODO: Fix lint error about this being run from a worker thread, says it should be - // run on a main thread. - new AsyncTask() { - + new Thread() { @Override - protected Void doInBackground(Void... params) { + public void run() { + android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); lrm.copyIconsToRepo(); - return null; } - }.execute(); + }.start(); broadcast(TYPE_COMPLETE); } catch (Exception e) {