Skip to content

Commit

Permalink
catch NPE (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2049r authored Mar 8, 2020
1 parent b978396 commit 9c92118
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,19 @@ public boolean validate(double max, double min) {
}
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();
Expand Down

0 comments on commit 9c92118

Please sign in to comment.