From bad25f57fc58ee0df22b41bf027eb0d70d3029ea Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 4 Sep 2019 12:37:25 -0500 Subject: [PATCH] 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. --- .../bitsybitshareswallet/fragments/TransactionsFragment.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt index 41253e5..b703113 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt @@ -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) } })