]> git.ktnx.net Git - mobile-ledger-staging.git/commitdiff
avoid scrolling to the last 'go to date' after reconfiguration
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 17 Jun 2020 19:18:20 +0000 (22:18 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 17 Jun 2020 19:18:20 +0000 (22:18 +0300)
a cleaner solution would be to have some sort of messaging mechanism to notify the fragment of the position of the 'go to' date

app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java

index 68e243a891d4662cdfc76d4e9ef5a0e12fdb4dc3..47794138cd1cb9ed526d3d7360aa7cf904ddc306 100644 (file)
@@ -164,8 +164,11 @@ public class TransactionListFragment extends MobileLedgerListFragment
 
         Data.foundTransactionItemIndex.observe(getViewLifecycleOwner(), pos -> {
             Logger.debug("go-to-date", String.format(Locale.US, "Found pos %d", pos));
-            if (pos != null)
+            if (pos != null) {
                 root.scrollToPosition(pos);
+                // reset the value to avoid re-notification upon reconfiguration or app restart
+                Data.foundTransactionItemIndex.setValue(null);
+            }
         });
     }
     private void onAccountNameFilterChanged(String accName) {