From: Damyan Ivanov Date: Thu, 2 May 2019 15:16:19 +0000 (+0300) Subject: move null check before the value is used X-Git-Tag: v0.10.0~53 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=0fbcabbed3b047c6f24be3def42f3ed2bb2928af;p=mobile-ledger.git move null check before the value is used --- 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);