From 0fbcabbed3b047c6f24be3def42f3ed2bb2928af Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 2 May 2019 18:16:19 +0300 Subject: [PATCH] move null check before the value is used --- .../ui/transaction_list/TransactionListViewModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e88481cf..bd53c2d8 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 @@ -39,8 +39,8 @@ public class TransactionListViewModel extends ViewModel { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filter); } public static TransactionListItem getTransactionListItem(int position) { + if (Data.transactions == null) return null; 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(); return Data.transactions.get(position); -- 2.39.5