From 5c20e2470d7ee06cb905faed4081eb45853a6442 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Mon, 17 Dec 2018 16:51:24 -0600 Subject: [PATCH] Avoid a crash in SendTransactionFragment when there are no assets loaded into de db. --- .../fragments/SendTransactionFragment.kt | 4 ++-- .../cy/agorise/bitsybitshareswallet/utils/Constants.kt | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt index 01bedbb..637c786 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -38,7 +38,6 @@ import cy.agorise.graphenej.api.calls.BroadcastTransaction import cy.agorise.graphenej.api.calls.GetAccountByName import cy.agorise.graphenej.api.calls.GetDynamicGlobalProperties import cy.agorise.graphenej.api.calls.GetRequiredFees -import cy.agorise.graphenej.crypto.SecureRandomGenerator import cy.agorise.graphenej.models.AccountProperties import cy.agorise.graphenej.models.DynamicGlobalProperties import cy.agorise.graphenej.models.JsonRpcResponse @@ -374,7 +373,8 @@ class SendTransactionFragment : Fragment(), ZXingScannerView.ResultHandler, Serv } private fun validateAmount(amount: Double) { - val balance = mBalancesDetailsAdapter!!.getItem(spAsset.selectedItemPosition)!! + if (mBalancesDetailsAdapter?.isEmpty != false) return + val balance = mBalancesDetailsAdapter?.getItem(spAsset.selectedItemPosition) ?: return val currentAmount = balance.amount.toDouble() / Math.pow(10.0, balance.precision.toDouble()) if (currentAmount < amount) { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt index f4e1eca..93d1cee 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt @@ -1,8 +1,5 @@ package cy.agorise.bitsybitshareswallet.utils -import cy.agorise.graphenej.Asset - - object Constants { /** Key used to store the number of the last agreed License version */ @@ -11,12 +8,6 @@ object Constants { /** Version of the currently used license */ const val CURRENT_LICENSE_VERSION = 1 - /** - * Key used to store a preference value used to keep track of the last time the assets in - * database were updated. - */ - const val KEY_LAST_ASSET_LIST_UPDATE = "key_last_assets_update" - /** Key used to store if the initial setup is already done or not */ const val KEY_INITIAL_SETUP_DONE = "key_initial_setup_done"