more thread pool async task execution
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 27 Feb 2019 17:21:50 +0000 (19:21 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 27 Feb 2019 17:21:50 +0000 (19:21 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListViewModel.java

index ad250f9..4d21053 100644 (file)
@@ -17,8 +17,8 @@
 
 package net.ktnx.mobileledger.ui.account_summary;
 
-import androidx.lifecycle.ViewModel;
 import android.content.Context;
+import android.os.AsyncTask;
 import android.util.Log;
 
 import net.ktnx.mobileledger.async.CommitAccountsTask;
@@ -29,17 +29,19 @@ import net.ktnx.mobileledger.model.LedgerAccount;
 
 import java.util.ArrayList;
 
+import androidx.lifecycle.ViewModel;
+
 class AccountSummaryViewModel extends ViewModel {
     static void commitSelections(Context context) {
         CAT task = new CAT();
-        task.execute(
+        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                 new CommitAccountsTaskParams(Data.accounts.get(), Data.optShowOnlyStarred.get()));
     }
     static void scheduleAccountListReload() {
         if (Data.profile.get() == null) return;
 
         UAT task = new UAT();
-        task.execute();
+        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
 
     }
 
index 558ca69..3d53dd5 100644 (file)
@@ -21,6 +21,7 @@ import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.res.ColorStateList;
 import android.graphics.Color;
+import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
@@ -401,7 +402,7 @@ public class MainActivity extends CrashReportingActivity {
         if (error == null) {
             updateLastUpdateTextFromDB();
 
-            new RefreshDescriptionsTask().execute();
+            new RefreshDescriptionsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
         }
         else Toast.makeText(this, error, Toast.LENGTH_LONG).show();
     }
index 7bc1a86..513bf9f 100644 (file)
@@ -17,7 +17,6 @@
 
 package net.ktnx.mobileledger.ui.transaction_list;
 
-import androidx.lifecycle.ViewModel;
 import android.os.AsyncTask;
 
 import net.ktnx.mobileledger.async.UpdateTransactionsTask;
@@ -27,6 +26,8 @@ import net.ktnx.mobileledger.utils.ObservableValue;
 
 import java.util.List;
 
+import androidx.lifecycle.ViewModel;
+
 public class TransactionListViewModel extends ViewModel {
     public static ObservableValue<Boolean> updating = new ObservableValue<>();
     public static ObservableValue<String> updateError = new ObservableValue<>();
@@ -36,7 +37,7 @@ public class TransactionListViewModel extends ViewModel {
 
         String filter = TransactionListFragment.accountFilter.get();
         AsyncTask<String, Void, String> task = new UTT();
-        task.execute(filter);
+        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filter);
     }
     public static TransactionListItem getTransactionListItem(int position) {
         List<TransactionListItem> transactions = Data.transactions.get();