From 8efd47224289c5cd27952e448441b2197f9640d0 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 21 Dec 2018 20:29:14 +0000 Subject: [PATCH] guard against a race condition when the transaction list is reduced while the scroller requests an item outside the range of the new list --- .../java/net/ktnx/mobileledger/TransactionListAdapter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/TransactionListAdapter.java b/app/src/main/java/net/ktnx/mobileledger/TransactionListAdapter.java index e69aab7b..559a247b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/TransactionListAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/TransactionListAdapter.java @@ -48,6 +48,12 @@ class TransactionListAdapter } public void onBindViewHolder(@NonNull TransactionRowHolder holder, int position) { + // in a race when transaction list is reduced, but the model hasn't been notified yet + // the view will disappear when the notifications reaches the model, so by simply omitting + // the out-of-range get() call nothing bad happens - just a to-be-deleted view remains + // a bit longer + if (position >= transactions.size()) return; + LedgerTransaction tr = transactions.get(position); Context ctx = holder.row.getContext(); -- 2.39.5