From: Damyan Ivanov Date: Wed, 27 Feb 2019 17:21:50 +0000 (+0200) Subject: more thread pool async task execution X-Git-Tag: v0.7~53 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=bacefcef0a636ed2334b50566a029e120642d929;p=mobile-ledger.git more thread pool async task execution --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java index ad250f97..4d210534 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java @@ -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); } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 558ca691..3d53dd50 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -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(); } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListViewModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListViewModel.java index 7bc1a866..513bf9f4 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListViewModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListViewModel.java @@ -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 updating = new ObservableValue<>(); public static ObservableValue updateError = new ObservableValue<>(); @@ -36,7 +37,7 @@ public class TransactionListViewModel extends ViewModel { String filter = TransactionListFragment.accountFilter.get(); AsyncTask task = new UTT(); - task.execute(filter); + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filter); } public static TransactionListItem getTransactionListItem(int position) { List transactions = Data.transactions.get();