price round
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.helper.PriceHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.cart.CartProductModel;
|
||||
import ch.pizzalink.android.model.cart.CartProductOptionModel;
|
||||
@@ -106,7 +107,7 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
|
||||
cartProductViewHolder.cartProductCountTextView.setText(cartProductList.get(position).getQuantity() + " x ");
|
||||
cartProductViewHolder.cartProductNameTextView.setText(cartProductList.get(position).getName());
|
||||
cartProductViewHolder.cartProductTotalPriceTextView.setText(cartProductList.get(position).getTotal());
|
||||
cartProductViewHolder.cartProductTotalPriceTextView.setText(PriceHelper.roundFractions(cartProductList.get(position).getTotal()));
|
||||
setCartInfoText(cartProductViewHolder.cartProductInfoTextView, cartProductList.get(position));
|
||||
break;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.helper.PriceHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
|
||||
@@ -96,7 +97,7 @@ public class OrderHistoryRecyclerAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
case HOLDER_ORDER :
|
||||
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
|
||||
orderViewHolder.orderDateTextView.setText(orderHistoryList.get(position).getFormattedCreateDate());
|
||||
orderViewHolder.orderTotalTextView.setText(orderHistoryList.get(position).getTotalString());
|
||||
orderViewHolder.orderTotalTextView.setText(PriceHelper.roundFractions(orderHistoryList.get(position).getTotalString()));
|
||||
orderViewHolder.orderStatusTextView.setText(orderHistoryList.get(position).getStatus());
|
||||
break;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.helper.PriceHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.ShippingMethodModel;
|
||||
|
||||
@@ -101,7 +102,7 @@ public class ShippingMethodsRecyclerAdapter extends RecyclerView.Adapter<Recycle
|
||||
switch (holder.getItemViewType()){
|
||||
case HOLDER_SHIPPING_METHOD :
|
||||
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
|
||||
orderViewHolder.shipmentMethodPriceTextView.setText(shippingMethodList.get(position).getPriceText());
|
||||
orderViewHolder.shipmentMethodPriceTextView.setText(PriceHelper.roundFractions(shippingMethodList.get(position).getPriceText()));
|
||||
orderViewHolder.shipmentMethodRadioButton.setText(shippingMethodList.get(position).getTitle());
|
||||
orderViewHolder.shipmentMethodRadioButton.setChecked(shippingMethodList.get(position).isSelected());
|
||||
break;
|
||||
|
||||
@@ -193,7 +193,7 @@ public class CartFragment extends BaseFragment {
|
||||
|
||||
private void setCartTotalFields(){
|
||||
cartTotalLabelTextView.setText(cartInfoModel.getTotals().get(0).getTitle().toUpperCase(Locale.GERMAN));
|
||||
cartProductTotalTextView.setText(cartInfoModel.getTotals().get(0).getText());
|
||||
cartProductTotalTextView.setText(PriceHelper.roundFractions(cartInfoModel.getTotals().get(0).getText()));
|
||||
}
|
||||
|
||||
private void initRecyclerView(){
|
||||
|
||||
@@ -39,6 +39,7 @@ public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
||||
@BindView(R.id.orderNotePizzalinkEditText) PizzalinkEditText orderNotePizzalinkEditText;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "createOrderNoteFragment";
|
||||
private CreateOrderActivity createOrderActivity;
|
||||
|
||||
public CreateOrderNoteFragment() {}
|
||||
|
||||
@@ -55,12 +56,12 @@ public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_create_order_note, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
initViews();
|
||||
return view;
|
||||
}
|
||||
|
||||
@OnClick({R.id.previousTextView, R.id.nextTextView})
|
||||
protected void onClick(View view){
|
||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
switch (view.getId()){
|
||||
case R.id.previousTextView:
|
||||
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
|
||||
@@ -71,4 +72,11 @@ public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
if(createOrderActivity.getOrderNote() != null){
|
||||
orderNotePizzalinkEditText.setText(createOrderActivity.getOrderNote());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.api.ResponseObject;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.PriceHelper;
|
||||
import ch.pizzalink.android.helper.SessionHelper;
|
||||
import ch.pizzalink.android.view.PizzalinkInfoView;
|
||||
import retrofit2.Call;
|
||||
@@ -84,7 +85,7 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
orderShippingMethodPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingMethod().getTitle());
|
||||
orderShippingAddressPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingAddress().getAddress());
|
||||
orderPaymentMethodPizzalinkInfoLayout.setText(createOrderActivity.getSelectedPaymentMethod().getTitle());
|
||||
orderTotalPizzalinkInfoLayout.setText(createOrderActivity.getCartInfo().getTotals().get(0).getText());
|
||||
orderTotalPizzalinkInfoLayout.setText(PriceHelper.roundFractions(createOrderActivity.getCartInfo().getTotals().get(0).getText()));
|
||||
if(createOrderActivity.getOrderNote().isEmpty()){
|
||||
orderNotePizzalinkInfoLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -121,8 +121,22 @@ public class PaymentMethodFragment extends CreateOrderBaseFragment {
|
||||
paymentMethodList.clear();
|
||||
paymentMethodList.addAll(paymentMethodModels);
|
||||
if(paymentMethodList.size() != 0){
|
||||
paymentMethodList.get(0).setSelected(true);
|
||||
selectedPaymentMethod = paymentMethodList.get(0);
|
||||
|
||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
if(createOrderActivity.getSelectedPaymentMethod() == null){
|
||||
paymentMethodList.get(0).setSelected(true);
|
||||
selectedPaymentMethod = paymentMethodList.get(0);
|
||||
}
|
||||
else {
|
||||
for(PaymentMethodModel paymentMethodModel : paymentMethodModels){
|
||||
if(paymentMethodModel.getCode().equals(createOrderActivity.getSelectedPaymentMethod().getCode())){
|
||||
paymentMethodModel.setSelected(true);
|
||||
selectedPaymentMethod = paymentMethodModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -150,8 +150,21 @@ public class ShippingAddressFragment extends CreateOrderBaseFragment {
|
||||
sortAddresses();
|
||||
}
|
||||
|
||||
addressList.get(0).setSelected(true);
|
||||
selectedAddress = addressList.get(0);
|
||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
|
||||
if(createOrderActivity.getSelectedShippingAddress() == null){
|
||||
addressList.get(0).setSelected(true);
|
||||
selectedAddress = addressList.get(0);
|
||||
}
|
||||
else {
|
||||
for(AddressModel addressModel : addressModels){
|
||||
if(addressModel.getId().equals(createOrderActivity.getSelectedShippingAddress().getId())){
|
||||
addressModel.setSelected(true);
|
||||
selectedAddress = addressModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
|
||||
|
||||
@@ -114,8 +114,23 @@ public class ShippingMethodFragment extends CreateOrderBaseFragment {
|
||||
shippingMethodList.clear();
|
||||
shippingMethodList.addAll(shippingMethodModels);
|
||||
if(shippingMethodList.size() != 0){
|
||||
shippingMethodList.get(0).setSelected(true);
|
||||
selectedShippingMethodModel = shippingMethodList.get(0);
|
||||
|
||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
|
||||
if(createOrderActivity.getSelectedShippingMethod() == null){
|
||||
shippingMethodList.get(0).setSelected(true);
|
||||
selectedShippingMethodModel = shippingMethodList.get(0);
|
||||
}
|
||||
else {
|
||||
for(ShippingMethodModel shippingMethodModel : shippingMethodModels){
|
||||
if(shippingMethodModel.getCode().equals(createOrderActivity.getSelectedShippingMethod().getCode())){
|
||||
shippingMethodModel.setSelected(true);
|
||||
selectedShippingMethodModel = shippingMethodModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -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