Add double rounding helper
This commit is contained in:
parent
0966bea1e8
commit
3150e7d00f
2 changed files with 8 additions and 1 deletions
|
@ -7,6 +7,8 @@ import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -155,5 +157,11 @@ public class Helpers {
|
||||||
return niceTimeScalar(t).replaceFirst("^1 ", "");
|
return niceTimeScalar(t).replaceFirst("^1 ", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double roundDouble(double value, int places) {
|
||||||
|
if (places < 0) throw new IllegalArgumentException("Invalid decimal places");
|
||||||
|
BigDecimal bd = new BigDecimal(value);
|
||||||
|
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
||||||
|
return bd.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/insightstatusmasterlayout"
|
android:id="@+id/insightstatusmasterlayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue