productOptionType enum fix
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
BIN
.idea/caches/gradle_models.ser
generated
BIN
.idea/caches/gradle_models.ser
generated
Binary file not shown.
@@ -1,424 +0,0 @@
|
|||||||
package ch.pizzamaxx.android.dialog;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.design.widget.BottomSheetBehavior;
|
|
||||||
import android.support.design.widget.BottomSheetDialog;
|
|
||||||
import android.support.design.widget.BottomSheetDialogFragment;
|
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import butterknife.BindString;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import ch.pizzamaxx.android.R;
|
|
||||||
import ch.pizzamaxx.android.activity.BaseActivity;
|
|
||||||
import ch.pizzamaxx.android.activity.MainActivity;
|
|
||||||
import ch.pizzamaxx.android.adapter.recycler.ProductCheckboxOptionsRecyclerAdapter;
|
|
||||||
import ch.pizzamaxx.android.adapter.recycler.ProductRadioOptionsRecyclerAdapter;
|
|
||||||
import ch.pizzamaxx.android.api.ApiEndPoints;
|
|
||||||
import ch.pizzamaxx.android.api.ApiService;
|
|
||||||
import ch.pizzamaxx.android.api.ResponseObject;
|
|
||||||
import ch.pizzamaxx.android.helper.DialogHelper;
|
|
||||||
import ch.pizzamaxx.android.helper.ImageLoadHelper;
|
|
||||||
import ch.pizzamaxx.android.helper.PriceHelper;
|
|
||||||
import ch.pizzamaxx.android.helper.SessionHelper;
|
|
||||||
import ch.pizzamaxx.android.helper.SharedPrefsHelper;
|
|
||||||
import ch.pizzamaxx.android.interfaces.RecyclerItemClickListener;
|
|
||||||
import ch.pizzamaxx.android.model.cart.CartInfoModel;
|
|
||||||
import ch.pizzamaxx.android.model.menu.MenuProductModel;
|
|
||||||
import ch.pizzamaxx.android.model.menu.MenuProductOptionModel;
|
|
||||||
import ch.pizzamaxx.android.model.menu.MenuProductOptionValueModel;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by cimenmus on 08/10/2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ProductPropertiesBottomSheetDialog extends BottomSheetDialogFragment {
|
|
||||||
|
|
||||||
@BindView(R.id.closeImageView) ImageView closeImageView;
|
|
||||||
@BindView(R.id.productImageView) ImageView productImageView;
|
|
||||||
@BindView(R.id.productNameTextView) TextView productNameTextView;
|
|
||||||
@BindView(R.id.productPriceTextView) TextView productPriceTextView;
|
|
||||||
@BindView(R.id.addToCartButton) Button addToCartButton;
|
|
||||||
@BindView(R.id.radioRecyclerHeaderTextView) TextView radioRecyclerHeaderTextView;
|
|
||||||
@BindView(R.id.radioRecyclerView) RecyclerView radioRecyclerView;
|
|
||||||
@BindView(R.id.checkboxRecyclerHeaderTextView) TextView checkboxRecyclerHeaderTextView;
|
|
||||||
@BindView(R.id.checkboxRecyclerView) RecyclerView checkboxRecyclerView;
|
|
||||||
@BindView(R.id.increaseProductCountImageView) ImageView increaseProductCountImageView;
|
|
||||||
@BindView(R.id.deccreaseProductCountImageView) ImageView deccreaseProductCountImageView;
|
|
||||||
@BindView(R.id.productCountTextView) TextView productCountTextView;
|
|
||||||
|
|
||||||
@BindString(R.string.no_options_selected_part) String noOptionsSelectedText;
|
|
||||||
|
|
||||||
private int productCount = 1;
|
|
||||||
|
|
||||||
private BottomSheetBehavior mBehavior;
|
|
||||||
private MenuProductModel menuProductModel;
|
|
||||||
|
|
||||||
private ArrayList<MenuProductOptionValueModel> productRadioOptionValueList = new ArrayList<>();
|
|
||||||
private ArrayList<MenuProductOptionValueModel> productCheckboxOptionValueList = new ArrayList<>();
|
|
||||||
private ProductRadioOptionsRecyclerAdapter productRadioOptionsRecyclerAdapter;
|
|
||||||
private ProductCheckboxOptionsRecyclerAdapter productCheckboxOptionsRecyclerAdapter;
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
|
|
||||||
View view = View.inflate(getContext(), R.layout.layout_bottomsheet, null);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
initViews();
|
|
||||||
dialog.setContentView(view);
|
|
||||||
mBehavior = BottomSheetBehavior.from((View) view.getParent());
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick({R.id.closeImageView,
|
|
||||||
R.id.increaseProductCountImageView,
|
|
||||||
R.id.deccreaseProductCountImageView,
|
|
||||||
R.id.addToCartButton})
|
|
||||||
public void onCLick(View view){
|
|
||||||
switch (view.getId()){
|
|
||||||
case R.id.closeImageView:
|
|
||||||
dismiss();
|
|
||||||
break;
|
|
||||||
case R.id.increaseProductCountImageView:
|
|
||||||
productCount++;
|
|
||||||
productCountTextView.setText(String.valueOf(productCount));
|
|
||||||
productPriceTextView.setText(
|
|
||||||
PriceHelper.calculatePriceAfterCountChanged(
|
|
||||||
productPriceTextView.getText().toString(), productCount - 1, productCount));
|
|
||||||
break;
|
|
||||||
case R.id.deccreaseProductCountImageView:
|
|
||||||
if(productCount == 1)
|
|
||||||
break;
|
|
||||||
productCount--;
|
|
||||||
productCountTextView.setText(String.valueOf(productCount));
|
|
||||||
productPriceTextView.setText(
|
|
||||||
PriceHelper.calculatePriceAfterCountChanged(
|
|
||||||
productPriceTextView.getText().toString(), productCount + 1, productCount));
|
|
||||||
break;
|
|
||||||
case R.id.addToCartButton:
|
|
||||||
if(checkFields())
|
|
||||||
//addProductToCart();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
|
|
||||||
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
|
|
||||||
menuProductOptionValueModel.setSelected(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
|
|
||||||
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
|
|
||||||
if(menuProductOptionValueModel.getPrice().equals("0") || menuProductOptionValueModel.getPrice().equals("0.00")){
|
|
||||||
|
|
||||||
/*
|
|
||||||
//checkbox
|
|
||||||
if(!(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
|
|
||||||
menuProductOptionModel.getType().toLowerCase().equals("select"))){
|
|
||||||
menuProductOptionValueModel.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//radio
|
|
||||||
else if(!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList())){
|
|
||||||
menuProductOptionValueModel.setSelected(true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if((menuProductOptionModel.getType().toLowerCase().equals("radio") ||
|
|
||||||
menuProductOptionModel.getType().toLowerCase().equals("select") &&
|
|
||||||
!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList()))){
|
|
||||||
menuProductOptionValueModel.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initViews(){
|
|
||||||
setFields();
|
|
||||||
fillRadioAndCheckboxOptionLists();
|
|
||||||
switch (menuProductModel.getProductOptionType()){
|
|
||||||
case RADIO_AND_CHECKBOX:
|
|
||||||
radioRecyclerView.setVisibility(View.VISIBLE);
|
|
||||||
checkboxRecyclerView.setVisibility(View.VISIBLE);
|
|
||||||
radioRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
|
||||||
checkboxRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
|
||||||
initRadioRecyclerView();
|
|
||||||
initCheckboxRecyclerView();
|
|
||||||
break;
|
|
||||||
case RADIO:
|
|
||||||
radioRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
|
||||||
radioRecyclerView.setVisibility(View.VISIBLE);
|
|
||||||
checkboxRecyclerView.setVisibility(View.GONE);
|
|
||||||
checkboxRecyclerHeaderTextView.setVisibility(View.GONE);
|
|
||||||
initRadioRecyclerView();
|
|
||||||
break;
|
|
||||||
case CHECKBOX:
|
|
||||||
radioRecyclerHeaderTextView.setVisibility(View.GONE);
|
|
||||||
radioRecyclerView.setVisibility(View.GONE);
|
|
||||||
checkboxRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
|
||||||
checkboxRecyclerView.setVisibility(View.VISIBLE);
|
|
||||||
initCheckboxRecyclerView();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMenuProductModel(MenuProductModel menuProductModel){
|
|
||||||
this.menuProductModel = menuProductModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initRadioRecyclerView(){
|
|
||||||
radioRecyclerView.setNestedScrollingEnabled(false);
|
|
||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(BaseActivity.currentActivity, 1);
|
|
||||||
radioRecyclerView.setLayoutManager(gridLayoutManager);
|
|
||||||
productRadioOptionsRecyclerAdapter = new ProductRadioOptionsRecyclerAdapter(productRadioOptionValueList, new RecyclerItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(View view, int position) {
|
|
||||||
if(!productRadioOptionValueList.get(position).isSelected()){
|
|
||||||
for(MenuProductOptionValueModel menuProductOptionValueModel : productRadioOptionValueList){
|
|
||||||
menuProductOptionValueModel.setSelected(false);
|
|
||||||
}
|
|
||||||
productRadioOptionValueList.get(position).setSelected(true);
|
|
||||||
productRadioOptionsRecyclerAdapter.notifyDataSetChanged();
|
|
||||||
productPriceTextView.setText(PriceHelper.calculatePriceAfterRadioOptionValueChanged(
|
|
||||||
productCount, menuProductModel, productRadioOptionValueList.get(position)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
radioRecyclerView.setAdapter(productRadioOptionsRecyclerAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initCheckboxRecyclerView(){
|
|
||||||
checkboxRecyclerView.setNestedScrollingEnabled(false);
|
|
||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(BaseActivity.currentActivity, 1);
|
|
||||||
checkboxRecyclerView.setLayoutManager(gridLayoutManager);
|
|
||||||
productCheckboxOptionsRecyclerAdapter = new ProductCheckboxOptionsRecyclerAdapter(productCheckboxOptionValueList, new RecyclerItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(View view, int position) {
|
|
||||||
productCheckboxOptionValueList.get(position).setSelected(
|
|
||||||
!productCheckboxOptionValueList.get(position).isSelected());
|
|
||||||
productCheckboxOptionsRecyclerAdapter.notifyItemChanged(position);
|
|
||||||
productPriceTextView.setText(
|
|
||||||
PriceHelper.calculatePriceAfterCheckboxOptionValueChanged(
|
|
||||||
productCount, menuProductModel, productCheckboxOptionValueList));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
checkboxRecyclerView.setAdapter(productCheckboxOptionsRecyclerAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFields(){
|
|
||||||
ImageLoadHelper.loadImage(productImageView, menuProductModel.getImageURL());
|
|
||||||
productNameTextView.setText(menuProductModel.getName());
|
|
||||||
productPriceTextView.setText(PriceHelper.getPriceWithCurreny(menuProductModel.getPrice()));
|
|
||||||
productPriceTextView.setText(PriceHelper.getPriceWithCurreny(menuProductModel.getPrice()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillRadioAndCheckboxOptionLists(){
|
|
||||||
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
|
|
||||||
setSelectedPriceShowingOptions(menuProductOptionModel);
|
|
||||||
|
|
||||||
if(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
|
|
||||||
menuProductOptionModel.getType().toLowerCase().equals("select")){
|
|
||||||
radioRecyclerHeaderTextView.setText(menuProductOptionModel.getName());
|
|
||||||
productRadioOptionValueList.addAll(menuProductOptionModel.getOptionValueModelList());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
checkboxRecyclerHeaderTextView.setText(menuProductOptionModel.getName());
|
|
||||||
productCheckboxOptionValueList.addAll(menuProductOptionModel.getOptionValueModelList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSelectedPriceShowingOptions(MenuProductOptionModel menuProductOptionModel){
|
|
||||||
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
|
|
||||||
if(menuProductOptionValueModel.getPrice().equals("0") || menuProductOptionValueModel.getPrice().equals("0.00")){
|
|
||||||
|
|
||||||
/*
|
|
||||||
//checkbox
|
|
||||||
if(!(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
|
|
||||||
menuProductOptionModel.getType().toLowerCase().equals("select"))){
|
|
||||||
menuProductOptionValueModel.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//radio
|
|
||||||
else if(!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList())){
|
|
||||||
menuProductOptionValueModel.setSelected(true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if((menuProductOptionModel.getType().toLowerCase().equals("radio") ||
|
|
||||||
menuProductOptionModel.getType().toLowerCase().equals("select") &&
|
|
||||||
!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList()))){
|
|
||||||
menuProductOptionValueModel.setSelected(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
private void addProductToCart(){
|
|
||||||
DialogHelper.showLoadingDialog();
|
|
||||||
Call<ResponseObject<AddProductToBasketResponseModel>> call =
|
|
||||||
ApiService.apiInterface.addProductsToBasket(
|
|
||||||
ApiEndPoints.API_ADD_PRODUCTS_TO_BASKET + SessionHelper.getCustomerToken().getToken(),
|
|
||||||
getAddToCartRequestParams());
|
|
||||||
call.enqueue(new Callback<ResponseObject<AddProductToBasketResponseModel>>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ResponseObject<AddProductToBasketResponseModel>> call, Response<ResponseObject<AddProductToBasketResponseModel>> response) {
|
|
||||||
DialogHelper.hideLoadingDialog();
|
|
||||||
if(response.isSuccessful() && response.body().getData() != null){
|
|
||||||
if(response.body().isSuccess()){
|
|
||||||
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, response.body().getData().getSuccessMessage());
|
|
||||||
getCartItemCount();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, response.body().getData().getErrorMessage());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ApiErrorUtils.parseError(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ResponseObject<AddProductToBasketResponseModel>> call, Throwable t) {
|
|
||||||
DialogHelper.hideLoadingDialog();
|
|
||||||
DialogHelper.showFailedDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private HashMap<String, Object> getAddToCartRequestParams(){
|
|
||||||
|
|
||||||
HashMap<String, Object> params = new HashMap<>();
|
|
||||||
params.put("product_id", menuProductModel.getId());
|
|
||||||
params.put("quantity", productCount);
|
|
||||||
|
|
||||||
for(MenuProductOptionModel productOptionModel : menuProductModel.getProductOptionList()){
|
|
||||||
|
|
||||||
ArrayList<String> selectedCheckboxOptionList = new ArrayList<>();
|
|
||||||
|
|
||||||
for(MenuProductOptionValueModel productOptionValueModel : productOptionModel.getOptionValueModelList()){
|
|
||||||
|
|
||||||
if(productOptionValueModel.isSelected()){
|
|
||||||
|
|
||||||
if(productOptionModel.getType().equals("checkbox")){
|
|
||||||
selectedCheckboxOptionList.add(productOptionValueModel.getProductOptionValueId());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
params.put("option[" + productOptionModel.getProductOptionId() + "]", productOptionValueModel.getProductOptionValueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(productOptionModel.getType().equals("checkbox")){
|
|
||||||
params.put("option[" + productOptionModel.getProductOptionId() + "]", selectedCheckboxOptionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getCartItemCount(){
|
|
||||||
/*
|
|
||||||
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
|
|
||||||
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
|
|
||||||
*/
|
|
||||||
|
|
||||||
HashMap<String, Object> params = new HashMap<>();
|
|
||||||
if(SessionHelper.getSelectedCoupon() != null){
|
|
||||||
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
|
|
||||||
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
|
|
||||||
params);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
|
|
||||||
if(response.isSuccessful() &&
|
|
||||||
response.body().getData() != null &&
|
|
||||||
response.body().isSuccess()){
|
|
||||||
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
|
|
||||||
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
|
|
||||||
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
|
|
||||||
mainActivity.setCartItemCount();
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean checkFields(){
|
|
||||||
|
|
||||||
if(radioRecyclerView.getVisibility() == View.VISIBLE &&
|
|
||||||
!isSelectedAtLeastOne(productRadioOptionValueList)){
|
|
||||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity,
|
|
||||||
radioRecyclerHeaderTextView.getText().toString() + " " + noOptionsSelectedText);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(checkboxRecyclerView.getVisibility() == View.VISIBLE &&
|
|
||||||
!isSelectedAtLeastOne(productCheckboxOptionValueList)){
|
|
||||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity,
|
|
||||||
checkboxRecyclerHeaderTextView.getText().toString() + " " + noOptionsSelectedText);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSelectedAtLeastOne(ArrayList<MenuProductOptionValueModel> menuProductOptionValueModels){
|
|
||||||
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModels){
|
|
||||||
if(menuProductOptionValueModel.isSelected()){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isAnyOptionValueSelected(ArrayList<MenuProductOptionValueModel> menuProductOptionValueModels){
|
|
||||||
for (MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModels){
|
|
||||||
if(menuProductOptionValueModel.isSelected()){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -22,9 +22,7 @@ import ch.pizzamaxx.android.adapter.recycler.MenuProductRecyclerAdapter;
|
|||||||
import ch.pizzamaxx.android.api.ApiErrorUtils;
|
import ch.pizzamaxx.android.api.ApiErrorUtils;
|
||||||
import ch.pizzamaxx.android.api.ApiService;
|
import ch.pizzamaxx.android.api.ApiService;
|
||||||
import ch.pizzamaxx.android.api.ResponseArray;
|
import ch.pizzamaxx.android.api.ResponseArray;
|
||||||
import ch.pizzamaxx.android.dialog.ProductPropertiesBottomSheetDialog;
|
|
||||||
import ch.pizzamaxx.android.helper.DialogHelper;
|
import ch.pizzamaxx.android.helper.DialogHelper;
|
||||||
import ch.pizzamaxx.android.helper.DisplayHelper;
|
|
||||||
import ch.pizzamaxx.android.helper.SessionHelper;
|
import ch.pizzamaxx.android.helper.SessionHelper;
|
||||||
import ch.pizzamaxx.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzamaxx.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzamaxx.android.model.CategoryModel;
|
import ch.pizzamaxx.android.model.CategoryModel;
|
||||||
@@ -110,7 +108,6 @@ public class MenuFragment extends BaseFragment {
|
|||||||
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
|
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
|
||||||
productPropertiesIntent.putExtra("menuProductModel", menuProductList.get(position));
|
productPropertiesIntent.putExtra("menuProductModel", menuProductList.get(position));
|
||||||
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
|
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
|
||||||
//showBottomsheetDialog(menuProductList.get(position));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
|
menuProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
|
||||||
@@ -150,12 +147,6 @@ public class MenuFragment extends BaseFragment {
|
|||||||
menuProductRecyclerAdapter.notifyDataSetChanged();
|
menuProductRecyclerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showBottomsheetDialog(MenuProductModel menuProductModel){
|
|
||||||
ProductPropertiesBottomSheetDialog productPropertiesBottomSheetDialog = new ProductPropertiesBottomSheetDialog();
|
|
||||||
productPropertiesBottomSheetDialog.setMenuProductModel(menuProductModel);
|
|
||||||
productPropertiesBottomSheetDialog.show(getChildFragmentManager(), "dialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortProductsByName(){
|
private void sortProductsByName(){
|
||||||
Collections.sort(menuProductList, new Comparator<MenuProductModel>() {
|
Collections.sort(menuProductList, new Comparator<MenuProductModel>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ import ch.pizzamaxx.android.api.ApiConstants;
|
|||||||
import ch.pizzamaxx.android.api.ApiErrorUtils;
|
import ch.pizzamaxx.android.api.ApiErrorUtils;
|
||||||
import ch.pizzamaxx.android.api.ApiService;
|
import ch.pizzamaxx.android.api.ApiService;
|
||||||
import ch.pizzamaxx.android.api.ResponseArray;
|
import ch.pizzamaxx.android.api.ResponseArray;
|
||||||
import ch.pizzamaxx.android.dialog.ProductPropertiesBottomSheetDialog;
|
|
||||||
import ch.pizzamaxx.android.helper.DialogHelper;
|
import ch.pizzamaxx.android.helper.DialogHelper;
|
||||||
import ch.pizzamaxx.android.helper.DisplayHelper;
|
|
||||||
import ch.pizzamaxx.android.helper.SessionHelper;
|
import ch.pizzamaxx.android.helper.SessionHelper;
|
||||||
import ch.pizzamaxx.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzamaxx.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzamaxx.android.model.CategoryModel;
|
import ch.pizzamaxx.android.model.CategoryModel;
|
||||||
@@ -110,7 +108,6 @@ public class ProductFragment extends BaseFragment {
|
|||||||
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
|
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
|
||||||
productPropertiesIntent.putExtra("menuProductModel", productList.get(position));
|
productPropertiesIntent.putExtra("menuProductModel", productList.get(position));
|
||||||
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
|
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
|
||||||
//showBottomsheetDialog(productList.get(position));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
customProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
|
customProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
|
||||||
@@ -159,12 +156,6 @@ public class ProductFragment extends BaseFragment {
|
|||||||
return ApiConstants.PRODUCT_ID_EKSTRA_KEBAP;
|
return ApiConstants.PRODUCT_ID_EKSTRA_KEBAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showBottomsheetDialog(MenuProductModel menuProductModel){
|
|
||||||
ProductPropertiesBottomSheetDialog productPropertiesBottomSheetDialog = new ProductPropertiesBottomSheetDialog();
|
|
||||||
productPropertiesBottomSheetDialog.setMenuProductModel(menuProductModel);
|
|
||||||
productPropertiesBottomSheetDialog.show(getChildFragmentManager(), "dialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortProductsByName(){
|
private void sortProductsByName(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,33 +61,6 @@ public class MenuProductModel implements Serializable {
|
|||||||
!description.equals(BaseActivity.currentActivity.getString(R.string.empty_description));
|
!description.equals(BaseActivity.currentActivity.getString(R.string.empty_description));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductOptionType getProductOptionType(){
|
|
||||||
if(productOptionList == null)
|
|
||||||
return ProductOptionType.NO_TYPE;
|
|
||||||
switch (productOptionList.size()){
|
|
||||||
case 0:
|
|
||||||
return ProductOptionType.NO_TYPE;
|
|
||||||
case 1:
|
|
||||||
if(productOptionList.get(0).getType().toLowerCase().equals("radio") ||
|
|
||||||
productOptionList.get(0).getType().toLowerCase().equals("select"))
|
|
||||||
return ProductOptionType.RADIO;
|
|
||||||
else
|
|
||||||
return ProductOptionType.CHECKBOX;
|
|
||||||
case 2:
|
|
||||||
return ProductOptionType.RADIO_AND_CHECKBOX;
|
|
||||||
default:
|
|
||||||
//return ProductOptionType.NO_TYPE;
|
|
||||||
return ProductOptionType.RADIO_AND_CHECKBOX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ProductOptionType{
|
|
||||||
NO_TYPE,
|
|
||||||
RADIO,
|
|
||||||
CHECKBOX,
|
|
||||||
RADIO_AND_CHECKBOX
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,231 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:ignore="MissingPrefix"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@color/white">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:src="@drawable/ic_back"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<!-- android:background="@color/cart_dialog_background" -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@color/white">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/closeImageView"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:src="@drawable/ic_cancel"
|
|
||||||
android:layout_gravity="right|end"
|
|
||||||
android:padding="12dp"/>
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/productImageView"
|
|
||||||
android:layout_width="120dp"
|
|
||||||
android:layout_height="120dp"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:layout_marginEnd="12dp"
|
|
||||||
android:layout_gravity="center_horizontal" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginEnd="12dp"
|
|
||||||
android:layout_toRightOf="@+id/productImageView"
|
|
||||||
android:layout_toEndOf="@+id/productImageView">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/productNameTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:padding="12sp"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/productPriceTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/red"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:paddingBottom="12dp"
|
|
||||||
android:paddingLeft="12dp"
|
|
||||||
android:paddingStart="12dp"
|
|
||||||
android:paddingRight="12dp"
|
|
||||||
android:paddingEnd="12dp"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/addToCartButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:text="@string/add_to_cart"
|
|
||||||
style="@style/PizzappGrayButton"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:layout_marginBottom="12dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<android.support.v4.widget.NestedScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:scrollbars="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:text="@string/count"
|
|
||||||
android:paddingTop="12dp"
|
|
||||||
android:paddingLeft="12dp"
|
|
||||||
android:paddingStart="12dp"
|
|
||||||
android:paddingRight="12dp"
|
|
||||||
android:paddingEnd="12dp"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@color/black"/>
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/ProductCountLayout"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_margin="12dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/deccreaseProductCountImageView"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:padding="4dp"
|
|
||||||
android:src="@drawable/ic_decrease"
|
|
||||||
android:layout_marginRight="4dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:layout_alignParentBottom="true"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/productCountTextView"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="1"
|
|
||||||
android:includeFontPadding="false"
|
|
||||||
android:lineSpacingExtra="0dp"
|
|
||||||
android:textSize="24sp"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:layout_toRightOf="@+id/deccreaseProductCountImageView"
|
|
||||||
android:layout_toEndOf="@+id/deccreaseProductCountImageView"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:textColor="@color/black"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/increaseProductCountImageView"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:padding="4dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_toRightOf="@+id/productCountTextView"
|
|
||||||
android:layout_toEndOf="@+id/productCountTextView"
|
|
||||||
android:src="@drawable/ic_increase"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginLeft="4dp"
|
|
||||||
android:layout_marginStart="4dp" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0.5dp"
|
|
||||||
android:background="@color/black"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:layout_marginEnd="12dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/radioRecyclerHeaderTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="Size"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@color/black"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/radioRecyclerView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0.5dp"
|
|
||||||
android:background="@color/black"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:layout_marginEnd="12dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/checkboxRecyclerHeaderTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@color/black"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/checkboxRecyclerView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.v4.widget.NestedScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -7,7 +7,7 @@ buildscript {
|
|||||||
maven { url 'https://maven.fabric.io/public' }
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||||
classpath 'io.fabric.tools:gradle:1.+'
|
classpath 'io.fabric.tools:gradle:1.+'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Wed Feb 06 21:08:58 EET 2019
|
#Wed Jul 03 23:07:53 EET 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user