<commit_before>package com.vinnypalumbo.popularmovies;

import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.squareup.picasso.Picasso;
import com.vinnypalumbo.popularmovies.data.MovieContract;

/**
 * Created by Vincent on 2016-01-21.
 */

public class DetailFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {

    private static final String LOG_TAG = DetailFragment.class.getSimpleName();
    static final String DETAIL_URI = "URI";

    private Uri mUri;
    private ToggleButton mToggleButton;

    private int movieId;
    private String title;
    private String poster;
    private String plot;
    private double rating;
    private int year;


    private static final int DETAIL_LOADER = 0;

    private static final String[] DETAIL_COLUMNS = {
            MovieContract.MovieEntry._ID,
            MovieContract.MovieEntry.COLUMN_MOVIE_ID,
            MovieContract.MovieEntry.COLUMN_TITLE,
            MovieContract.MovieEntry.COLUMN_POSTER,
            MovieContract.MovieEntry.COLUMN_PLOT,
            MovieContract.MovieEntry.COLUMN_RATING,
            MovieContract.MovieEntry.COLUMN_DATE
    };

    // these constants correspond to the projection defined above, and must change if the
    // projection changes
    static final int COL_ID = 0;
    static final int COL_MOVIE_ID = 1;
    static final int COL_MOVIE_TITLE = 2;
    static final int COL_MOVIE_POSTER = 3;
    static final int COL_MOVIE_PLOT = 4;
    static final int COL_MOVIE_RATING = 5;
    static final int COL_MOVIE_DATE = 6;

    private TextView mTitleView;
    private ImageView mPosterView;
    private TextView mPlotView;
    private TextView mRatingView;
    private TextView mYearView;

    public DetailFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Log.d("vinny-debug", "DetailFragment - onCreateView");

        Bundle arguments = getArguments();
        if (arguments != null) {
            mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
        }


        View rootView = inflater.inflate(R.layout.fragment_detail, container, false);


        mTitleView = (TextView) rootView.findViewById(R.id.detail_title);
        mPosterView = (ImageView) rootView.findViewById(R.id.detail_poster);
        mPlotView = (TextView) rootView.findViewById(R.id.detail_plot);
        mRatingView = (TextView) rootView.findViewById(R.id.detail_rating);
        mYearView = (TextView) rootView.findViewById(R.id.detail_year);

        // add or delete movie from watchlist when toggle button changed
        mToggleButton = (ToggleButton) rootView.findViewById(R.id.detail_favorite);
        mToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    addToWatchlist(movieId, title, poster, plot, rating, year);
                    Toast.makeText(getContext(), R.string.button_on_toast, Toast.LENGTH_SHORT).show();<commit_msg>Create ArrayAdapter to eventually use to populate the Trailer ListView<commit_after>package com.vinnypalumbo.popularmovies;

import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.squareup.picasso.Picasso;
import com.vinnypalumbo.popularmovies.data.MovieContract;

import java.util.ArrayList;

/**
 * Created by Vincent on 2016-01-21.
 */

public class DetailFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {

    private static final String LOG_TAG = DetailFragment.class.getSimpleName();
    static final String DETAIL_URI = "URI";

    private Uri mUri;
    private ToggleButton mToggleButton;
    private ArrayAdapter<String> mTrailerAdapter;

    private int movieId;
    private String title;
    private String poster;
    private String plot;
    private double rating;
    private int year;


    private static final int DETAIL_LOADER = 0;

    private static final String[] DETAIL_COLUMNS = {
            MovieContract.MovieEntry._ID,
            MovieContract.MovieEntry.COLUMN_MOVIE_ID,
            MovieContract.MovieEntry.COLUMN_TITLE,
            MovieContract.MovieEntry.COLUMN_POSTER,
            MovieContract.MovieEntry.COLUMN_PLOT,
            MovieContract.MovieEntry.COLUMN_RATING,
            MovieContract.MovieEntry.COLUMN_DATE
    };

    // these constants correspond to the projection defined above, and must change if the
    // projection changes
    static final int COL_ID = 0;
    static final int COL_MOVIE_ID = 1;
    static final int COL_MOVIE_TITLE = 2;
    static final int COL_MOVIE_POSTER = 3;
    static final int COL_MOVIE_PLOT = 4;
    static final int COL_MOVIE_RATING = 5;
    static final int COL_MOVIE_DATE = 6;

    private TextView mTitleView;
    private ImageView mPosterView;
    private TextView mPlotView;
    private TextView mRatingView;
    private TextView mYearView;

    public DetailFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Log.d("vinny-debug", "DetailFragment - onCreateView");

        Bundle arguments = getArguments();
        if (arguments != null) {
            mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
        }

        mTrailerAdapter =
                new ArrayAdapter<String>(
                        getActivity(), // The current context (this activity)
                        R.layout.list_item_trailer, // The name of the layout ID.
                        R.id.list_item_trailer_title, // The ID of the textview to populate.
                        new ArrayList<String>());

        View rootView = inflater.inflate(R.layout.fragment_detail, container, false);


        mTitleView = (TextView) rootView.findViewById(R.id.detail_title);
        mPosterView = (ImageView) rootView.findViewById(R.id.detail_poster);
        mPlotView = (TextView) rootView.findViewById(R.id.detail_plot);
        mRatingView = (TextView) rootView.findViewById(R.id.detail_rating);
        mYearView = (TextView) rootView.findViewById(R.id.detail_year);

        // add or delete movie from watchlist when toggle button changed
        mToggleButton = (ToggleButton) rootView.findViewById(R.id.detail_favorite);
        mToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    addToWatchlist(movieId, title, poster, plot, rating, year);
                    Toast.makeText(getContext(), R.string.button_on_toast, Toast.LENGTH_SHORT).show();
{'fraction_non_alphanumeric': 0.07934336525307797, 'fraction_numerical': 0.004974505658500186, 'mean_word_length': 3.2822151224707135, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4045102', 'n_tokens_mistral': 2363, 'n_tokens_neox': 2189, 'n_words': 537}