X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Ftransaction_list%2FTransactionListViewModel.java;h=f994ec7a03097475b643ebf78fa846b87d10bc26;hb=2605ed75387bb13f36b95545df467302a89dcf99;hp=7e0214c1f909795ff23627a2e9a04c0a06917ffb;hpb=73adeb59bc035a88a2c18d8cd79467e2f15825db;p=mobile-ledger.git 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 7e0214c1..f994ec7a 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 @@ -19,39 +19,29 @@ package net.ktnx.mobileledger.ui.transaction_list; import android.os.AsyncTask; +import androidx.lifecycle.ViewModel; + import net.ktnx.mobileledger.async.UpdateTransactionsTask; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.TransactionListItem; +import net.ktnx.mobileledger.utils.LockHolder; 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<>(); public static void scheduleTransactionListReload() { - if (Data.profile.get() == null) return; - - String filter = TransactionListFragment.accountFilter.get(); + String filter = Data.accountFilter.getValue(); AsyncTask task = new UTT(); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filter); } public static TransactionListItem getTransactionListItem(int position) { try(LockHolder lh = Data.transactions.lockForReading()) { - if (Data.transactions == null) return null; - if (position >= Data.transactions.size() + 1) return null; - if (position == Data.transactions.size()) return new TransactionListItem(); + if (position >= Data.transactions.size()) return null; return Data.transactions.get(position); } } - public static int getTransactionCount() { - List transactions = Data.transactions.get(); - if (transactions == null) return 0; - return transactions.size(); - } private static class UTT extends UpdateTransactionsTask { @Override protected void onPostExecute(String error) {