Skip to content

Commit

Permalink
Update Crashlytics dependency
Browse files Browse the repository at this point in the history
Fix crash when only negative sign is in calculatorEditText
Fix crash during import due to unsupported amount denominator (now support up to 6)
  • Loading branch information
codinguser committed Nov 4, 2015
1 parent 22b5327 commit e6dcef8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ dependencies {
exclude module: 'httpclient'
}

compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}

Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/org/gnucash/android/model/Money.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public final class Money implements Comparable<Money>{
*/
public static Money getZeroInstance(){
if (sDefaultZero == null) {
String currencyCode = Currency.getInstance(GnuCashApplication.getDefaultLocale()).getCurrencyCode();
String currencyCode = GnuCashApplication.getDefaultCurrencyCode();
sDefaultZero = new Money(BigDecimal.ZERO, Commodity.getInstance(currencyCode));
}
return sDefaultZero;
Expand Down Expand Up @@ -211,9 +211,11 @@ public long getNumerator() {
try {
return mAmount.scaleByPowerOfTen(getScale()).longValueExact();
} catch (ArithmeticException e) {
Log.e(getClass().getName(), "Currency " + mCommodity.getCurrencyCode() +
String msg = "Currency " + mCommodity.getCurrencyCode() +
" with scale " + getScale() +
" has amount " + mAmount.toString());
" has amount " + mAmount.toString();
Crashlytics.log(msg);
Log.e(getClass().getName(), msg);
throw e;
}
}
Expand All @@ -225,16 +227,14 @@ public long getNumerator() {
*/
public long getDenominator() {
switch (getScale()) {
case 0:
return 1;
case 1:
return 10;
case 2:
return 100;
case 3:
return 1000;
case 4:
return 10000;
case 0: return 1;
case 1: return 10;
case 2: return 100;
case 3: return 1000;
case 4: return 10000;
case 5: return 100000;
case 6: return 1000000; //I think GnuCash XML can have gold and silver with this denom

}
throw new RuntimeException("Unsupported number of fraction digits " + getScale());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public boolean isInputModified(){
public BigDecimal getValue(){
evaluate();
String amountString = getCleanString();
if (amountString.isEmpty())
if (amountString.isEmpty() || !amountString.matches("\\d+")) //value should contain atleast one digit
return null;
return new BigDecimal(amountString);
}
Expand Down

0 comments on commit e6dcef8

Please sign in to comment.