package com.cwainner.chris.recipecentral;

import android.app.FragmentManager;
import android.content.Intent;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;

public class RecipesActivity extends AppCompatActivity {
    @Bind(R.id.recipesHeader) TextView recipesHeader;
    @Bind(R.id.recipeTypeView) TextView recipeTypeView;
    @Bind(R.id.recipeGrid) GridView recipeGrid;

    private String[] recipes = new String[] {"Brownies", "Nachos", "Alfredo", "Chili", "Banana Bread", "Burger", "Cheesecake", "Ice Cream"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recipes);
        ButterKnife.bind(this);

        RecipesArrayAdapter adapter = new RecipesArrayAdapter(this, android.R.layout.simple_list_item_1, recipes);
        recipeGrid.setAdapter(adapter);

        Intent intent = getIntent();
        String recipeType = intent.getStringExtra("recipeType");
        if(!recipeType.equals("")){
            recipeTypeView.setText("Recipe type: " + recipeType);
        }

        Typeface quicksandFont = Typeface.createFromAsset(getAssets(), "fonts/Quicksand-Bold.otf");
        recipesHeader.setTypeface(quicksandFont);

        FragmentManager fm = getFragmentManager();
        RecipeDetailFragment recipeDetailFragment = new RecipeDetailFragment();
        recipeDetailFragment.show(fm, "Sample Fragment");
    }
}

@@ -212,16 +212,77 @@
 Bundle;%0A
+import android.view.View;%0Aimport android.widget.AdapterView;%0A
 import a
@@ -336,16 +336,45 @@
 extView;
+%0Aimport android.widget.Toast;
 %0A%0Aimport
@@ -986,163 +986,8 @@
 );%0A%0A
-        RecipesArrayAdapter adapter = new RecipesArrayAdapter(this, android.R.layout.simple_list_item_1, recipes);%0A        recipeGrid.setAdapter(adapter);%0A
 %0A   
@@ -1210,151 +1210,381 @@
     
-Typeface quicksandFont = Typeface.createFromAsset(getAssets(), %22fonts/Quicksand-Bold.otf%22);%0A        recipesHeader.setTypeface(quicksandFont);%0A%0A
+recipeGrid.setAdapter(new RecipesArrayAdapter(this, android.R.layout.simple_list_item_1, recipes));%0A        recipeGrid.setOnItemClickListener(new AdapterView.OnItemClickListener()%7B%0A            @Override%0A            public void onItemClick(AdapterView%3C?%3E adapterView, View view, int i, long l)%7B%0A                String recipe = ((TextView)view).getText().toString();%0A        
     
@@ -1638,16 +1638,24 @@
         
+ 
+       
 RecipeDe
@@ -1714,24 +1714,32 @@
 Fragment();%0A
+        
         reci
@@ -1780,20 +1780,199 @@
 Fragment%22);%0A
+            %7D%0A        %7D);%0A%0A        Typeface quicksandFont = Typeface.createFromAsset(getAssets(), %22fonts/Quicksand-Bold.otf%22);%0A        recipesHeader.setTypeface(quicksandFont);%0A%0A%0A
     %7D%0A%7D%0A

Add fragment to on click listener for grid view