menus
This commit is contained in:
@@ -8,14 +8,9 @@ import android.support.v4.widget.DrawerLayout;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx;
|
||||
|
||||
@@ -24,26 +19,17 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.adapter.recycler.NavigationMenuRecyclerAdapter;
|
||||
import ch.pizzalink.android.api.ApiConstants;
|
||||
import ch.pizzalink.android.fragment.CartFragment;
|
||||
import ch.pizzalink.android.fragment.InfoFragment;
|
||||
import ch.pizzalink.android.fragment.HistoryFragment;
|
||||
import ch.pizzalink.android.fragment.MenuFragment;
|
||||
import ch.pizzalink.android.fragment.order.ChickenFragment;
|
||||
import ch.pizzalink.android.fragment.order.DessertFragment;
|
||||
import ch.pizzalink.android.fragment.order.DrinksFragment;
|
||||
import ch.pizzalink.android.fragment.order.ExtraKebapFragment;
|
||||
import ch.pizzalink.android.fragment.order.HaussFragment;
|
||||
import ch.pizzalink.android.fragment.order.OwnPizzaFragment;
|
||||
import ch.pizzalink.android.fragment.order.PastaFragment;
|
||||
import ch.pizzalink.android.fragment.order.PizzaFragment;
|
||||
import ch.pizzalink.android.fragment.order.EkstraKebapFragment;
|
||||
import ch.pizzalink.android.fragment.order.ProductFragment;
|
||||
import ch.pizzalink.android.fragment.ProfileFragment;
|
||||
import ch.pizzalink.android.fragment.order.SalatFragment;
|
||||
import ch.pizzalink.android.fragment.order.VorspeisenFragment;
|
||||
import ch.pizzalink.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.CategoryModel;
|
||||
import ch.pizzalink.android.view.PizzalinkToolbar;
|
||||
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionParameters;
|
||||
@@ -59,6 +45,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private String currentFragmentName = "";
|
||||
private int currentCategoryId = -1;
|
||||
private ArrayList<CategoryModel> categoryList = new ArrayList<>();
|
||||
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
|
||||
|
||||
@@ -80,9 +67,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private void showStartScreen(){
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(categoryList.get(0))).commit();
|
||||
currentFragmentName = PizzaFragment.FRAGMENT_NAME;
|
||||
openProductsScreen(categoryList.get(2));
|
||||
}
|
||||
|
||||
private void initBottomNavigationView(){
|
||||
@@ -98,11 +83,11 @@ public class MainActivity extends BaseActivity {
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()){
|
||||
case R.id.action_menu:
|
||||
if (currentFragmentName.equals(PizzaFragment.FRAGMENT_NAME))
|
||||
if (currentFragmentName.equals(MenuFragment.FRAGMENT_NAME))
|
||||
return true;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(categoryList.get(0))).commit();
|
||||
currentFragmentName = PizzaFragment.FRAGMENT_NAME;
|
||||
MenuFragment.newInstance(categoryList.get(2))).commit();
|
||||
currentFragmentName = MenuFragment.FRAGMENT_NAME;
|
||||
return true;
|
||||
|
||||
case R.id.action_cart:
|
||||
@@ -110,6 +95,7 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, CartFragment.newInstance()).commit();
|
||||
currentFragmentName = CartFragment.FRAGMENT_NAME;
|
||||
currentCategoryId = -1;
|
||||
return true;
|
||||
|
||||
case R.id.action_history:
|
||||
@@ -117,6 +103,7 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, HistoryFragment.newInstance()).commit();
|
||||
currentFragmentName = HistoryFragment.FRAGMENT_NAME;
|
||||
currentCategoryId = -1;
|
||||
return true;
|
||||
|
||||
case R.id.action_profile:
|
||||
@@ -124,6 +111,7 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, ProfileFragment.newInstance()).commit();
|
||||
currentFragmentName = ProfileFragment.FRAGMENT_NAME;
|
||||
currentCategoryId = -1;
|
||||
return true;
|
||||
|
||||
case R.id.action_info:
|
||||
@@ -131,6 +119,7 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, InfoFragment.newInstance()).commit();
|
||||
currentFragmentName = InfoFragment.FRAGMENT_NAME;
|
||||
currentCategoryId = -1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -157,106 +146,6 @@ public class MainActivity extends BaseActivity {
|
||||
drawerLayout.openDrawer(GravityCompat.START);
|
||||
}
|
||||
|
||||
private void selectMenuItem(View view){
|
||||
//drawerLayout.closeDrawers();
|
||||
switch (view.getId()){
|
||||
case R.id.ownPizzaMenuItem:
|
||||
if (currentFragmentName.equals(OwnPizzaFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, OwnPizzaFragment.newInstance()).commit();
|
||||
currentFragmentName = OwnPizzaFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.exstraKebapMenuItem:
|
||||
if (currentFragmentName.equals(ExtraKebapFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, ExtraKebapFragment.newInstance()).commit();
|
||||
currentFragmentName = ExtraKebapFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.pizzaMenuItem:
|
||||
if (currentFragmentName.equals(PizzaFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, PizzaFragment.newInstance()).commit();
|
||||
currentFragmentName = PizzaFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.vorspeisenMenuItem:
|
||||
if (currentFragmentName.equals(VorspeisenFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, VorspeisenFragment.newInstance()).commit();
|
||||
currentFragmentName = VorspeisenFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.haussMenuItem:
|
||||
if (currentFragmentName.equals(HaussFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, HaussFragment.newInstance()).commit();
|
||||
currentFragmentName = HaussFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.salatMenuItem:
|
||||
if (currentFragmentName.equals(SalatFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, SalatFragment.newInstance()).commit();
|
||||
currentFragmentName = SalatFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.pastaMenuItem:
|
||||
if (currentFragmentName.equals(PastaFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, PastaFragment.newInstance()).commit();
|
||||
currentFragmentName = PastaFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.chickenMenuItem:
|
||||
if (currentFragmentName.equals(ChickenFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, ChickenFragment.newInstance()).commit();
|
||||
currentFragmentName = ChickenFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.drinksMenuItem:
|
||||
/*
|
||||
if (currentFragmentName.equals(DrinksFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
*/
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, DrinksFragment.newInstance(view.getId())).commit();
|
||||
currentFragmentName = DrinksFragment.FRAGMENT_NAME;
|
||||
break;
|
||||
|
||||
case R.id.roseDrinksMenuItem:
|
||||
case R.id.rotweinDrinksMenuItem:
|
||||
case R.id.spirituosenDrinksMenuItem:
|
||||
case R.id.weissweinDrinksMenuItem:
|
||||
case R.id.beerDrinksMenuItem:
|
||||
/*
|
||||
if (currentFragmentName.equals(DrinksFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
*/
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, DrinksFragment.newInstance(view.getId())).commit();
|
||||
currentFragmentName = DrinksFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
case R.id.dessertMenuItem:
|
||||
if (currentFragmentName.equals(DessertFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, DessertFragment.newInstance()).commit();
|
||||
currentFragmentName = DessertFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPizzalinkToolbarFields(boolean showHamburgerIcon, String title){
|
||||
pizzalinkToolbar.setHamburgerIconVisibility(showHamburgerIcon);
|
||||
pizzalinkToolbar.setTitle(title);
|
||||
@@ -312,10 +201,7 @@ public class MainActivity extends BaseActivity {
|
||||
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(list.get(position))).commit();
|
||||
currentFragmentName = OwnPizzaFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
openProductsScreen(categoryList.get(pstn));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -332,10 +218,7 @@ public class MainActivity extends BaseActivity {
|
||||
headerHolder.rootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(categoryList.get(pstn))).commit();
|
||||
currentFragmentName = OwnPizzaFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
openProductsScreen(categoryList.get(pstn));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -364,4 +247,35 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void openProductsScreen(CategoryModel clickedCategoryModel){
|
||||
|
||||
drawerLayout.closeDrawers();
|
||||
|
||||
if(clickedCategoryModel.isProduct()){
|
||||
|
||||
if(currentFragmentName.equals(ProductFragment.FRAGMENT_NAME) &&
|
||||
currentCategoryId == clickedCategoryModel.getId())
|
||||
return;
|
||||
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
ProductFragment.newInstance(clickedCategoryModel)).commit();
|
||||
currentFragmentName = ProductFragment.FRAGMENT_NAME;
|
||||
currentCategoryId = clickedCategoryModel.getId();
|
||||
}
|
||||
else {
|
||||
|
||||
if(currentFragmentName.equals(MenuFragment.FRAGMENT_NAME) &&
|
||||
currentCategoryId == clickedCategoryModel.getId())
|
||||
return;
|
||||
|
||||
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(clickedCategoryModel)).commit();
|
||||
currentFragmentName = MenuFragment.FRAGMENT_NAME;
|
||||
currentCategoryId = clickedCategoryModel.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.CartProductModel;
|
||||
import ch.pizzalink.android.model.cart.CartProductModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 05/10/2017.
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package ch.pizzalink.android.adapter.recycler;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.helper.ImageLoadHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.menu.MenuProductModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 20/09/2017.
|
||||
*/
|
||||
|
||||
public class MenuProductRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private final int HOLDER_MENU_PRODUCT = 0;
|
||||
private final int HOLDER_SPACE = 1;
|
||||
|
||||
private ArrayList<MenuProductModel> menuProductList = new ArrayList<>();
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
|
||||
public static class MenuProductViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.productNameTextView) TextView productNameTextView;
|
||||
@BindView(R.id.productImageView) ImageView productImageView;
|
||||
@BindView(R.id.productIngredientsLayout) RelativeLayout productIngredientsLayout;
|
||||
@BindView(R.id.productIngredientsTextView) TextView productIngredientsTextView;
|
||||
@BindView(R.id.productPriceTextView) TextView productPriceTextView;
|
||||
|
||||
@BindString(R.string.chf) String chfText;
|
||||
|
||||
public MenuProductViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
|
||||
public SpaceViewHolder(final View view) {
|
||||
super(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if(position == menuProductList.size())
|
||||
return HOLDER_SPACE;
|
||||
return HOLDER_MENU_PRODUCT;
|
||||
}
|
||||
|
||||
public MenuProductRecyclerAdapter(ArrayList<MenuProductModel> menuProductList,
|
||||
RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.menuProductList = menuProductList;
|
||||
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
|
||||
RecyclerView.ViewHolder viewHolder;
|
||||
View view;
|
||||
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
|
||||
|
||||
switch (viewType){
|
||||
|
||||
case HOLDER_MENU_PRODUCT:
|
||||
view = inflater.inflate(R.layout.row_menu_product, viewGroup, false);
|
||||
viewHolder = new MenuProductViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE:
|
||||
view = inflater.inflate(R.layout.row_space, viewGroup, false);
|
||||
viewHolder = new SpaceViewHolder(view);
|
||||
break;
|
||||
|
||||
default:
|
||||
view = inflater.inflate(R.layout.row_menu_product, viewGroup, false);
|
||||
viewHolder = new MenuProductViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
}
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
|
||||
switch (holder.getItemViewType()){
|
||||
case HOLDER_MENU_PRODUCT :
|
||||
MenuProductViewHolder menuProductViewHolder = (MenuProductViewHolder) holder;
|
||||
ImageLoadHelper.loadImage(menuProductViewHolder.productImageView, menuProductList.get(position).getImageURL());
|
||||
menuProductViewHolder.productNameTextView.setText(menuProductList.get(position).getName());
|
||||
menuProductViewHolder.productPriceTextView.setText(
|
||||
menuProductViewHolder.chfText + " " + menuProductList.get(position).getPrice());
|
||||
if(menuProductList.get(position).isDescriptionAvailable()){
|
||||
menuProductViewHolder.productIngredientsLayout.setVisibility(View.VISIBLE);
|
||||
menuProductViewHolder.productIngredientsTextView.setText(menuProductList.get(position).getDescription());
|
||||
}
|
||||
else
|
||||
menuProductViewHolder.productIngredientsLayout.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE :
|
||||
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return menuProductList.size() + 1 ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,8 @@ import java.util.ArrayList;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.helper.ImageLoadHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
import ch.pizzalink.android.model.PizzaModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 04/10/2017.
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
package ch.pizzalink.android.adapter.recycler;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindDrawable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.BindViews;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.helper.ImageLoadHelper;
|
||||
import ch.pizzalink.android.interfaces.CheckBoxChangedListener;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.PizzaModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 20/09/2017.
|
||||
*/
|
||||
|
||||
public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private final int HOLDER_PIZZA = 0;
|
||||
private final int HOLDER_SPACE = 1;
|
||||
|
||||
private ArrayList<PizzaModel> pizzaList = new ArrayList<>();
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
|
||||
public static class PizzaViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.pizzaNameTextView) TextView pizzaNameTextView;
|
||||
@BindView(R.id.pizzaImageView) ImageView pizzaImageView;
|
||||
@BindView(R.id.pizzaIngredientsTextView) TextView pizzaIngredientsTextView;
|
||||
|
||||
public PizzaViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
|
||||
public SpaceViewHolder(final View view) {
|
||||
super(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
if(position == pizzaList.size())
|
||||
return HOLDER_SPACE;
|
||||
|
||||
return HOLDER_PIZZA;
|
||||
}
|
||||
|
||||
public PizzaRecyclerAdapter(ArrayList<PizzaModel> pizzaList,
|
||||
RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.pizzaList = pizzaList;
|
||||
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
|
||||
RecyclerView.ViewHolder viewHolder;
|
||||
View view;
|
||||
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
|
||||
|
||||
switch (viewType){
|
||||
|
||||
case HOLDER_PIZZA:
|
||||
view = inflater.inflate(R.layout.row_pizza, viewGroup, false);
|
||||
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE:
|
||||
view = inflater.inflate(R.layout.row_space, viewGroup, false);
|
||||
viewHolder = new SpaceViewHolder(view);
|
||||
break;
|
||||
|
||||
default:
|
||||
view = inflater.inflate(R.layout.row_pizza, viewGroup, false);
|
||||
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
}
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
|
||||
switch (holder.getItemViewType()){
|
||||
case HOLDER_PIZZA :
|
||||
PizzaViewHolder pizzaViewHolder = (PizzaViewHolder) holder;
|
||||
pizzaViewHolder.pizzaNameTextView.setText(pizzaList.get(position).getName());
|
||||
pizzaViewHolder.pizzaIngredientsTextView.setText(pizzaList.get(position).getIngredients());
|
||||
ImageLoadHelper.loadImage(pizzaViewHolder.pizzaImageView, pizzaList.get(position).getImageURL());
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE :
|
||||
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return pizzaList.size() + 1 ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,4 +4,8 @@ public class ApiConstants {
|
||||
public static final int API_READ_TIMEOUT = 30;
|
||||
public static final int API_CONNECT_TIMEOUT = 10;
|
||||
public static final String API_PATH = "http://www.pizzalink.ch/";
|
||||
public static final int CATEGORY_ID_WUNSCHPIZZA = 9999;
|
||||
public static final int CATEGORY_ID_EKSTRA_KEBAP = 9998;
|
||||
public static final int PRODUCT_ID_WUNSCHPIZZA = 56;
|
||||
public static final int PRODUCT_ID_EKSTRA_KEBAP = 91;
|
||||
}
|
||||
|
||||
@@ -12,5 +12,7 @@ public class ApiEndPoints {
|
||||
public static final String API_GET_ORDER_HISTORY = PREFIX + "getOrders" + SUFFIX;
|
||||
public static final String API_GET_CART_PRODUCTS = PREFIX + "getBasketProducts" + SUFFIX;
|
||||
public static final String API_GET_CLEAR_CART = PREFIX + "clearBasket" + SUFFIX;
|
||||
public static final String API_GET_PRODUCTS_BY_CATEGORY = PREFIX + "getProductsByCategory" + SUFFIX;
|
||||
public static final String API_GET_PRODUCT = PREFIX + "getProduct" + SUFFIX;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ch.pizzalink.android.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import ch.pizzalink.android.model.CartInfoModel;
|
||||
import ch.pizzalink.android.model.cart.CartInfoModel;
|
||||
import ch.pizzalink.android.model.CategoryModel;
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
import ch.pizzalink.android.model.UserModel;
|
||||
import ch.pizzalink.android.model.menu.MenuProductModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Field;
|
||||
@@ -56,6 +56,18 @@ public interface ApiInterface {
|
||||
@GET(ApiEndPoints.API_GET_CLEAR_CART)
|
||||
Call<ResponseObject> clearCart(@Query("token") String token);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_PRODUCTS_BY_CATEGORY)
|
||||
Call<ResponseArray<MenuProductModel>> getProductsByCategory(@Query("category_id") String categoryId);
|
||||
|
||||
/*
|
||||
@POST(ApiEndPoints.API_GET_PRODUCT)
|
||||
Call<ResponseObject<MenuProductModel>> getProductById(@Body HashMap<String, Object> body);
|
||||
*/
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_GET_PRODUCT)
|
||||
Call<ResponseArray<MenuProductModel>> getProductById(@Field("product_id") int productId);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ch.pizzalink.android.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@@ -28,9 +27,9 @@ import ch.pizzalink.android.api.ResponseObject;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SessionHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.CartInfoModel;
|
||||
import ch.pizzalink.android.model.CartProductModel;
|
||||
import ch.pizzalink.android.model.CartTotalModel;
|
||||
import ch.pizzalink.android.model.cart.CartInfoModel;
|
||||
import ch.pizzalink.android.model.cart.CartProductModel;
|
||||
import ch.pizzalink.android.model.cart.CartTotalModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
@@ -135,8 +135,6 @@ public class HistoryFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
private void fillAndNotifyOrderHistoryList(ArrayList<OrderModel> orderList){
|
||||
if(orderList == null)
|
||||
return;
|
||||
OrderModel.checkNull(orderList);
|
||||
orderHistoryList.clear();
|
||||
orderHistoryList.addAll(orderList);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ch.pizzalink.android.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -10,20 +9,24 @@ import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.adapter.recycler.PizzaRecyclerAdapter;
|
||||
import ch.pizzalink.android.adapter.recycler.MenuProductRecyclerAdapter;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.api.ResponseArray;
|
||||
import ch.pizzalink.android.fragment.order.OrderBaseFragment;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.DisplayHelper;
|
||||
import ch.pizzalink.android.interfaces.CheckBoxChangedListener;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.CategoryModel;
|
||||
import ch.pizzalink.android.model.PizzaModel;
|
||||
import ch.pizzalink.android.model.SizeModel;
|
||||
import ch.pizzalink.android.model.menu.MenuProductModel;
|
||||
import ch.pizzalink.android.view.GridSpacesItemDecoration;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 02/10/2017.
|
||||
@@ -31,11 +34,11 @@ import ch.pizzalink.android.view.GridSpacesItemDecoration;
|
||||
|
||||
public class MenuFragment extends OrderBaseFragment {
|
||||
|
||||
@BindView(R.id.pizzaRecyclerView) RecyclerView pizzaRecyclerView;
|
||||
@BindView(R.id.menuProductRecyclerView) RecyclerView menuProductRecyclerView;
|
||||
|
||||
public static final String FRAGMENT_NAME = "menuFragment";
|
||||
private ArrayList<PizzaModel> pizzaList = new ArrayList<>();
|
||||
private PizzaRecyclerAdapter pizzaRecyclerAdapter;
|
||||
private ArrayList<MenuProductModel> menuProductList = new ArrayList<>();
|
||||
private MenuProductRecyclerAdapter menuProductRecyclerAdapter;
|
||||
private CategoryModel categoryModel;
|
||||
|
||||
public MenuFragment() {}
|
||||
@@ -59,6 +62,7 @@ public class MenuFragment extends OrderBaseFragment {
|
||||
ButterKnife.bind(this, view);
|
||||
getDataFromArguments();
|
||||
initViews();
|
||||
getProductsByCategory();
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -69,101 +73,51 @@ public class MenuFragment extends OrderBaseFragment {
|
||||
private void initViews(){
|
||||
setPizzalinkToolbarFields(true, categoryModel.getName());
|
||||
initRecyclerView();
|
||||
fillPizzaList();
|
||||
}
|
||||
|
||||
private void initRecyclerView(){
|
||||
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
|
||||
pizzaRecyclerView.setLayoutManager(layoutManager);
|
||||
pizzaRecyclerAdapter = new PizzaRecyclerAdapter(pizzaList, new RecyclerItemClickListener() {
|
||||
menuProductRecyclerView.setLayoutManager(layoutManager);
|
||||
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(menuProductList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
|
||||
}
|
||||
});
|
||||
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
pizzaRecyclerView.setAdapter(pizzaRecyclerAdapter);
|
||||
menuProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
menuProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
|
||||
}
|
||||
|
||||
private void fillPizzaList(){
|
||||
|
||||
for(int i = 0; i < 12; i++){
|
||||
|
||||
PizzaModel pizzaModel = new PizzaModel();
|
||||
pizzaModel.setName("Pizza " + (i+1));
|
||||
pizzaModel.setIngredients("Mozzarella, Artischocken, Pilze, Peperoni, Oliven, Oregano");
|
||||
pizzaModel.setImageURL("http://www.pizzalink.ch/pizza/image/cache/catalog/pizza/2-220x220.png");
|
||||
|
||||
ArrayList<SizeModel> sizeList = new ArrayList<>();
|
||||
|
||||
if(i % 4 == 0){
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
SizeModel sizeModel2 = new SizeModel();
|
||||
sizeModel2.setName("Size 2");
|
||||
sizeModel2.setLength("Length 2");
|
||||
|
||||
SizeModel sizeModel3 = new SizeModel();
|
||||
sizeModel3.setName("Size 3");
|
||||
sizeModel3.setLength("Length 3");
|
||||
|
||||
SizeModel sizeModel4 = new SizeModel();
|
||||
sizeModel4.setName("Size 4");
|
||||
sizeModel4.setLength("Length 4");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
sizeList.add(sizeModel2);
|
||||
sizeList.add(sizeModel3);
|
||||
sizeList.add(sizeModel4);
|
||||
|
||||
} else if(i % 4 == 1){
|
||||
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
SizeModel sizeModel2 = new SizeModel();
|
||||
sizeModel2.setName("Size 2");
|
||||
sizeModel2.setLength("Length 2");
|
||||
|
||||
SizeModel sizeModel3 = new SizeModel();
|
||||
sizeModel3.setName("Size 3");
|
||||
sizeModel3.setLength("Length 3");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
sizeList.add(sizeModel2);
|
||||
sizeList.add(sizeModel3);
|
||||
|
||||
} else if(i % 4 == 2){
|
||||
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
SizeModel sizeModel2 = new SizeModel();
|
||||
sizeModel2.setName("Size 2");
|
||||
sizeModel2.setLength("Length 2");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
sizeList.add(sizeModel2);
|
||||
|
||||
} else {
|
||||
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
private void getProductsByCategory(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(categoryModel.getCategoryIdString());
|
||||
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body().getData() != null &&
|
||||
response.body().isSuccess())
|
||||
fillAndNotifyProductList(response.body().getData());
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
pizzaModel.setPizzaSizeList(sizeList);
|
||||
|
||||
pizzaList.add(pizzaModel);
|
||||
}
|
||||
pizzaRecyclerAdapter.notifyDataSetChanged();
|
||||
@Override
|
||||
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fillAndNotifyProductList(ArrayList<MenuProductModel> productList){
|
||||
MenuProductModel.checkNull(productList);
|
||||
menuProductList.clear();
|
||||
menuProductList.addAll(productList);
|
||||
menuProductRecyclerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@ import ch.pizzalink.android.R;
|
||||
* Created by cimenmus on 19/09/2017.
|
||||
*/
|
||||
|
||||
public class ExtraKebapFragment extends OrderBaseFragment {
|
||||
public class EkstraKebapFragment extends OrderBaseFragment {
|
||||
|
||||
@BindString(R.string.fragment_title_ekstra_kebap) String fragmentTitle;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "extraKebapFragment";
|
||||
public static final java.lang.String FRAGMENT_NAME = "eksraKebapFragment";
|
||||
|
||||
public ExtraKebapFragment() {}
|
||||
public EkstraKebapFragment() {}
|
||||
|
||||
public static ExtraKebapFragment newInstance() {
|
||||
return new ExtraKebapFragment();
|
||||
public static EkstraKebapFragment newInstance() {
|
||||
return new EkstraKebapFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,7 +32,7 @@ public class ExtraKebapFragment extends OrderBaseFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_extra_kebap, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_ekstra_kebap, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
initViews();
|
||||
return view;
|
||||
@@ -1,44 +0,0 @@
|
||||
package ch.pizzalink.android.fragment.order;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 19/09/2017.
|
||||
*/
|
||||
|
||||
public class OwnPizzaFragment extends OrderBaseFragment {
|
||||
|
||||
@BindString(R.string.fragment_title_create_own_pizza) String fragmentTitle;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "ownPizzaFragment";
|
||||
|
||||
public OwnPizzaFragment() {}
|
||||
|
||||
public static OwnPizzaFragment newInstance() {
|
||||
return new OwnPizzaFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_own_pizza, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
initViews();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
setPizzalinkToolbarFields(true, fragmentTitle);
|
||||
}
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
package ch.pizzalink.android.fragment.order;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.adapter.recycler.PizzaRecyclerAdapter;
|
||||
import ch.pizzalink.android.helper.DisplayHelper;
|
||||
import ch.pizzalink.android.interfaces.CheckBoxChangedListener;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.PizzaModel;
|
||||
import ch.pizzalink.android.model.SizeModel;
|
||||
import ch.pizzalink.android.view.GridSpacesItemDecoration;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 18/09/2017.
|
||||
*/
|
||||
|
||||
public class PizzaFragment extends OrderBaseFragment {
|
||||
|
||||
@BindView(R.id.pizzaRecyclerView) RecyclerView pizzaRecyclerView;
|
||||
|
||||
@BindString(R.string.fragment_title_pizza) String fragmentTitle;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "pizzaFragment";
|
||||
private ArrayList<PizzaModel> pizzaList = new ArrayList<>();
|
||||
private PizzaRecyclerAdapter pizzaRecyclerAdapter;
|
||||
|
||||
public PizzaFragment() {}
|
||||
|
||||
public static PizzaFragment newInstance() {
|
||||
return new PizzaFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_pizza, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
initViews();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
setPizzalinkToolbarFields(true, fragmentTitle);
|
||||
initRecyclerView();
|
||||
fillPizzaList();
|
||||
}
|
||||
|
||||
private void initRecyclerView(){
|
||||
|
||||
|
||||
RecyclerItemClickListener recyclerItemClickListener = new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
/*
|
||||
switch (view.getId()){
|
||||
case R.id.increasePizzaCountTextView:
|
||||
pizzaList.get(position).setCount(pizzaList.get(position).getCount() + 1);
|
||||
pizzaRecyclerAdapter.notifyItemChanged(position);
|
||||
break;
|
||||
case R.id.deccreasePizzaCountTextView:
|
||||
if(pizzaList.get(position).getCount() == 0)
|
||||
break;
|
||||
pizzaList.get(position).setCount(pizzaList.get(position).getCount() - 1);
|
||||
pizzaRecyclerAdapter.notifyItemChanged(position);
|
||||
break;
|
||||
default:
|
||||
for(int i = 0; i < pizzaList.size(); i++){
|
||||
if(i == position && !pizzaList.get(i).isExpanded())
|
||||
pizzaList.get(i).setExpanded(true);
|
||||
else
|
||||
pizzaList.get(i).setExpanded(false);
|
||||
}
|
||||
pizzaRecyclerAdapter.notifyDataSetChanged();
|
||||
pizzaRecyclerView.scrollToPosition(position);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
CheckBoxChangedListener checkBoxChangedListener = new CheckBoxChangedListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(AppCompatCheckBox appCompatCheckBox, int position) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
pizzaRecyclerAdapter = new PizzaRecyclerAdapter(pizzaList, recyclerItemClickListener);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
|
||||
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
pizzaRecyclerView.setLayoutManager(layoutManager);
|
||||
pizzaRecyclerView.setAdapter(pizzaRecyclerAdapter);
|
||||
}
|
||||
|
||||
private void fillPizzaList(){
|
||||
|
||||
for(int i = 0; i < 12; i++){
|
||||
|
||||
PizzaModel pizzaModel = new PizzaModel();
|
||||
pizzaModel.setName("Pizza " + (i+1));
|
||||
pizzaModel.setIngredients("Mozzarella, Artischocken, Pilze, Peperoni, Oliven, Oregano");
|
||||
pizzaModel.setImageURL("http://www.pizzalink.ch/pizza/image/cache/catalog/pizza/2-220x220.png");
|
||||
|
||||
ArrayList<SizeModel> sizeList = new ArrayList<>();
|
||||
|
||||
if(i % 4 == 0){
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
SizeModel sizeModel2 = new SizeModel();
|
||||
sizeModel2.setName("Size 2");
|
||||
sizeModel2.setLength("Length 2");
|
||||
|
||||
SizeModel sizeModel3 = new SizeModel();
|
||||
sizeModel3.setName("Size 3");
|
||||
sizeModel3.setLength("Length 3");
|
||||
|
||||
SizeModel sizeModel4 = new SizeModel();
|
||||
sizeModel4.setName("Size 4");
|
||||
sizeModel4.setLength("Length 4");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
sizeList.add(sizeModel2);
|
||||
sizeList.add(sizeModel3);
|
||||
sizeList.add(sizeModel4);
|
||||
|
||||
} else if(i % 4 == 1){
|
||||
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
SizeModel sizeModel2 = new SizeModel();
|
||||
sizeModel2.setName("Size 2");
|
||||
sizeModel2.setLength("Length 2");
|
||||
|
||||
SizeModel sizeModel3 = new SizeModel();
|
||||
sizeModel3.setName("Size 3");
|
||||
sizeModel3.setLength("Length 3");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
sizeList.add(sizeModel2);
|
||||
sizeList.add(sizeModel3);
|
||||
|
||||
} else if(i % 4 == 2){
|
||||
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
SizeModel sizeModel2 = new SizeModel();
|
||||
sizeModel2.setName("Size 2");
|
||||
sizeModel2.setLength("Length 2");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
sizeList.add(sizeModel2);
|
||||
|
||||
} else {
|
||||
|
||||
SizeModel sizeModel1 = new SizeModel();
|
||||
sizeModel1.setName("Size 1");
|
||||
sizeModel1.setLength("Length 1");
|
||||
|
||||
sizeList.add(sizeModel1);
|
||||
}
|
||||
|
||||
pizzaModel.setPizzaSizeList(sizeList);
|
||||
|
||||
pizzaList.add(pizzaModel);
|
||||
}
|
||||
pizzaRecyclerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package ch.pizzalink.android.fragment.order;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.api.ApiConstants;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.api.ResponseArray;
|
||||
import ch.pizzalink.android.api.ResponseObject;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.model.CategoryModel;
|
||||
import ch.pizzalink.android.model.menu.MenuProductModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 19/09/2017.
|
||||
*/
|
||||
|
||||
public class ProductFragment extends OrderBaseFragment {
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "productFragment";
|
||||
private CategoryModel categoryModel;
|
||||
|
||||
public ProductFragment() {}
|
||||
|
||||
public static ProductFragment newInstance(CategoryModel categoryModel) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("categoryModel", categoryModel);
|
||||
ProductFragment fragment = new ProductFragment();
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_product, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
getDataFromArguments();
|
||||
initViews();
|
||||
getProductById();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void getDataFromArguments(){
|
||||
categoryModel = (CategoryModel) getArguments().getSerializable("categoryModel");
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
setPizzalinkToolbarFields(true, categoryModel.getName());
|
||||
}
|
||||
|
||||
private void getProductById(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductById(getProductIdByCategory());
|
||||
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body().getData() != null &&
|
||||
response.body().isSuccess())
|
||||
setProductFields(response.body().getData());
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setProductFields(ArrayList<MenuProductModel> menuProductList){
|
||||
if(menuProductList == null || menuProductList.size() == 0)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
private int getProductIdByCategory(){
|
||||
if(categoryModel.getId() == ApiConstants.CATEGORY_ID_WUNSCHPIZZA)
|
||||
return ApiConstants.PRODUCT_ID_WUNSCHPIZZA;
|
||||
else
|
||||
return ApiConstants.PRODUCT_ID_EKSTRA_KEBAP;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.google.gson.annotations.SerializedName;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ch.pizzalink.android.api.ApiConstants;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 26/09/2017.
|
||||
*/
|
||||
@@ -41,6 +43,14 @@ public class CategoryModel implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
public String getCategoryIdString(){
|
||||
return String.valueOf(id);
|
||||
}
|
||||
|
||||
public boolean isProduct(){
|
||||
return id == ApiConstants.CATEGORY_ID_WUNSCHPIZZA || id == ApiConstants.CATEGORY_ID_EKSTRA_KEBAP;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -16,17 +16,9 @@ import ch.pizzalink.android.helper.DateTimeHelper;
|
||||
|
||||
public class CustomerTokenModel {
|
||||
|
||||
@Expose
|
||||
@SerializedName("customer_token")
|
||||
private String token;
|
||||
|
||||
@Expose
|
||||
@SerializedName("token_death_time")
|
||||
private String expiresIn;
|
||||
|
||||
@Expose
|
||||
@SerializedName("refresh_token")
|
||||
private String refreshToken;
|
||||
@Expose @SerializedName("customer_token") private String token;
|
||||
@Expose @SerializedName("token_death_time") private String expiresIn;
|
||||
@Expose @SerializedName("refresh_token") private String refreshToken;
|
||||
|
||||
public boolean isCustomerTokenAlive(){
|
||||
long millis7days = 86400000 * 7;
|
||||
|
||||
@@ -13,22 +13,10 @@ import ch.pizzalink.android.helper.DateTimeHelper;
|
||||
|
||||
public class OrderModel {
|
||||
|
||||
@Expose
|
||||
@SerializedName("order_id")
|
||||
private String id;
|
||||
|
||||
@Expose
|
||||
@SerializedName("date_added")
|
||||
private String createDate;
|
||||
|
||||
@Expose
|
||||
@SerializedName("currency_code")
|
||||
private String currencyCode;
|
||||
|
||||
@Expose
|
||||
@SerializedName("currency_value")
|
||||
private String currencyValue;
|
||||
|
||||
@Expose @SerializedName("order_id") private String id;
|
||||
@Expose @SerializedName("date_added") private String createDate;
|
||||
@Expose @SerializedName("currency_code") private String currencyCode;
|
||||
@Expose @SerializedName("currency_value") private String currencyValue;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String status;
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package ch.pizzalink.android.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 20/09/2017.
|
||||
*/
|
||||
|
||||
public class PizzaModel {
|
||||
|
||||
private String id, name, ingredients;
|
||||
private int count, isCartCount;
|
||||
private String imageURL;
|
||||
private double price;
|
||||
private boolean isInCart;
|
||||
private ArrayList<SizeModel> pizzaSizeList;
|
||||
private boolean isExpanded;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
public void setIngredients(String ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getIsCartCount() {
|
||||
return isCartCount;
|
||||
}
|
||||
|
||||
public void setIsCartCount(int isCartCount) {
|
||||
this.isCartCount = isCartCount;
|
||||
}
|
||||
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public boolean isInCart() {
|
||||
return isInCart;
|
||||
}
|
||||
|
||||
public void setInCart(boolean inCart) {
|
||||
isInCart = inCart;
|
||||
}
|
||||
|
||||
public ArrayList<SizeModel> getPizzaSizeList() {
|
||||
return pizzaSizeList;
|
||||
}
|
||||
|
||||
public void setPizzaSizeList(ArrayList<SizeModel> pizzaSizeList) {
|
||||
this.pizzaSizeList = pizzaSizeList;
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return isExpanded;
|
||||
}
|
||||
|
||||
public void setExpanded(boolean expanded) {
|
||||
isExpanded = expanded;
|
||||
}
|
||||
|
||||
public String getImageURL() {
|
||||
return imageURL;
|
||||
}
|
||||
|
||||
public void setImageURL(String imageURL) {
|
||||
this.imageURL = imageURL;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package ch.pizzalink.android.model;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 20/09/2017.
|
||||
*/
|
||||
|
||||
public class SizeModel {
|
||||
|
||||
private String name;
|
||||
private boolean isChecked;
|
||||
private String length;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class UserModel {
|
||||
|
||||
@Expose
|
||||
@SerializedName("customer_id")
|
||||
private String id;
|
||||
|
||||
@Expose @SerializedName("customer_id") private String id;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String email;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.pizzalink.android.model;
|
||||
package ch.pizzalink.android.model.cart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.pizzalink.android.model;
|
||||
package ch.pizzalink.android.model.cart;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@@ -22,7 +22,7 @@ public class CartProductModel {
|
||||
private String total;
|
||||
private boolean stock;
|
||||
private int reward;
|
||||
private ArrayList<ProductOptionModel> option;
|
||||
private ArrayList<CartProductOptionModel> option;
|
||||
|
||||
private void checkNull(){
|
||||
|
||||
@@ -51,8 +51,8 @@ public class CartProductModel {
|
||||
total = "";
|
||||
|
||||
if(option != null){
|
||||
for(ProductOptionModel productOptionModel : option){
|
||||
productOptionModel.checkNull();
|
||||
for(CartProductOptionModel cartProductOptionModel : option){
|
||||
cartProductOptionModel.checkNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,11 +143,11 @@ public class CartProductModel {
|
||||
this.reward = reward;
|
||||
}
|
||||
|
||||
public ArrayList<ProductOptionModel> getOption() {
|
||||
public ArrayList<CartProductOptionModel> getOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
public void setOption(ArrayList<ProductOptionModel> option) {
|
||||
public void setOption(ArrayList<CartProductOptionModel> option) {
|
||||
this.option = option;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.pizzalink.android.model;
|
||||
package ch.pizzalink.android.model.cart;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@@ -7,7 +7,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
* Created by cimenmus on 05/10/2017.
|
||||
*/
|
||||
|
||||
public class ProductOptionModel {
|
||||
public class CartProductOptionModel {
|
||||
|
||||
@Expose @SerializedName("product_option_id") private String id;
|
||||
@Expose @SerializedName("product_option_value_id") private String valueId;
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.pizzalink.android.model;
|
||||
package ch.pizzalink.android.model.cart;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 05/10/2017.
|
||||
@@ -0,0 +1,143 @@
|
||||
package ch.pizzalink.android.model.menu;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.model.cart.CartProductOptionModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 08/10/2017.
|
||||
*/
|
||||
|
||||
public class MenuProductModel {
|
||||
|
||||
@Expose @SerializedName("product_id") private String id;
|
||||
@Expose @SerializedName("thumb") private String imageURL;
|
||||
@Expose @SerializedName("special") private boolean isSpecial;
|
||||
@Expose @SerializedName("tax") private boolean isTax;
|
||||
@Expose @SerializedName("options") private ArrayList<MenuProductOptionModel> productOptionList;
|
||||
private String name;
|
||||
private String description;
|
||||
private String price;
|
||||
private String minimum;
|
||||
private int rating;
|
||||
|
||||
private void checkNull(){
|
||||
|
||||
if(id == null)
|
||||
id = "";
|
||||
|
||||
if(imageURL == null)
|
||||
imageURL = "empty";
|
||||
|
||||
if(name == null)
|
||||
name = "";
|
||||
|
||||
if(description == null)
|
||||
description = "";
|
||||
|
||||
if(price == null)
|
||||
price = "";
|
||||
|
||||
if(minimum == null)
|
||||
minimum = "";
|
||||
|
||||
if(productOptionList != null)
|
||||
MenuProductOptionModel.checkNull(productOptionList);
|
||||
}
|
||||
|
||||
public static void checkNull(ArrayList<MenuProductModel> menuProductModels){
|
||||
for(MenuProductModel menuProductModel : menuProductModels){
|
||||
menuProductModel.checkNull();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDescriptionAvailable(){
|
||||
return !description.isEmpty() &&
|
||||
!description.equals(BaseActivity.currentActivity.getString(R.string.empty_description));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getImageURL() {
|
||||
return imageURL;
|
||||
}
|
||||
|
||||
public void setImageURL(String imageURL) {
|
||||
this.imageURL = imageURL;
|
||||
}
|
||||
|
||||
public boolean isSpecial() {
|
||||
return isSpecial;
|
||||
}
|
||||
|
||||
public void setSpecial(boolean special) {
|
||||
isSpecial = special;
|
||||
}
|
||||
|
||||
public boolean isTax() {
|
||||
return isTax;
|
||||
}
|
||||
|
||||
public void setTax(boolean tax) {
|
||||
isTax = tax;
|
||||
}
|
||||
|
||||
public ArrayList<MenuProductOptionModel> getProductOptionList() {
|
||||
return productOptionList;
|
||||
}
|
||||
|
||||
public void setProductOptionList(ArrayList<MenuProductOptionModel> productOptionList) {
|
||||
this.productOptionList = productOptionList;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
public void setMinimum(String minimum) {
|
||||
this.minimum = minimum;
|
||||
}
|
||||
|
||||
public int getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(int rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package ch.pizzalink.android.model.menu;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 08/10/2017.
|
||||
*/
|
||||
|
||||
public class MenuProductOptionModel {
|
||||
|
||||
@Expose @SerializedName("product_option_id")
|
||||
private String productOptionId;
|
||||
|
||||
@Expose @SerializedName("option_id")
|
||||
private String optionId;
|
||||
|
||||
@Expose @SerializedName("product_option_value")
|
||||
private ArrayList<MenuProductOptionValueModel> optionValueModelList;
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
private String type;
|
||||
private String required;
|
||||
|
||||
private void checkNull(){
|
||||
|
||||
if(productOptionId == null)
|
||||
productOptionId = "";
|
||||
|
||||
if(optionId == null)
|
||||
optionId = "";
|
||||
|
||||
if(name == null)
|
||||
name = "";
|
||||
|
||||
if(value == null)
|
||||
value = "";
|
||||
|
||||
if(type == null)
|
||||
type = "";
|
||||
|
||||
if(required == null)
|
||||
required = "";
|
||||
|
||||
if(optionValueModelList != null){
|
||||
MenuProductOptionValueModel.checkNull(optionValueModelList);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkNull(ArrayList<MenuProductOptionModel> menuProductOptionModels){
|
||||
for(MenuProductOptionModel menuProductOptionModel : menuProductOptionModels){
|
||||
menuProductOptionModel.checkNull();
|
||||
}
|
||||
}
|
||||
|
||||
public String getProductOptionId() {
|
||||
return productOptionId;
|
||||
}
|
||||
|
||||
public void setProductOptionId(String productOptionId) {
|
||||
this.productOptionId = productOptionId;
|
||||
}
|
||||
|
||||
public String getOptionId() {
|
||||
return optionId;
|
||||
}
|
||||
|
||||
public void setOptionId(String optionId) {
|
||||
this.optionId = optionId;
|
||||
}
|
||||
|
||||
public ArrayList<MenuProductOptionValueModel> getOptionValueModelList() {
|
||||
return optionValueModelList;
|
||||
}
|
||||
|
||||
public void setOptionValueModelList(ArrayList<MenuProductOptionValueModel> optionValueModelList) {
|
||||
this.optionValueModelList = optionValueModelList;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(String required) {
|
||||
this.required = required;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package ch.pizzalink.android.model.menu;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 08/10/2017.
|
||||
*/
|
||||
|
||||
public class MenuProductOptionValueModel {
|
||||
|
||||
@Expose @SerializedName("product_option_value_id") private String productOptionValueId;
|
||||
@Expose @SerializedName("option_value_id") private String optionValueId;
|
||||
@Expose @SerializedName("image") private String imageURL;
|
||||
private String name;
|
||||
private String price;
|
||||
private String price_prefix;
|
||||
|
||||
private void checkNull(){
|
||||
|
||||
if(productOptionValueId == null)
|
||||
productOptionValueId = "";
|
||||
|
||||
if(optionValueId == null)
|
||||
optionValueId = "";
|
||||
|
||||
if(imageURL == null)
|
||||
imageURL = "empty";
|
||||
|
||||
if(name == null)
|
||||
name = "";
|
||||
|
||||
if(price == null)
|
||||
price = "";
|
||||
|
||||
if(price_prefix == null)
|
||||
price_prefix = "";
|
||||
}
|
||||
|
||||
public static void checkNull(ArrayList<MenuProductOptionValueModel> productOptionValueList){
|
||||
for(MenuProductOptionValueModel menuProductOptionValueModel : productOptionValueList){
|
||||
menuProductOptionValueModel.checkNull();
|
||||
}
|
||||
}
|
||||
|
||||
public String getProductOptionValueId() {
|
||||
return productOptionValueId;
|
||||
}
|
||||
|
||||
public void setProductOptionValueId(String productOptionValueId) {
|
||||
this.productOptionValueId = productOptionValueId;
|
||||
}
|
||||
|
||||
public String getOptionValueId() {
|
||||
return optionValueId;
|
||||
}
|
||||
|
||||
public void setOptionValueId(String optionValueId) {
|
||||
this.optionValueId = optionValueId;
|
||||
}
|
||||
|
||||
public String getImageURL() {
|
||||
return imageURL;
|
||||
}
|
||||
|
||||
public void setImageURL(String imageURL) {
|
||||
this.imageURL = imageURL;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getPrice_prefix() {
|
||||
return price_prefix;
|
||||
}
|
||||
|
||||
public void setPrice_prefix(String price_prefix) {
|
||||
this.price_prefix = price_prefix;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/pizzaRecyclerView"
|
||||
android:id="@+id/menuProductRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/actvity_default_background_color_1"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/pizzaRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/actvity_default_background_color_1"
|
||||
android:scrollbars="vertical"/>
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_height="24dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textColorHint="@color/row_pizza_ingredients_background"
|
||||
android:textColorHint="@color/row_product_ingredients_background"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
@@ -37,7 +37,7 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/row_pizza_ingredients_background"
|
||||
android:background="@color/row_product_ingredients_background"
|
||||
android:layout_marginTop="2dp"/>
|
||||
|
||||
|
||||
|
||||
74
app/src/main/res/layout/row_menu_product.xml
Normal file
74
app/src/main/res/layout/row_menu_product.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
app:cardCornerRadius="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productNameTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
android:text="Anatoliajefjefje\nwhufjechfuhefu"
|
||||
android:padding="8dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/productImageView"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginStart="12dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/productIngredientsLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="96dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productIngredientsTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/row_product_ingredients_background"
|
||||
android:padding="8dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:gravity="center"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="Mozzarella, Artischocken, Pilze, Peperoni, Oliven, Oregano"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productPriceTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/black"
|
||||
android:text="CHF 25.00"
|
||||
android:padding="16dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
app:cardCornerRadius="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pizzaNameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
android:paddingTop="12dp"
|
||||
android:text="Anatolia"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pizzaImageView"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginEnd="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pizzaIngredientsTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/row_pizza_ingredients_background"
|
||||
android:padding="12dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:gravity="center"
|
||||
android:text="Mozzarella, Artischocken, Pilze, Peperoni, Oliven, Oregano"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pizzaPriceTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/black"
|
||||
android:text="CHF 25.00"
|
||||
android:padding="16dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
@@ -10,7 +10,7 @@
|
||||
<color name="bottom_menu_selected_item">#EC1649</color>
|
||||
<color name="bottom_menu_unselected_item">#ffffff</color>
|
||||
<color name="navigation_drawer_background">#4C4B4A</color>
|
||||
<color name="row_pizza_ingredients_background">#EBECEC</color>
|
||||
<color name="row_product_ingredients_background">#EBECEC</color>
|
||||
|
||||
<!-- android:background="?android:colorBackground" -->
|
||||
<color name="actvity_default_background_color_1">#EEEEEE</color>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<string name="navigation_menu_item_dessert">DESSERT</string>
|
||||
<!-- NavigationMenu-->
|
||||
|
||||
<string name="fragment_title_create_own_pizza">Wunschpizza</string>
|
||||
<string name="fragment_title_wunschpizza">Wunschpizza</string>
|
||||
<string name="fragment_title_ekstra_kebap">Ekstra Kebap</string>
|
||||
<string name="fragment_title_pizza">Pizza</string>
|
||||
<string name="fragment_title_vorspeisen">Vorspeisen</string>
|
||||
@@ -110,5 +110,8 @@
|
||||
<string name="month_name_november">Nov.</string>
|
||||
<string name="month_name_december">Dec.</string>
|
||||
|
||||
<string name="chf">CHF</string>
|
||||
<string name="empty_description">..</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user