diff --git a/README.md b/README.md
index f4326ef..654777a 100644
--- a/README.md
+++ b/README.md
@@ -163,6 +163,10 @@ There are some operations you want to keep on running irrespective of which app
With API level 21, Google introduced Material Design. In this chapter we’ll look at **what Material Design is**, and how to make your apps fit in with it. We’ll start by introducing you to **card views** you can reuse across your app for a *consistent look and feel*. Then we’ll introduce you to the **recycler view**, the list view’s flexible friend. Along the way you’ll see how to **create your own adapters**, and how to completely change the look of a recycler view with *just two lines of code*.
+**Apps you'll build:**
+
+[BitsAndPizzas (one more time)](https://github.com/dogriffiths/HeadFirstAndroid/tree/master/chapter14/BitsAndPizzas)
+

## Appendix 1: ART–The Android Runtime
diff --git a/chapter14/BitsAndPizzas/.gitignore b/chapter14/BitsAndPizzas/.gitignore
new file mode 100644
index 0000000..9c4de58
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.gitignore
@@ -0,0 +1,7 @@
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
diff --git a/chapter14/BitsAndPizzas/.idea/.name b/chapter14/BitsAndPizzas/.idea/.name
new file mode 100644
index 0000000..e40a72c
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/.name
@@ -0,0 +1 @@
+BitsAndPizzas
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/.idea/compiler.xml b/chapter14/BitsAndPizzas/.idea/compiler.xml
new file mode 100644
index 0000000..9a8b7e5
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/.idea/copyright/profiles_settings.xml b/chapter14/BitsAndPizzas/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/.idea/gradle.xml b/chapter14/BitsAndPizzas/.idea/gradle.xml
new file mode 100644
index 0000000..8d2df47
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/.idea/misc.xml b/chapter14/BitsAndPizzas/.idea/misc.xml
new file mode 100644
index 0000000..aaaf922
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/misc.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/.idea/modules.xml b/chapter14/BitsAndPizzas/.idea/modules.xml
new file mode 100644
index 0000000..a7bf6e5
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/.idea/vcs.xml b/chapter14/BitsAndPizzas/.idea/vcs.xml
new file mode 100644
index 0000000..6564d52
--- /dev/null
+++ b/chapter14/BitsAndPizzas/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/BitsAndPizzas.iml b/chapter14/BitsAndPizzas/BitsAndPizzas.iml
new file mode 100644
index 0000000..592d909
--- /dev/null
+++ b/chapter14/BitsAndPizzas/BitsAndPizzas.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/app/.gitignore b/chapter14/BitsAndPizzas/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/chapter14/BitsAndPizzas/app/app.iml b/chapter14/BitsAndPizzas/app/app.iml
new file mode 100644
index 0000000..f507c5f
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/app.iml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/app/build.gradle b/chapter14/BitsAndPizzas/app/build.gradle
new file mode 100644
index 0000000..4dad3dd
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 21
+ buildToolsVersion "21.1.2"
+
+ defaultConfig {
+ applicationId "com.hfad.bitsandpizzas"
+ minSdkVersion 17
+ targetSdkVersion 21
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile 'com.android.support:appcompat-v7:21.0.+'
+ compile 'com.android.support:recyclerview-v7:21.0.+'
+ compile 'com.android.support:cardview-v7:21.0.+'
+}
diff --git a/chapter14/BitsAndPizzas/app/proguard-rules.pro b/chapter14/BitsAndPizzas/app/proguard-rules.pro
new file mode 100644
index 0000000..3e3c221
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/davidg/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/chapter14/BitsAndPizzas/app/src/androidTest/java/com/hfad/bitsandpizzas/ApplicationTest.java b/chapter14/BitsAndPizzas/app/src/androidTest/java/com/hfad/bitsandpizzas/ApplicationTest.java
new file mode 100644
index 0000000..f36b088
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/androidTest/java/com/hfad/bitsandpizzas/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * Testing Fundamentals
+ */
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/app/src/main/AndroidManifest.xml b/chapter14/BitsAndPizzas/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..166f559
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/AndroidManifest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/CaptionedImagesAdapter.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/CaptionedImagesAdapter.java
new file mode 100644
index 0000000..2c0a736
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/CaptionedImagesAdapter.java
@@ -0,0 +1,69 @@
+package com.hfad.bitsandpizzas;
+
+import android.graphics.drawable.Drawable;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.support.v7.widget.CardView;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+class CaptionedImagesAdapter extends RecyclerView.Adapter {
+
+ private String[] captions;
+ private int[] imageIds;
+ private Listener listener;
+
+ public static interface Listener {
+ public void onClick(int position);
+ }
+
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+ private CardView cardView;
+ public ViewHolder(CardView v) {
+ super(v);
+ cardView=v;
+ }
+ }
+
+ public CaptionedImagesAdapter(String[] captions, int[] imageIds){
+ this.captions = captions;
+ this.imageIds = imageIds;
+ }
+
+ public void setListener(Listener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public CaptionedImagesAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ CardView cv = (CardView) LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.card_captioned_image, parent, false);
+ return new ViewHolder(cv);
+ }
+
+ @Override
+ public void onBindViewHolder(ViewHolder holder, final int position) {
+ CardView cardView = holder.cardView;
+ ImageView imageView = (ImageView)cardView.findViewById(R.id.info_image);
+ Drawable drawable = cardView.getResources().getDrawable(imageIds[position]);
+ imageView.setImageDrawable(drawable);
+ imageView.setContentDescription(captions[position]);
+ TextView textView = (TextView)cardView.findViewById(R.id.info_text);
+ textView.setText(captions[position]);
+ cardView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(position);
+ }
+ }
+ });
+ }
+
+ @Override
+ public int getItemCount() {
+ return captions.length;
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/MainActivity.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/MainActivity.java
new file mode 100644
index 0000000..62fac42
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/MainActivity.java
@@ -0,0 +1,196 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.ShareActionProvider;
+
+public class MainActivity extends Activity {
+ private class DrawerItemClickListener implements ListView.OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ selectItem(position);
+ }
+ };
+
+ private ShareActionProvider shareActionProvider;
+ private String[] titles;
+ private ListView drawerList;
+ private DrawerLayout drawerLayout;
+ private ActionBarDrawerToggle drawerToggle;
+ private int currentPosition = 0;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ titles = getResources().getStringArray(R.array.titles);
+ drawerList = (ListView)findViewById(R.id.drawer);
+ drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ //Populate the ListView
+ drawerList.setAdapter(new ArrayAdapter(this,
+ android.R.layout.simple_list_item_activated_1, titles));
+ drawerList.setOnItemClickListener(new DrawerItemClickListener());
+ //Display the correct fragment.
+ if (savedInstanceState != null) {
+ currentPosition = savedInstanceState.getInt("position");
+ setActionBarTitle(currentPosition);
+ } else {
+ selectItem(0);
+ }
+ //Create the ActionBarDrawerToggle
+ drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
+ R.string.open_drawer, R.string.close_drawer) {
+ //Called when a drawer has settled in a completely closed state
+ @Override
+ public void onDrawerClosed(View view) {
+ super.onDrawerClosed(view);
+ invalidateOptionsMenu();
+ }
+ //Called when a drawer has settled in a completely open state.
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ invalidateOptionsMenu();
+ }
+ };
+ drawerLayout.setDrawerListener(drawerToggle);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActionBar().setHomeButtonEnabled(true);
+ getFragmentManager().addOnBackStackChangedListener(
+ new FragmentManager.OnBackStackChangedListener() {
+ public void onBackStackChanged() {
+ FragmentManager fragMan = getFragmentManager();
+ Fragment fragment = fragMan.findFragmentByTag("visible_fragment");
+ if (fragment instanceof TopFragment) {
+ currentPosition = 0;
+ }
+ if (fragment instanceof PizzaMaterialFragment) {
+ currentPosition = 1;
+ }
+ if (fragment instanceof PastaFragment) {
+ currentPosition = 2;
+ }
+ if (fragment instanceof StoresFragment) {
+ currentPosition = 3;
+ }
+ setActionBarTitle(currentPosition);
+ drawerList.setItemChecked(currentPosition, true);
+ }
+ }
+ );
+ }
+
+ private void selectItem(int position) {
+ // update the main content by replacing fragments
+ currentPosition = position;
+ Fragment fragment;
+ switch(position) {
+ case 1:
+ fragment = new PizzaMaterialFragment();
+ break;
+ case 2:
+ fragment = new PastaFragment();
+ break;
+ case 3:
+ fragment = new StoresFragment();
+ break;
+ default:
+ fragment = new TopFragment();
+ }
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ ft.replace(R.id.content_frame, fragment, "visible_fragment");
+ ft.addToBackStack(null);
+ ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
+ ft.commit();
+ //Set the action bar title
+ setActionBarTitle(position);
+ //Close drawer
+ drawerLayout.closeDrawer(drawerList);
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ // If the drawer is open, hide action items related to the content view
+ boolean drawerOpen = drawerLayout.isDrawerOpen(drawerList);
+ menu.findItem(R.id.action_share).setVisible(!drawerOpen);
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ drawerToggle.syncState();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ drawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt("position", currentPosition);
+ }
+
+ private void setActionBarTitle(int position) {
+ String title;
+ if (position == 0) {
+ title = getResources().getString(R.string.app_name);
+ } else {
+ title = titles[position];
+ }
+ getActionBar().setTitle(title);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ MenuItem menuItem = menu.findItem(R.id.action_share);
+ shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
+ setIntent("This is example text");
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ private void setIntent(String text) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, text);
+ shareActionProvider.setShareIntent(intent);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (drawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ switch (item.getItemId()) {
+ case R.id.action_create_order:
+ //Code to run when the Create Order item is clicked
+ Intent intent = new Intent(this, OrderActivity.class);
+ startActivity(intent);
+ return true;
+ case R.id.action_settings:
+ //Code to run when the settings item is clicked
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/OrderActivity.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/OrderActivity.java
new file mode 100644
index 0000000..4b23965
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/OrderActivity.java
@@ -0,0 +1,15 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.os.Bundle;
+
+public class OrderActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_order);
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PastaFragment.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PastaFragment.java
new file mode 100644
index 0000000..319d482
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PastaFragment.java
@@ -0,0 +1,22 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.ListFragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+
+public class PastaFragment extends ListFragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ ArrayAdapter adapter = new ArrayAdapter(
+ inflater.getContext(),
+ android.R.layout.simple_list_item_1,
+ getResources().getStringArray(R.array.pasta));
+ setListAdapter(adapter);
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/Pizza.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/Pizza.java
new file mode 100644
index 0000000..6f54122
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/Pizza.java
@@ -0,0 +1,24 @@
+package com.hfad.bitsandpizzas;
+
+public class Pizza {
+ private String name;
+ private int imageResourceId;
+
+ public static final Pizza[] pizzas = {
+ new Pizza("Diavolo", R.drawable.diavolo),
+ new Pizza("Funghi", R.drawable.funghi)
+ };
+
+ private Pizza(String name, int imageResourceId) {
+ this.name = name;
+ this.imageResourceId = imageResourceId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getImageResourceId() {
+ return imageResourceId;
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaDetailActivity.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaDetailActivity.java
new file mode 100644
index 0000000..28b1d55
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaDetailActivity.java
@@ -0,0 +1,63 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.ImageView;
+import android.widget.ShareActionProvider;
+import android.widget.TextView;
+
+public class PizzaDetailActivity extends Activity {
+
+ public static final String EXTRA_PIZZANO = "pizzaNo";
+ private ShareActionProvider shareActionProvider;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_pizza_detail);
+
+ //Enable the Up button
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ //Display details of the pizza
+ int pizzaNo = (Integer)getIntent().getExtras().get(EXTRA_PIZZANO);
+ String pizzaName = Pizza.pizzas[pizzaNo].getName();
+ TextView textView = (TextView)findViewById(R.id.pizza_text);
+ textView.setText(pizzaName);
+ int pizzaImage = Pizza.pizzas[pizzaNo].getImageResourceId();
+ ImageView imageView = (ImageView)findViewById(R.id.pizza_image);
+ imageView.setImageDrawable(getResources().getDrawable(pizzaImage));
+ imageView.setContentDescription(pizzaName);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+
+ //Share the name of the pizza
+ TextView textView = (TextView)findViewById(R.id.pizza_text);
+ CharSequence pizzaName = textView.getText();
+ MenuItem menuItem = menu.findItem(R.id.action_share);
+ shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, pizzaName);
+ shareActionProvider.setShareIntent(intent);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_create_order:
+ Intent intent = new Intent(this, OrderActivity.class);
+ startActivity(intent);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaFragment.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaFragment.java
new file mode 100644
index 0000000..ae7939a
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaFragment.java
@@ -0,0 +1,22 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.ListFragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+
+public class PizzaFragment extends ListFragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ ArrayAdapter adapter = new ArrayAdapter(
+ inflater.getContext(),
+ android.R.layout.simple_list_item_1,
+ getResources().getStringArray(R.array.pizzas));
+ setListAdapter(adapter);
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaMaterialFragment.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaMaterialFragment.java
new file mode 100644
index 0000000..e0ae660
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/PizzaMaterialFragment.java
@@ -0,0 +1,43 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.Fragment;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class PizzaMaterialFragment extends Fragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ RecyclerView pizzaRecycler = (RecyclerView)inflater.inflate(R.layout.fragment_pizza_material,
+ container, false);
+
+ String[] pizzaNames = new String[Pizza.pizzas.length];
+ for (int i = 0; i < pizzaNames.length; i++) {
+ pizzaNames[i] = Pizza.pizzas[i].getName();
+ }
+
+ int[] pizzaImages = new int[Pizza.pizzas.length];
+ for (int i = 0; i < pizzaImages.length; i++) {
+ pizzaImages[i] = Pizza.pizzas[i].getImageResourceId();
+ }
+
+ CaptionedImagesAdapter adapter = new CaptionedImagesAdapter(pizzaNames, pizzaImages);
+ pizzaRecycler.setAdapter(adapter);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
+ pizzaRecycler.setLayoutManager(layoutManager);
+ adapter.setListener(new CaptionedImagesAdapter.Listener() {
+ public void onClick(int position) {
+ Intent intent = new Intent(getActivity(), PizzaDetailActivity.class);
+ intent.putExtra(PizzaDetailActivity.EXTRA_PIZZANO, position);
+ getActivity().startActivity(intent);
+ }
+ });
+ return pizzaRecycler;
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/StoresFragment.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/StoresFragment.java
new file mode 100644
index 0000000..a8440ae
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/StoresFragment.java
@@ -0,0 +1,22 @@
+package com.hfad.bitsandpizzas;
+
+import android.app.ListFragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+
+public class StoresFragment extends ListFragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ ArrayAdapter adapter = new ArrayAdapter(
+ inflater.getContext(),
+ android.R.layout.simple_list_item_1,
+ getResources().getStringArray(R.array.stores));
+ setListAdapter(adapter);
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/TopFragment.java b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/TopFragment.java
new file mode 100644
index 0000000..3af0d8e
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/java/com/hfad/bitsandpizzas/TopFragment.java
@@ -0,0 +1,41 @@
+package com.hfad.bitsandpizzas;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.app.Fragment;
+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 android.widget.RelativeLayout;
+
+public class TopFragment extends Fragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ RelativeLayout layout = (RelativeLayout)inflater.inflate(R.layout.fragment_top, container, false);
+ RecyclerView pizzaRecycler = (RecyclerView)layout.findViewById(R.id.pizza_recycler);
+ String[] pizzaNames = new String[2];
+ for (int i = 0; i < 2; i++) {
+ pizzaNames[i] = Pizza.pizzas[i].getName();
+ }
+ int[] pizzaImages = new int[2];
+ for (int i = 0; i < 2; i++) {
+ pizzaImages[i] = Pizza.pizzas[i].getImageResourceId();
+ }
+ GridLayoutManager layoutManager = new GridLayoutManager(getActivity(),2);
+ pizzaRecycler.setLayoutManager(layoutManager);
+ CaptionedImagesAdapter adapter = new CaptionedImagesAdapter(pizzaNames, pizzaImages);
+ pizzaRecycler.setAdapter(adapter);
+ adapter.setListener(new CaptionedImagesAdapter.Listener() {
+ public void onClick(int position) {
+ Intent intent = new Intent(getActivity(), PizzaDetailActivity.class);
+ intent.putExtra(PizzaDetailActivity.EXTRA_PIZZANO, position);
+ getActivity().startActivity(intent);
+ }
+ });
+ return layout;
+ }
+}
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/drawable-hdpi/ic_action_new_event.png b/chapter14/BitsAndPizzas/app/src/main/res/drawable-hdpi/ic_action_new_event.png
new file mode 100644
index 0000000..5a5d558
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/drawable-hdpi/ic_action_new_event.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/drawable-mdpi/ic_action_new_event.png b/chapter14/BitsAndPizzas/app/src/main/res/drawable-mdpi/ic_action_new_event.png
new file mode 100644
index 0000000..e8b7e41
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/drawable-mdpi/ic_action_new_event.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/drawable-nodpi/diavolo.jpg b/chapter14/BitsAndPizzas/app/src/main/res/drawable-nodpi/diavolo.jpg
new file mode 100644
index 0000000..0d40004
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/drawable-nodpi/diavolo.jpg differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/drawable-nodpi/funghi.jpg b/chapter14/BitsAndPizzas/app/src/main/res/drawable-nodpi/funghi.jpg
new file mode 100644
index 0000000..3a392b7
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/drawable-nodpi/funghi.jpg differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/drawable-xhdpi/ic_action_new_event.png b/chapter14/BitsAndPizzas/app/src/main/res/drawable-xhdpi/ic_action_new_event.png
new file mode 100644
index 0000000..f2435cb
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/drawable-xhdpi/ic_action_new_event.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/drawable-xxhdpi/ic_action_new_event.png b/chapter14/BitsAndPizzas/app/src/main/res/drawable-xxhdpi/ic_action_new_event.png
new file mode 100644
index 0000000..ebd2410
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/drawable-xxhdpi/ic_action_new_event.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_main.xml b/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..99333f3
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,18 @@
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_order.xml b/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_order.xml
new file mode 100644
index 0000000..bc56ff5
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_order.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_pizza_detail.xml b/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_pizza_detail.xml
new file mode 100644
index 0000000..0207374
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/layout/activity_pizza_detail.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/layout/card_captioned_image.xml b/chapter14/BitsAndPizzas/app/src/main/res/layout/card_captioned_image.xml
new file mode 100644
index 0000000..617f69e
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/layout/card_captioned_image.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/layout/fragment_pizza_material.xml b/chapter14/BitsAndPizzas/app/src/main/res/layout/fragment_pizza_material.xml
new file mode 100644
index 0000000..265f139
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/layout/fragment_pizza_material.xml
@@ -0,0 +1,7 @@
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/layout/fragment_top.xml b/chapter14/BitsAndPizzas/app/src/main/res/layout/fragment_top.xml
new file mode 100644
index 0000000..bb34136
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/layout/fragment_top.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_main.xml b/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..2870660
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,22 @@
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_order.xml b/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_order.xml
new file mode 100644
index 0000000..fd5454a
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_order.xml
@@ -0,0 +1,7 @@
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_pizza_detail.xml b/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_pizza_detail.xml
new file mode 100644
index 0000000..4a797fd
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/menu/menu_pizza_detail.xml
@@ -0,0 +1,7 @@
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/mipmap-hdpi/ic_launcher.png b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/mipmap-mdpi/ic_launcher.png b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/chapter14/BitsAndPizzas/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/values-v21/styles.xml b/chapter14/BitsAndPizzas/app/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..be7431d
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/values-v21/styles.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/values-w820dp/dimens.xml b/chapter14/BitsAndPizzas/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+
+
+ 64dp
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/values/dimens.xml b/chapter14/BitsAndPizzas/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 16dp
+ 16dp
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/values/strings.xml b/chapter14/BitsAndPizzas/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..bbd7b5c
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/values/strings.xml
@@ -0,0 +1,36 @@
+
+ Bits And Pizzas
+
+ Hello world!
+ Settings
+ Create Order
+ Order Activity
+ Share
+
+
+ Hello blank fragment
+ Top fragment
+
+ Diavolo
+ Funghi
+
+
+ Spaghetti Bolognese
+ Lasagne
+
+
+ Cambridge
+ Sebastopol
+
+
+ Home
+ Pizzas
+ Pasta
+ Stores
+
+ Open drawer
+ Close drawer
+ Pizza Detail
+ We offer a range of freshly baked pizza and pasta
+ dishes. Why not try some?
+
diff --git a/chapter14/BitsAndPizzas/app/src/main/res/values/styles.xml b/chapter14/BitsAndPizzas/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..e0c5aae
--- /dev/null
+++ b/chapter14/BitsAndPizzas/app/src/main/res/values/styles.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/chapter14/BitsAndPizzas/build.gradle b/chapter14/BitsAndPizzas/build.gradle
new file mode 100644
index 0000000..d3ff69d
--- /dev/null
+++ b/chapter14/BitsAndPizzas/build.gradle
@@ -0,0 +1,19 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.1.0'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
diff --git a/chapter14/BitsAndPizzas/gradle.properties b/chapter14/BitsAndPizzas/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/chapter14/BitsAndPizzas/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/chapter14/BitsAndPizzas/gradle/wrapper/gradle-wrapper.jar b/chapter14/BitsAndPizzas/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/chapter14/BitsAndPizzas/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/chapter14/BitsAndPizzas/gradle/wrapper/gradle-wrapper.properties b/chapter14/BitsAndPizzas/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..0c71e76
--- /dev/null
+++ b/chapter14/BitsAndPizzas/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/chapter14/BitsAndPizzas/gradlew b/chapter14/BitsAndPizzas/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/chapter14/BitsAndPizzas/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/chapter14/BitsAndPizzas/gradlew.bat b/chapter14/BitsAndPizzas/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/chapter14/BitsAndPizzas/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/chapter14/BitsAndPizzas/settings.gradle b/chapter14/BitsAndPizzas/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/chapter14/BitsAndPizzas/settings.gradle
@@ -0,0 +1 @@
+include ':app'