From ed0b0076b713470b35e3b80219f8d9b231a56ca5 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 24 Nov 2019 23:02:44 +0200 Subject: [PATCH] new transaction fragment: survive configuration changes / fragment restart --- .../ui/activity/NewTransactionFragment.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java index 2775716b..5492d81e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java @@ -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); -- 2.39.5