price round
This commit is contained in:
@@ -14,11 +14,13 @@ import ch.pizzalink.android.model.menu.MenuProductOptionValueModel;
|
||||
public class PriceHelper {
|
||||
|
||||
public static String getPriceWithCurreny(String price){
|
||||
price = roundFractions(price);
|
||||
return BaseActivity.currentActivity.getString(R.string.chf) + " " + price;
|
||||
}
|
||||
|
||||
public static String getPriceWithCurreny(Double price){
|
||||
return BaseActivity.currentActivity.getString(R.string.chf) + " " + price;
|
||||
String priceString = roundFractions(String.valueOf(price));
|
||||
return BaseActivity.currentActivity.getString(R.string.chf) + " " + priceString;
|
||||
}
|
||||
|
||||
public static String removeCurrencyFromPrice(String priceWithCurreny){
|
||||
@@ -94,14 +96,36 @@ public class PriceHelper {
|
||||
.append(" ")
|
||||
.append(BaseActivity.currentActivity.getString(R.string.chf))
|
||||
.append(" ")
|
||||
.append(productOptionValueModel.getPrice())
|
||||
.append(roundFractions(productOptionValueModel.getPrice()))
|
||||
.toString();
|
||||
}
|
||||
|
||||
private static Double stringToDouble(String string){
|
||||
string = addFractions(string);
|
||||
Double dbl = Double.valueOf(string);
|
||||
return Math.floor(dbl * 100) / 100;
|
||||
}
|
||||
|
||||
public static String roundFractions(String price){
|
||||
|
||||
if(price.equals("0")){
|
||||
price = "0.-";
|
||||
}
|
||||
if(price.endsWith(".0")){
|
||||
price = price.replace(".0", ".-");
|
||||
}
|
||||
else if(price.endsWith(".00")){
|
||||
price = price.replace(".00", ".-");
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
private static String addFractions(String price){
|
||||
if(price.endsWith(".-")){
|
||||
price = price.replace(".-", ".00");
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user