Merge branch 'use-android-executor' into 'master'

Use Android executor for background API calls

Some Android API calls need to be made from a thread with a message queue, but to keep the UI responsive they shouldn't be made from the UI thread.

This patch gives AndroidExecutor a captive thread with a message queue to execute tasks, and converts various background tasks from creating their own threads to using AndroidExecutor and IoExecutor.

This allows us to upgrade the support library to 23.2.1. Fixes #332.

See merge request !161
This commit is contained in:
akwizgran
2016-05-03 14:34:49 +00:00
13 changed files with 133 additions and 87 deletions

View File

@@ -9,6 +9,7 @@ import android.os.StrictMode.VmPolicy;
import android.support.v7.preference.PreferenceManager;
import org.briarproject.R;
import org.briarproject.android.api.AndroidExecutor;
import org.briarproject.android.util.AndroidUtils;
import org.briarproject.api.db.DatabaseConfig;
@@ -29,6 +30,8 @@ public class SplashScreenActivity extends BaseActivity {
@Inject
protected DatabaseConfig dbConfig;
@Inject
protected AndroidExecutor androidExecutor;
public SplashScreenActivity() {
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
@@ -87,12 +90,11 @@ public class SplashScreenActivity extends BaseActivity {
}
private void setPreferencesDefaults() {
new Thread() {
@Override
androidExecutor.execute(new Runnable() {
public void run() {
PreferenceManager.setDefaultValues(SplashScreenActivity.this,
R.xml.panic_preferences, false);
}
}.start();
});
}
}