commit 85a3a53805ae47e753b05704dce77dcef06b3183
parent e9aae97e558c0f57479d5f827a0fc6b802bfee81
Author: Torsten Grote <t@grobox.de>
Date: Tue, 13 Oct 2020 10:12:34 -0300
[cashier] prevent crash while main fragment is on back-stack
and screen is rotated two times.
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt
@@ -53,7 +53,7 @@ class BalanceFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
+ savedInstanceState: Bundle?,
): View? {
setHasOptionsMenu(true)
ui = FragmentBalanceBinding.inflate(layoutInflater, container, false)
@@ -97,8 +97,9 @@ class BalanceFragment : Fragment() {
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
- // for some reason automatic restore isn't working at the moment!?
- ui.amountView.editText?.text.let {
+ // automatic restore isn't working, maybe because of the different layout in landscape mode
+ // the ui won't be available after onDestroyView()
+ if (view != null) ui.amountView.editText?.text.let {
outState.putCharSequence("amountView", it)
}
}