package gouravexample.popularmoviesstage1;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.squareup.picasso.OkHttpDownloader;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import gouravexample.popularmoviesstage1.data.MoviesContract;

/**
 * Created by GOURAV on 28-08-2016.
 */
public class MovieAdapter extends CursorAdapter{

    private Picasso mBuilder;



    public MovieAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
        mBuilder = new Picasso.Builder(context)
                .loggingEnabled(BuildConfig.DEBUG)
                .indicatorsEnabled(BuildConfig.DEBUG)
                .downloader(new OkHttpDownloader(context))
                .build();
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.grid_item_movie, parent, false);
        return view;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {

        LinearLayout ll = (LinearLayout)view;
        ImageView iv = (ImageView) ll.findViewById(R.id.image);

        mBuilder.load(cursor.getString(GridFragment.COL_POSTER_PATH)).into(iv);
    }
}

@@ -1357,16 +1357,103 @@
 false);%0A
+        ViewHolder viewHolder = new ViewHolder(view);%0A        view.setTag(viewHolder);%0A
         
@@ -1569,111 +1569,60 @@
     
-LinearLayout ll = (LinearLayout)view;%0A        ImageView iv = (ImageView) ll.findViewById(R.id.image
+ViewHolder viewHolder = (ViewHolder) view.getTag(
 );%0A
-%0A
     
@@ -1696,12 +1696,197 @@
 nto(
-iv);
+viewHolder.iv);%0A    %7D%0A%0A    public static class ViewHolder%7B%0A        ImageView iv;%0A%0A        public ViewHolder(View view)%7B%0A            iv = (ImageView) view.findViewById(R.id.image);%0A        %7D
 %0A   

Add the ViewHolder pattern in the MovieAdapter.