price round
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ch.pizzalink.android.R;
|
import ch.pizzalink.android.R;
|
||||||
|
import ch.pizzalink.android.helper.PriceHelper;
|
||||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzalink.android.model.cart.CartProductModel;
|
import ch.pizzalink.android.model.cart.CartProductModel;
|
||||||
import ch.pizzalink.android.model.cart.CartProductOptionModel;
|
import ch.pizzalink.android.model.cart.CartProductOptionModel;
|
||||||
@@ -106,7 +107,7 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
|
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
|
||||||
cartProductViewHolder.cartProductCountTextView.setText(cartProductList.get(position).getQuantity() + " x ");
|
cartProductViewHolder.cartProductCountTextView.setText(cartProductList.get(position).getQuantity() + " x ");
|
||||||
cartProductViewHolder.cartProductNameTextView.setText(cartProductList.get(position).getName());
|
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));
|
setCartInfoText(cartProductViewHolder.cartProductInfoTextView, cartProductList.get(position));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ch.pizzalink.android.R;
|
import ch.pizzalink.android.R;
|
||||||
|
import ch.pizzalink.android.helper.PriceHelper;
|
||||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzalink.android.model.OrderModel;
|
import ch.pizzalink.android.model.OrderModel;
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ public class OrderHistoryRecyclerAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
case HOLDER_ORDER :
|
case HOLDER_ORDER :
|
||||||
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
|
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
|
||||||
orderViewHolder.orderDateTextView.setText(orderHistoryList.get(position).getFormattedCreateDate());
|
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());
|
orderViewHolder.orderStatusTextView.setText(orderHistoryList.get(position).getStatus());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ch.pizzalink.android.R;
|
import ch.pizzalink.android.R;
|
||||||
|
import ch.pizzalink.android.helper.PriceHelper;
|
||||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzalink.android.model.ShippingMethodModel;
|
import ch.pizzalink.android.model.ShippingMethodModel;
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ public class ShippingMethodsRecyclerAdapter extends RecyclerView.Adapter<Recycle
|
|||||||
switch (holder.getItemViewType()){
|
switch (holder.getItemViewType()){
|
||||||
case HOLDER_SHIPPING_METHOD :
|
case HOLDER_SHIPPING_METHOD :
|
||||||
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
|
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.setText(shippingMethodList.get(position).getTitle());
|
||||||
orderViewHolder.shipmentMethodRadioButton.setChecked(shippingMethodList.get(position).isSelected());
|
orderViewHolder.shipmentMethodRadioButton.setChecked(shippingMethodList.get(position).isSelected());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public class CartFragment extends BaseFragment {
|
|||||||
|
|
||||||
private void setCartTotalFields(){
|
private void setCartTotalFields(){
|
||||||
cartTotalLabelTextView.setText(cartInfoModel.getTotals().get(0).getTitle().toUpperCase(Locale.GERMAN));
|
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(){
|
private void initRecyclerView(){
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
|||||||
@BindView(R.id.orderNotePizzalinkEditText) PizzalinkEditText orderNotePizzalinkEditText;
|
@BindView(R.id.orderNotePizzalinkEditText) PizzalinkEditText orderNotePizzalinkEditText;
|
||||||
|
|
||||||
public static final java.lang.String FRAGMENT_NAME = "createOrderNoteFragment";
|
public static final java.lang.String FRAGMENT_NAME = "createOrderNoteFragment";
|
||||||
|
private CreateOrderActivity createOrderActivity;
|
||||||
|
|
||||||
public CreateOrderNoteFragment() {}
|
public CreateOrderNoteFragment() {}
|
||||||
|
|
||||||
@@ -55,12 +56,12 @@ public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_create_order_note, container, false);
|
View view = inflater.inflate(R.layout.fragment_create_order_note, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
initViews();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick({R.id.previousTextView, R.id.nextTextView})
|
@OnClick({R.id.previousTextView, R.id.nextTextView})
|
||||||
protected void onClick(View view){
|
protected void onClick(View view){
|
||||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
|
||||||
switch (view.getId()){
|
switch (view.getId()){
|
||||||
case R.id.previousTextView:
|
case R.id.previousTextView:
|
||||||
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
|
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
|
||||||
@@ -71,4 +72,11 @@ public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
|||||||
break;
|
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.ApiService;
|
||||||
import ch.pizzalink.android.api.ResponseObject;
|
import ch.pizzalink.android.api.ResponseObject;
|
||||||
import ch.pizzalink.android.helper.DialogHelper;
|
import ch.pizzalink.android.helper.DialogHelper;
|
||||||
|
import ch.pizzalink.android.helper.PriceHelper;
|
||||||
import ch.pizzalink.android.helper.SessionHelper;
|
import ch.pizzalink.android.helper.SessionHelper;
|
||||||
import ch.pizzalink.android.view.PizzalinkInfoView;
|
import ch.pizzalink.android.view.PizzalinkInfoView;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@@ -84,7 +85,7 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
|||||||
orderShippingMethodPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingMethod().getTitle());
|
orderShippingMethodPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingMethod().getTitle());
|
||||||
orderShippingAddressPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingAddress().getAddress());
|
orderShippingAddressPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingAddress().getAddress());
|
||||||
orderPaymentMethodPizzalinkInfoLayout.setText(createOrderActivity.getSelectedPaymentMethod().getTitle());
|
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()){
|
if(createOrderActivity.getOrderNote().isEmpty()){
|
||||||
orderNotePizzalinkInfoLayout.setVisibility(View.GONE);
|
orderNotePizzalinkInfoLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,8 +121,22 @@ public class PaymentMethodFragment extends CreateOrderBaseFragment {
|
|||||||
paymentMethodList.clear();
|
paymentMethodList.clear();
|
||||||
paymentMethodList.addAll(paymentMethodModels);
|
paymentMethodList.addAll(paymentMethodModels);
|
||||||
if(paymentMethodList.size() != 0){
|
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();
|
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,8 +150,21 @@ public class ShippingAddressFragment extends CreateOrderBaseFragment {
|
|||||||
sortAddresses();
|
sortAddresses();
|
||||||
}
|
}
|
||||||
|
|
||||||
addressList.get(0).setSelected(true);
|
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||||
selectedAddress = addressList.get(0);
|
|
||||||
|
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();
|
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
|
||||||
|
|||||||
@@ -114,8 +114,23 @@ public class ShippingMethodFragment extends CreateOrderBaseFragment {
|
|||||||
shippingMethodList.clear();
|
shippingMethodList.clear();
|
||||||
shippingMethodList.addAll(shippingMethodModels);
|
shippingMethodList.addAll(shippingMethodModels);
|
||||||
if(shippingMethodList.size() != 0){
|
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();
|
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ import ch.pizzalink.android.model.menu.MenuProductOptionValueModel;
|
|||||||
public class PriceHelper {
|
public class PriceHelper {
|
||||||
|
|
||||||
public static String getPriceWithCurreny(String price){
|
public static String getPriceWithCurreny(String price){
|
||||||
|
price = roundFractions(price);
|
||||||
return BaseActivity.currentActivity.getString(R.string.chf) + " " + price;
|
return BaseActivity.currentActivity.getString(R.string.chf) + " " + price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPriceWithCurreny(Double 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){
|
public static String removeCurrencyFromPrice(String priceWithCurreny){
|
||||||
@@ -94,14 +96,36 @@ public class PriceHelper {
|
|||||||
.append(" ")
|
.append(" ")
|
||||||
.append(BaseActivity.currentActivity.getString(R.string.chf))
|
.append(BaseActivity.currentActivity.getString(R.string.chf))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(productOptionValueModel.getPrice())
|
.append(roundFractions(productOptionValueModel.getPrice()))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Double stringToDouble(String string){
|
private static Double stringToDouble(String string){
|
||||||
|
string = addFractions(string);
|
||||||
Double dbl = Double.valueOf(string);
|
Double dbl = Double.valueOf(string);
|
||||||
return Math.floor(dbl * 100) / 100;
|
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