use AsyncTask for SwapType operations to run in background
Thread runs at normal priority by default. AsyncTasks are integrated into Android for handling things running in the background while keeping the UI responsive. This reverts most of commit 828cc272ee5235f868104b009349cc7e835e144f.
This commit is contained in:
parent
96fe1f9584
commit
26b35723d3
@ -2,6 +2,7 @@ package org.fdroid.fdroid.localrepo.type;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
@ -70,12 +71,13 @@ public abstract class SwapType {
|
||||
}
|
||||
|
||||
public void startInBackground() {
|
||||
new Thread() {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
public void run() {
|
||||
SwapType.this.start();
|
||||
protected Void doInBackground(Void... params) {
|
||||
start();
|
||||
return null;
|
||||
}
|
||||
}.start();
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void ensureRunning() {
|
||||
@ -85,21 +87,23 @@ public abstract class SwapType {
|
||||
}
|
||||
|
||||
public void ensureRunningInBackground() {
|
||||
new Thread() {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
public void run() {
|
||||
protected Void doInBackground(Void... params) {
|
||||
ensureRunning();
|
||||
return null;
|
||||
}
|
||||
}.start();
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void stopInBackground() {
|
||||
new Thread() {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
public void run() {
|
||||
SwapType.this.stop();
|
||||
protected Void doInBackground(Void... params) {
|
||||
stop();
|
||||
return null;
|
||||
}
|
||||
}.start();
|
||||
}.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user