From 4f3aa04fd5bf01de0e5218bdadad6f5b507877c6 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 22 Aug 2021 19:15:09 +0300 Subject: [PATCH] fix crash in new transaction shortcut when the main app is not running --- .../ui/new_transaction/NewTransactionFragment.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionFragment.java index 7741d18a..60fd3cba 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionFragment.java @@ -195,8 +195,13 @@ public class NewTransactionFragment extends Fragment { element = FocusedElement.valueOf(savedInstanceState.getString("focused-element")); } - if (!keep) - viewModel.reset(); + if (!keep) { + // we need the DB up and running + Data.observeProfile(getViewLifecycleOwner(), p -> { + if (p != null) + viewModel.reset(); + }); + } else { viewModel.noteFocusChanged(focused, element); } -- 2.39.5