]> git.ktnx.net Git - mobile-ledger.git/commitdiff
new transaction fragment: survive configuration changes / fragment restart
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 24 Nov 2019 21:02:44 +0000 (23:02 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 24 Nov 2019 21:02:44 +0000 (23:02 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java

index 2775716bb9d4073fd36fa520ab7c59c668d2071b..5492d81e2f7da9cbf7b74c339614867b8f13029d 100644 (file)
@@ -166,9 +166,19 @@ public class NewTransactionFragment extends Fragment {
                 // TODO display error
             }
             else {
-                viewModel.reset();
             }
         }
+
+        if (savedInstanceState != null) {
+            boolean keep = savedInstanceState.getBoolean("keep", true);
+            if (!keep)
+                viewModel.reset();
+        }
+    }
+    @Override
+    public void onSaveInstanceState(@NonNull Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putBoolean("keep", true);
     }
     private void onFabPressed() {
         fab.setEnabled(false);