From: Damyan Ivanov Date: Sat, 22 Dec 2018 07:59:54 +0000 (+0000) Subject: fu: single transaction list X-Git-Tag: v0.3~168 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=a5971dd3588704cc5c8dd9077d4d74860c5a06a9;p=mobile-ledger.git fu: single transaction list --- 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 f2377c95..480c0de2 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 @@ -21,25 +21,17 @@ import android.arch.lifecycle.ViewModel; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; +import android.util.Log; import net.ktnx.mobileledger.model.LedgerTransaction; import net.ktnx.mobileledger.utils.MLDB; import java.util.ArrayList; -import java.util.List; public class TransactionListViewModel extends ViewModel { - private List transactions; + private ArrayList transactions; - public List getTransactions(Context context) { - if (transactions == null) { - transactions = new ArrayList<>(); - reloadTransactions(context); - } - - return transactions; - } public void reloadTransactions(Context context) { ArrayList newList = new ArrayList<>(); @@ -51,8 +43,17 @@ public class TransactionListViewModel extends ViewModel { newList.add(new LedgerTransaction(cursor.getInt(0))); } transactions = newList; + Log.d("transactions", "transaction list updated"); } } } + public LedgerTransaction getTransaction(int position) { + if (position >= transactions.size()) return null; + return transactions.get(position); + } + public int getTransactionCount() { + if (transactions == null) return 0; + return transactions.size(); + } }