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;
import android.widget.TextView;

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;
    }

    private class PhotoHolder extends RecyclerView.ViewHolder {

        private TextView mTitleTextView;

        public PhotoHolder(View itemView) {
            super(itemView);
            mTitleTextView = (TextView) itemView;
        }

        public void bindGalleryItem(GalleryItem item) {
            mTitleTextView.setText(item.toString());
        }
    }
}

@@ -394,24 +394,79 @@
 .widget.
-TextView
+Gallery;%0Aimport android.widget.TextView;%0A%0Aimport java.util.List
 ;%0A%0Apubli
@@ -2078,11 +2078,770 @@
  %7D%0A    %7D
+%0A%0A    private class PhotoAdapter extends RecyclerView.Adapter%3CPhotoHolder%3E %7B%0A%0A        private List%3CGalleryItem%3E mGalleryItems;%0A%0A        public PhotoAdapter(List%3CGalleryItem%3E items) %7B%0A            mGalleryItems = items;%0A        %7D%0A%0A        @Override%0A        public PhotoHolder onCreateViewHolder(ViewGroup parent, int viewType) %7B%0A            TextView textView = new TextView(getActivity());%0A            return new PhotoHolder(textView);%0A        %7D%0A%0A        @Override%0A        public void onBindViewHolder(PhotoHolder holder, int position) %7B%0A            GalleryItem item = mGalleryItems.get(position);%0A            holder.bindGalleryItem(item);%0A        %7D%0A%0A        @Override%0A        public int getItemCount() %7B%0A            return mGalleryItems.size();%0A        %7D%0A    %7D
 %0A%7D%0A

Create Adapter for gallery