- try (LockHolder locker = Data.transactions.lockForWriting()) {
- List<TransactionListItem> transactions = Data.transactions.getList();
- TransactionListItem target = new TransactionListItem(date, true);
- int found = Collections.binarySearch(transactions, target,
- new TransactionListItemComparator());
- if (found >= 0)
- return found;
- else
- return 1 - found;
- }
+ TransactionListItem target = new TransactionListItem(date, true);
+ int found =
+ Collections.binarySearch(transactions, target, new TransactionListItemComparator());
+ if (found < 0)
+ found = -1 - found;
+
+ model.foundTransactionItemIndex.postValue(found);