From 1e75e369dc2ff10f07e16109cea3bb0e7cf629ed Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 21 Aug 2019 17:48:51 -0500 Subject: [PATCH] Avoid crash in Transactions' FilterOptionsDialog. - This crash was being caused when the user tried to filter the transactions in the Transactions screen, but the user has no balances (existent or downloaded). The app was not prepared to handle that case. --- .../bitsybitshareswallet/fragments/FilterOptionsDialog.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt index 57c6673..0153b9e 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt @@ -236,7 +236,13 @@ class FilterOptionsDialog : DialogFragment(), DatePickerFragment.OnDateSetListen mFilterOptions.assetAll = cbAsset.isChecked - mFilterOptions.asset = (sAsset.selectedItem as BalanceDetail).symbol + val symbol = (sAsset.selectedItem as BalanceDetail?)?.symbol + // If there are no assets in the spinner (the account has 0 balances or the app has not yet + // fetched the account balances) symbol will be null, make sure that does not create a crash. + if (symbol != null) + mFilterOptions.asset = symbol + else + mFilterOptions.assetAll = true mFilterOptions.equivalentValueAll = cbEquivalentValue.isChecked