package com.denis.home.popularmovies;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.denis.home.popularmovies.data.MoviesContract;
import com.squareup.picasso.Picasso;

/**
 * Created by Denis on 23.12.2015.
 */
public class NewMovieAdapter extends CursorAdapter {
    private static final String LOG_TAG = NewMovieAdapter.class.getSimpleName();
    private Context mContext;
    private static int sLoaderID;

    public static class ViewHolder {
        public final ImageView imageView;
        public final TextView textView;

        public ViewHolder(View view) {
            imageView = (ImageView) view.findViewById(R.id.discovery_movie_image);
            textView = (TextView) view.findViewById(R.id.discovery_movie_text);
        }
    }

    public NewMovieAdapter(Context context, Cursor c, int flags, int loaderID) {
        super(context, c, flags);
        Log.d(LOG_TAG, "MovAdapter");
        mContext = context;
        sLoaderID = loaderID;
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        int layoutId = R.layout.movie_item;

        Log.d(LOG_TAG, "In new View");

        View view = LayoutInflater.from(context).inflate(layoutId, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        view.setTag(viewHolder);

        return view;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        ViewHolder viewHolder = (ViewHolder) view.getTag();

        Log.d(LOG_TAG, "In bind View");

        int movieTitleCI = cursor.getColumnIndex(MoviesContract.MovieEntry.COLUMN_TITLE);
        final String movieTitle = cursor.getString(movieTitleCI);
        viewHolder.textView.setText(movieTitle);

        int moviePosterCI = cursor.getColumnIndex(MoviesContract.MovieEntry.COLUMN_POSTER);
        int moviePoster = cursor.getInt(moviePosterCI);
        Picasso.with(context).load(moviePoster).placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher).into(viewHolder.imageView);
    }
}

@@ -36,442 +36,103 @@
 s;%0A%0A
-import android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.support.v4.widget.CursorAdapter;%0Aimport android.util.Log;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.widget.ImageView;%0Aimport android.widget.TextView;%0A%0Aimport com.denis.home.popularmovies.data.MoviesContract;%0Aimport com.squareup.picasso.Picasso;%0A%0A/**%0A * Created by Denis on 23.12.2015.%0A */%0A
+/**%0A * Created by Denis on 23.12.2015.%0A */%0A%0A// Unused class%0Apublic class NewMovieAdapter %7B%7D%0A%0A/*
 publ
@@ -1942,9 +1942,11 @@
 %0A    %7D%0A%7D
+*/
 %0A

comment unused adapter