add to cart dialog

This commit is contained in:
2017-10-14 22:03:11 +03:00
parent da8c8dbc20
commit 98292254b4
10 changed files with 268 additions and 122 deletions

View File

@@ -31,7 +31,7 @@ public class PriceHelper {
}
public static String calculatePriceAfterCountChanged(String oldPriceString, int oldCount, int newCount){
Double oldPrice = Double.valueOf(removeCurrencyFromPrice(oldPriceString));
Double oldPrice = stringToDouble(removeCurrencyFromPrice(oldPriceString));
Double productOldPrice = oldPrice / oldCount;
Double productNewPrice = productOldPrice * newCount;
return getPriceWithCurreny(productNewPrice);
@@ -41,14 +41,14 @@ public class PriceHelper {
MenuProductModel menuProductModel,
MenuProductOptionValueModel menuProductOptionValueModel){
Double productPrice = Double.valueOf(menuProductModel.getPrice());
Double productPrice = stringToDouble(menuProductModel.getPrice());
switch (menuProductOptionValueModel.getPrice_prefix()){
case "+":
productPrice += Double.valueOf(menuProductOptionValueModel.getPrice());
productPrice += stringToDouble(menuProductOptionValueModel.getPrice());
break;
case "-":
productPrice -= Double.valueOf(menuProductOptionValueModel.getPrice());
productPrice -= stringToDouble(menuProductOptionValueModel.getPrice());
break;
}
@@ -60,16 +60,16 @@ public class PriceHelper {
MenuProductModel menuProductModel,
ArrayList<MenuProductOptionValueModel> menuProductOptionValueModelList){
Double productPrice = Double.valueOf(menuProductModel.getPrice());
Double productPrice = stringToDouble(menuProductModel.getPrice());
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModelList){
if(menuProductOptionValueModel.isSelected()){
switch (menuProductOptionValueModel.getPrice_prefix()){
case "+":
productPrice += Double.valueOf(menuProductOptionValueModel.getPrice());
productPrice += stringToDouble(menuProductOptionValueModel.getPrice());
break;
case "-":
productPrice -= Double.valueOf(menuProductOptionValueModel.getPrice());
productPrice -= stringToDouble(menuProductOptionValueModel.getPrice());
break;
}
}
@@ -79,5 +79,20 @@ public class PriceHelper {
}
public static String getProductOptionPriceText(MenuProductOptionValueModel productOptionValueModel){
return new StringBuilder()
//.append(productOptionValueModel.getPrice_prefix())
.append(" ")
.append(BaseActivity.currentActivity.getString(R.string.chf))
.append(" ")
.append(productOptionValueModel.getPrice())
.toString();
}
private static Double stringToDouble(String string){
Double dbl = Double.valueOf(string);
return Math.floor(dbl * 100) / 100;
}
}