// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListActivity.java
// public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener {
// 
//     private static final String EXTRA_TOOL_TYPE = "com.iangclifton.woodworkingtools.TOOL_TYPE";
// 
//     private ToolType mToolType;
//     private ViewPager mViewPager;
// 
//     public static void startActivity(Activity activity, ToolType toolType, Bundle activityOptions) {
//         final Intent intent = new Intent(activity, ToolListActivity.class);
//         intent.putExtra(EXTRA_TOOL_TYPE, toolType);
//         ActivityCompat.startActivity(activity, intent, activityOptions);
//     }
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_tool_list);
// 
//         final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//         setSupportActionBar(toolbar);
//         getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// 
//         mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE);
//         if (mToolType == null) {
//             throw new IllegalStateException("ToolType not available as extra; use startActivity");
//         }
//         setTitle(mToolType.getToolNameResourceId());
// 
//         // Set up tabs
//         mViewPager = (ViewPager) findViewById(R.id.viewpager);
//         final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
//         final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType);
//         tabLayout.setTabsFromPagerAdapter(toolPagerAdapter);
//         mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
//         mViewPager.setAdapter(toolPagerAdapter);
//         tabLayout.setOnTabSelectedListener(this);
// 
//         // Handle animation from previous activity
//         postponeEnterTransition();
//         mViewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
//             @Override
//             public boolean onPreDraw() {
//                 mViewPager.getViewTreeObserver().removeOnPreDrawListener(this);
//                 startPostponedEnterTransition();
//                 return true;
//             }
//         });
// 
//         setEnterSharedElementCallback(new SharedElementCallback() {
//             @Override
//             public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
//                 if (mViewPager.getCurrentItem() != 0) {
//                     // Not displaying the about page, which has the hero image
//                     names.clear();
//                     sharedElements.clear();
//                 }
//             }
//         });
// 
// 
//     }
// 
// 
//     @Override
//     public void onTabSelected(TabLayout.Tab tab) {
//         mViewPager.setCurrentItem(tab.getPosition());
//     }
// 
//     @Override
//     public void onTabUnselected(TabLayout.Tab tab) {
// 
//     }
// 
//     @Override
//     public void onTabReselected(TabLayout.Tab tab) {
// 
//     }
// }


import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import com.iangclifton.woodworkingtools.toollist.ToolListActivity;
package com.iangclifton.woodworkingtools;




/**
 * Fragment displaying a GridView of tool types.
 *
 * @author Ian G. Clifton
 */
public class ToolGridFragment extends Fragment implements AdapterView.OnItemClickListener {

    private ToolGridAdapter mToolGridAdapter;

// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListActivity.java
// public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener {
// 
//     private static final String EXTRA_TOOL_TYPE = "com.iangclifton.woodworkingtools.TOOL_TYPE";
// 
//     private ToolType mToolType;
//     private ViewPager mViewPager;
// 
//     public static void startActivity(Activity activity, ToolType toolType, Bundle activityOptions) {
//         final Intent intent = new Intent(activity, ToolListActivity.class);
//         intent.putExtra(EXTRA_TOOL_TYPE, toolType);
//         ActivityCompat.startActivity(activity, intent, activityOptions);
//     }
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_tool_list);
// 
//         final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//         setSupportActionBar(toolbar);
//         getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// 
//         mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE);
//         if (mToolType == null) {
//             throw new IllegalStateException("ToolType not available as extra; use startActivity");
//         }
//         setTitle(mToolType.getToolNameResourceId());
// 
//         // Set up tabs
//         mViewPager = (ViewPager) findViewById(R.id.viewpager);
//         final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
//         final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType);
//         tabLayout.setTabsFromPagerAdapter(toolPagerAdapter);
//         mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
//         mViewPager.setAdapter(toolPagerAdapter);
//         tabLayout.setOnTabSelectedListener(this);
// 
//         // Handle animation from previous activity
//         postponeEnterTransition();
//         mViewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
//             @Override
//             public boolean onPreDraw() {
//                 mViewPager.getViewTreeObserver().removeOnPreDrawListener(this);
//                 startPostponedEnterTransition();
//                 return true;
//             }
//         });
// 
//         setEnterSharedElementCallback(new SharedElementCallback() {
//             @Override
//             public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
//                 if (mViewPager.getCurrentItem() != 0) {
//                     // Not displaying the about page, which has the hero image
//                     names.clear();
//                     sharedElements.clear();
//                 }
//             }
//         });
// 
// 
//     }
// 
// 
//     @Override
//     public void onTabSelected(TabLayout.Tab tab) {
//         mViewPager.setCurrentItem(tab.getPosition());
//     }
// 
//     @Override
//     public void onTabUnselected(TabLayout.Tab tab) {
// 
//     }
// 
//     @Override
//     public void onTabReselected(TabLayout.Tab tab) {
// 
//     }
// }


// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolGridFragment.java
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import com.iangclifton.woodworkingtools.toollist.ToolListActivity;

package com.iangclifton.woodworkingtools;




/**
 * Fragment displaying a GridView of tool types.
 *
 * @author Ian G. Clifton
 */
public class ToolGridFragment extends Fragment implements AdapterView.OnItemClickListener {

    private ToolGridAdapter mToolGridAdapter;

    public ToolGridFragment() {