<commit_before>
package com.battlelancer.seriesguide.adapters;

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

import com.battlelancer.seriesguide.WatchedBox;
import com.battlelancer.seriesguide.ui.EpisodesFragment.EpisodesQuery;
import com.battlelancer.seriesguide.util.Utils;
import com.uwetrottmann.androidutils.CheatSheet;
import com.uwetrottmann.seriesguide.R;

public class EpisodesAdapter extends CursorAdapter {

    private static final int LAYOUT = R.layout.episode_row;

    private LayoutInflater mLayoutInflater;

    private OnClickListener mOnClickListener;

    private OnFlagEpisodeListener mOnFlagListener;

    public interface OnFlagEpisodeListener {
        public void onFlagEpisodeWatched(int episodeId, int episodeNumber, boolean isWatched);
    }

    public EpisodesAdapter(Context context, Cursor c, int flags, OnClickListener listener,
            OnFlagEpisodeListener flagListener) {
        super(context, c, flags);
        mLayoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mOnClickListener = listener;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (!mDataValid) {
            throw new IllegalStateException("this should only be called when the cursor is valid");
        }<commit_msg>Fix crash if flagging episodes.<commit_after>
package com.battlelancer.seriesguide.adapters;

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

import com.battlelancer.seriesguide.WatchedBox;
import com.battlelancer.seriesguide.ui.EpisodesFragment.EpisodesQuery;
import com.battlelancer.seriesguide.util.Utils;
import com.uwetrottmann.androidutils.CheatSheet;
import com.uwetrottmann.seriesguide.R;

public class EpisodesAdapter extends CursorAdapter {

    private static final int LAYOUT = R.layout.episode_row;

    private LayoutInflater mLayoutInflater;

    private OnClickListener mOnClickListener;

    private OnFlagEpisodeListener mOnFlagListener;

    public interface OnFlagEpisodeListener {
        public void onFlagEpisodeWatched(int episodeId, int episodeNumber, boolean isWatched);
    }

    public EpisodesAdapter(Context context, Cursor c, int flags, OnClickListener listener,
            OnFlagEpisodeListener flagListener) {
        super(context, c, flags);
        mLayoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mOnClickListener = listener;
        mOnFlagListener = flagListener;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (!mDataValid) {
            throw new IllegalStateException("this should only be called when the cursor is valid");
        }
{'fraction_non_alphanumeric': 0.07025547445255474, 'fraction_numerical': 0.0006082725060827251, 'mean_word_length': 4.3479674796747965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3635514', 'n_tokens_mistral': 932, 'n_tokens_neox': 876, 'n_words': 216}