Scroll up when new transactions are found.
- Added a mechanism to automatically scroll to the top in the TransactionsFragment when the difference between the old and new list of transactions is 1, which most probably means that a new transaction was detected.
This commit is contained in:
parent
fa8d6cb85f
commit
bad25f57fc
1 changed files with 6 additions and 0 deletions
|
@ -76,7 +76,13 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
|
|||
rvTransactions.visibility = View.VISIBLE
|
||||
tvEmpty.visibility = View.GONE
|
||||
|
||||
val shouldScrollUp = transactions.size - transfersDetailsAdapter.itemCount == 1
|
||||
transfersDetailsAdapter.replaceAll(transactions)
|
||||
|
||||
// Scroll to the top only if the difference between old and new items is 1
|
||||
// which most likely means a new transaction was received/sent.
|
||||
if (shouldScrollUp)
|
||||
rvTransactions.scrollToPosition(0)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue