From 9c921183abfc9659adfcfe9eac414d2b6a79cd07 Mon Sep 17 00:00:00 2001 From: m2049r Date: Sun, 8 Mar 2020 22:29:02 +0100 Subject: [PATCH] catch NPE (#655) --- .../xmrwallet/widget/ExchangeEditText.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java index 364aca7b..644dbe50 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java +++ b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java @@ -68,15 +68,19 @@ public class ExchangeEditText extends LinearLayout { } boolean ok = true; String nativeAmount = getNativeAmount(); - try { - double amount = Double.parseDouble(nativeAmount); - if ((amount < min) || (amount > max)) { + if (nativeAmount == null) { + ok = false; + } else { + try { + double amount = Double.parseDouble(nativeAmount); + if ((amount < min) || (amount > max)) { + ok = false; + } + } catch (NumberFormatException ex) { + // this cannot be + Timber.e(ex.getLocalizedMessage()); ok = false; } - } catch (NumberFormatException ex) { - // this cannot be - Timber.e(ex.getLocalizedMessage()); - ok = false; } if (!ok) { shakeAmountField();