package com.bignerdranch.android.photogallery;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.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;

public class PhotoGalleryFragment extends Fragment {

    private static final String TAG = "PhotoGalleryFragment";

    private RecyclerView mPhotoRecyclerView;

    private class FetchItemsTasks extends AsyncTask<Void, Void, Void> {
        @Override protected Void doInBackground(Void... params) {
            new FlickrFetcher().fetchItems();
            return null;
        }
    }

    public static PhotoGalleryFragment newInstance() {

        Bundle args = new Bundle();

        PhotoGalleryFragment fragment = new PhotoGalleryFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRetainInstance(true);
        new FetchItemsTasks().execute();
    }

    @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_photo_gallery, container, false);

        mPhotoRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_photo_gallery_recycler_view);
        mPhotoRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));

        return view;
    }
}

@@ -371,16 +371,48 @@
 ewGroup;
+%0Aimport android.widget.TextView;
 %0A%0Apublic
@@ -1656,11 +1656,378 @@
 w;%0A    %7D
+%0A%0A    private class PhotoHolder extends RecyclerView.ViewHolder %7B%0A%0A        private TextView mTitleTextView;%0A%0A        public PhotoHolder(View itemView) %7B%0A            super(itemView);%0A            mTitleTextView = (TextView) itemView;%0A        %7D%0A%0A        public void bindGalleryItem(GalleryItem item) %7B%0A            mTitleTextView.setText(item.toString());%0A        %7D%0A    %7D
 %0A%7D%0A

Create ViewHolder for Gallery items