navigation drawer
This commit is contained in:
@@ -6,6 +6,9 @@ import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
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.widget.LinearLayout;
|
||||
@@ -13,13 +16,17 @@ import android.widget.TextView;
|
||||
|
||||
import com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.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;
|
||||
@@ -31,33 +38,22 @@ import ch.pizzalink.android.fragment.order.PizzaFragment;
|
||||
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;
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.drawerLayout) DrawerLayout drawerLayout;
|
||||
@BindView(R.id.navigationMenuRecyclerView) RecyclerView navigationMenuRecyclerView;
|
||||
@BindView(R.id.pizzalinkToolbar) PizzalinkToolbar pizzalinkToolbar;
|
||||
@BindView(R.id.bottomNavigationView) BottomNavigationViewEx bottomNavigationView;
|
||||
|
||||
@BindView(R.id.ownPizzaMenuItem) TextView ownPizzaMenuItem;
|
||||
@BindView(R.id.exstraKebapMenuItem) TextView exstraKebapMenuItem;
|
||||
@BindView(R.id.pizzaMenuItem) TextView pizzaMenuItem;
|
||||
@BindView(R.id.vorspeisenMenuItem) TextView vorspeisenMenuItem;
|
||||
@BindView(R.id.haussMenuItem) TextView haussMenuItem;
|
||||
@BindView(R.id.salatMenuItem) TextView salatMenuItem;
|
||||
@BindView(R.id.pastaMenuItem) TextView pastaMenuItem;
|
||||
@BindView(R.id.chickenMenuItem) TextView chickenMenuItem;
|
||||
@BindView(R.id.drinksMenuItem) TextView drinksMenuItem;
|
||||
@BindView(R.id.drinksLayout) LinearLayout drinksLayout;
|
||||
@BindView(R.id.roseDrinksMenuItem) TextView roseDrinksMenuItem;
|
||||
@BindView(R.id.rotweinDrinksMenuItem) TextView rotweinDrinksMenuItem;
|
||||
@BindView(R.id.spirituosenDrinksMenuItem) TextView spirituosenDrinksMenuItem;
|
||||
@BindView(R.id.weissweinDrinksMenuItem) TextView weissweinDrinksMenuItem;
|
||||
@BindView(R.id.beerDrinksMenuItem) TextView beerDrinksMenuItem;
|
||||
@BindView(R.id.dessertMenuItem) TextView dessertMenuItem;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private String currentFragmentName = "";
|
||||
private ArrayList<CategoryModel> categoryList = new ArrayList<>();
|
||||
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -67,24 +63,16 @@ public class MainActivity extends BaseActivity {
|
||||
initViews();
|
||||
}
|
||||
|
||||
@OnClick({R.id.ownPizzaMenuItem, R.id.exstraKebapMenuItem, R.id.pizzaMenuItem,
|
||||
R.id.vorspeisenMenuItem, R.id.haussMenuItem, R.id.salatMenuItem,
|
||||
R.id.pastaMenuItem, R.id.chickenMenuItem, R.id.drinksMenuItem,
|
||||
R.id.roseDrinksMenuItem, R.id.rotweinDrinksMenuItem, R.id.spirituosenDrinksMenuItem,
|
||||
R.id.weissweinDrinksMenuItem, R.id.beerDrinksMenuItem, R.id.dessertMenuItem})
|
||||
public void onClick(View view){
|
||||
selectMenuItem(view);
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
initNavigationDrawer();
|
||||
initBottomNavigationView();
|
||||
showStartScreen();
|
||||
initNavigationDrawer();
|
||||
}
|
||||
|
||||
private void showStartScreen(){
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, PizzaFragment.newInstance()).commit();
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(categoryList.get(0))).commit();
|
||||
currentFragmentName = PizzaFragment.FRAGMENT_NAME;
|
||||
}
|
||||
|
||||
@@ -103,7 +91,8 @@ public class MainActivity extends BaseActivity {
|
||||
case R.id.action_menu:
|
||||
if (currentFragmentName.equals(PizzaFragment.FRAGMENT_NAME))
|
||||
return true;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, PizzaFragment.newInstance()).commit();
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(categoryList.get(0))).commit();
|
||||
currentFragmentName = PizzaFragment.FRAGMENT_NAME;
|
||||
return true;
|
||||
|
||||
@@ -141,6 +130,9 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initNavigationDrawer(){
|
||||
|
||||
initNavigationMenuRecyclerView();
|
||||
|
||||
pizzalinkToolbar.getHamburgerIcon().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -150,9 +142,26 @@ public class MainActivity extends BaseActivity {
|
||||
openNavigationDrawer();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initNavigationMenuRecyclerView(){
|
||||
categoryList = SharedPrefsHelper.readCategoryList();
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
navigationMenuRecyclerView.setLayoutManager(layoutManager);
|
||||
navigationMenuRecyclerAdapter = new NavigationMenuRecyclerAdapter(categoryList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
|
||||
MenuFragment.newInstance(categoryList.get(position))).commit();
|
||||
currentFragmentName = OwnPizzaFragment.FRAGMENT_NAME;
|
||||
drawerLayout.closeDrawers();
|
||||
}
|
||||
});
|
||||
navigationMenuRecyclerView.setAdapter(navigationMenuRecyclerAdapter);
|
||||
}
|
||||
|
||||
|
||||
private void openNavigationDrawer(){
|
||||
drawerLayout.openDrawer(GravityCompat.START);
|
||||
}
|
||||
@@ -165,7 +174,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, OwnPizzaFragment.newInstance()).commit();
|
||||
currentFragmentName = OwnPizzaFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -174,7 +182,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, ExtraKebapFragment.newInstance()).commit();
|
||||
currentFragmentName = ExtraKebapFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -183,7 +190,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, PizzaFragment.newInstance()).commit();
|
||||
currentFragmentName = PizzaFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -192,7 +198,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, VorspeisenFragment.newInstance()).commit();
|
||||
currentFragmentName = VorspeisenFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -201,7 +206,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, HaussFragment.newInstance()).commit();
|
||||
currentFragmentName = HaussFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -210,7 +214,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, SalatFragment.newInstance()).commit();
|
||||
currentFragmentName = SalatFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -219,7 +222,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, PastaFragment.newInstance()).commit();
|
||||
currentFragmentName = PastaFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -228,7 +230,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, ChickenFragment.newInstance()).commit();
|
||||
currentFragmentName = ChickenFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
@@ -237,7 +238,6 @@ public class MainActivity extends BaseActivity {
|
||||
if (currentFragmentName.equals(DrinksFragment.FRAGMENT_NAME))
|
||||
break;
|
||||
*/
|
||||
drinksLayout.setVisibility(View.VISIBLE);
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, DrinksFragment.newInstance(view.getId())).commit();
|
||||
currentFragmentName = DrinksFragment.FRAGMENT_NAME;
|
||||
break;
|
||||
@@ -261,7 +261,6 @@ public class MainActivity extends BaseActivity {
|
||||
break;
|
||||
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, DessertFragment.newInstance()).commit();
|
||||
currentFragmentName = DessertFragment.FRAGMENT_NAME;
|
||||
drinksLayout.setVisibility(View.GONE);
|
||||
drawerLayout.closeDrawers();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SplashActivity extends BaseActivity {
|
||||
refreshCustomerToken();
|
||||
}
|
||||
else
|
||||
openActivity(WelcomeActivity.class);
|
||||
openActivity(LoginActivity.class);
|
||||
}
|
||||
|
||||
private void openActivity(final Class<?> cls){
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
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.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.CategoryModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 02/10/2017.
|
||||
*/
|
||||
|
||||
|
||||
public class NavigationMenuRecyclerAdapter extends RecyclerView.Adapter<NavigationMenuRecyclerAdapter.ViewHolder> {
|
||||
|
||||
private ArrayList<CategoryModel> categoryList;
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
@BindView(R.id.categoryNameItem) TextView categoryNameItem;
|
||||
|
||||
public ViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public NavigationMenuRecyclerAdapter(ArrayList<CategoryModel> categoryList, RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.categoryList = categoryList;
|
||||
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigationMenuRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_category, viewGroup, false);
|
||||
return new NavigationMenuRecyclerAdapter.ViewHolder(root, recyclerItemClickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(NavigationMenuRecyclerAdapter.ViewHolder holder, int position) {
|
||||
holder.categoryNameItem.setText(categoryList.get(position).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryList.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public class NavigationMenuRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private final int HOLDER_CATEGORY = 0;
|
||||
private final int HOLDER_SPACE = 1;
|
||||
|
||||
private ArrayList<CategoryModel> categoryList;
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
|
||||
public static class CategoryViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.categoryNameItem) TextView categoryNameItem;
|
||||
|
||||
public CategoryViewHolder(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 == categoryList.size())
|
||||
return HOLDER_SPACE;
|
||||
return HOLDER_CATEGORY;
|
||||
}
|
||||
|
||||
public NavigationMenuRecyclerAdapter(ArrayList<CategoryModel> categoryList,
|
||||
RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.categoryList = categoryList;
|
||||
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_CATEGORY:
|
||||
view = inflater.inflate(R.layout.row_category, viewGroup, false);
|
||||
viewHolder = new CategoryViewHolder(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_category, viewGroup, false);
|
||||
viewHolder = new CategoryViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
}
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
switch (holder.getItemViewType()){
|
||||
case HOLDER_CATEGORY :
|
||||
CategoryViewHolder categoryViewHolder = (CategoryViewHolder) holder;
|
||||
categoryViewHolder.categoryNameItem.setText(categoryList.get(position).getName());
|
||||
break;
|
||||
case HOLDER_SPACE :
|
||||
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryList.size() + 1 ;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
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;
|
||||
import android.view.View;
|
||||
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.fragment.order.OrderBaseFragment;
|
||||
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.view.GridSpacesItemDecoration;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 02/10/2017.
|
||||
*/
|
||||
|
||||
public class MenuFragment extends OrderBaseFragment {
|
||||
|
||||
@BindView(R.id.pizzaRecyclerView) RecyclerView pizzaRecyclerView;
|
||||
|
||||
public static final String FRAGMENT_NAME = "menuFragment";
|
||||
private ArrayList<PizzaModel> pizzaList = new ArrayList<>();
|
||||
private PizzaRecyclerAdapter pizzaRecyclerAdapter;
|
||||
private CategoryModel categoryModel;
|
||||
|
||||
public MenuFragment() {}
|
||||
|
||||
public static MenuFragment newInstance(CategoryModel categoryModel) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("categoryModel", categoryModel);
|
||||
MenuFragment fragment = new MenuFragment();
|
||||
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_menu, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
getDataFromArguments();
|
||||
initViews();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void getDataFromArguments(){
|
||||
categoryModel = (CategoryModel) getArguments().getSerializable("categoryModel");
|
||||
}
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
|
||||
}
|
||||
});
|
||||
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,13 +3,14 @@ package ch.pizzalink.android.model;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 26/09/2017.
|
||||
*/
|
||||
|
||||
public class CategoryModel {
|
||||
public class CategoryModel implements Serializable{
|
||||
|
||||
@Expose
|
||||
@SerializedName("category_id")
|
||||
|
||||
@@ -29,7 +29,12 @@
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"/>
|
||||
|
||||
<include layout="@layout/layout_navigation_drawer"/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/navigationMenuRecyclerView"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:background="@color/navigation_drawer_background"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
||||
|
||||
8
app/src/main/res/layout/fragment_menu.xml
Normal file
8
app/src/main/res/layout/fragment_menu.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?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"/>
|
||||
10
app/src/main/res/layout/row_category.xml
Normal file
10
app/src/main/res/layout/row_category.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/categoryNameItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:padding="20dp"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
Reference in New Issue
Block a user