<commit_before>package com.armandgray.taap;

import android.database.Cursor;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;

import com.armandgray.taap.db.DrillsTable;
import com.armandgray.taap.models.Drill;
import com.armandgray.taap.utils.DrillsRvAdapter;
import com.armandgray.taap.utils.RecyclerItemClickListener;

import java.util.ArrayList;

import static com.armandgray.taap.db.DatabaseContentProvider.CONTENT_URI_DRILLS;

class MainActivityViews {

    MainActivity activity;
    MainViewsListener listener;

    private String[] drillsArray = {"All", "Shooting", "Ball Handling", "Passing", "Fundamentals"};
    EditText etSearch;
    FloatingActionButton fab;
    Spinner spinner;
    private ImageView ivSort;
    private ImageView ivSearch;
    RecyclerView rvDrills;

    MainActivityViews(MainActivity activity, MainViewsListener listener) {
        this.activity = activity;
        this.listener = listener;
    }

    void setupActivityInitialState() {
        activity.setContentView(R.layout.activity_main);

        assignGlobalViews();
        setupToolbar();
        setupFabClickListener();
        setupSortClickListener();
        setupSpinnerItemSelectedListener();
        setupSearchVisibility();
        setupSearchIconClickListener();
        setupEtSearchTextChangeListener();
        setupRvDrills();
    }

    private void assignGlobalViews() {
        fab = (FloatingActionButton) activity.findViewById(R.id.fab);
        spinner = (Spinner) activity.findViewById(R.id.spDrillsSort);
        etSearch = (EditText) activity.findViewById(R.id.etSearch);
        ivSort = (ImageView) activity.findViewById(R.id.ivSort);
        ivSearch = (ImageView) activity.findViewById(R.id.ivSearch);
    }


    private void setupToolbar() {
        Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
        activity.setSupportActionBar(toolbar);
    }

    private void setupFabClickListener() {
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onFabClick();
            }
        });
    }

    private void setupSortClickListener() {
        ivSort.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onSortClick();
            }
        });
    }

    private void setupSpinnerItemSelectedListener() {
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                listener.onSpinnerItemSelected(parent, view, position, id);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    private void setupSearchVisibility() {
        etSearch.setFocusable(true);
        etSearch.setVisibility(View.GONE);
    }

    private void setupSearchIconClickListener() {
        ivSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onSearchClick();
            }
        });
        etSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                listener.onEtSearchFocusChange(v, hasFocus);
            }
        });
    }

    private void setupEtSearchTextChangeListener() {
        etSearch.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                listener.onEtSearchTextChanged(s, start, before, count);
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

    private void setupRvDrills() {
        rvDrills = (RecyclerView) activity.findViewById(R.id.rvDrills);
        rvDrills.setAdapter(new DrillsRvAdapter(getDrillsListFromDatabase()));
        rvDrills.setLayoutManager(
                new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false));
        setupRvDrillsItemClickListener();
    }

    private ArrayList<Drill> getDrillsListFromDatabase() {
        Cursor cursor = activity.getContentResolver()
                .query(CONTENT_URI_DRILLS, DrillsTable.ALL_DRILL_COLUMNS,
                        null, null, null);
        if (cursor == null) { return null; }
        ArrayList<Drill> listAllDrills = new ArrayList<>();
        cursor.close();
        return listAllDrills;<commit_msg>added call to addAllDrillsData in MainActivityViews<commit_after>package com.armandgray.taap;

import android.database.Cursor;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;

import com.armandgray.taap.db.DrillsTable;
import com.armandgray.taap.models.Drill;
import com.armandgray.taap.utils.DrillsRvAdapter;
import com.armandgray.taap.utils.RecyclerItemClickListener;

import java.util.ArrayList;

import static com.armandgray.taap.db.DatabaseContentProvider.CONTENT_URI_DRILLS;
import static com.armandgray.taap.utils.CursorDataHelper.addAllDrillsData;

class MainActivityViews {

    MainActivity activity;
    MainViewsListener listener;

    private String[] drillsArray = {"All", "Shooting", "Ball Handling", "Passing", "Fundamentals"};
    EditText etSearch;
    FloatingActionButton fab;
    Spinner spinner;
    private ImageView ivSort;
    private ImageView ivSearch;
    RecyclerView rvDrills;

    MainActivityViews(MainActivity activity, MainViewsListener listener) {
        this.activity = activity;
        this.listener = listener;
    }

    void setupActivityInitialState() {
        activity.setContentView(R.layout.activity_main);

        assignGlobalViews();
        setupToolbar();
        setupFabClickListener();
        setupSortClickListener();
        setupSpinnerItemSelectedListener();
        setupSearchVisibility();
        setupSearchIconClickListener();
        setupEtSearchTextChangeListener();
        setupRvDrills();
    }

    private void assignGlobalViews() {
        fab = (FloatingActionButton) activity.findViewById(R.id.fab);
        spinner = (Spinner) activity.findViewById(R.id.spDrillsSort);
        etSearch = (EditText) activity.findViewById(R.id.etSearch);
        ivSort = (ImageView) activity.findViewById(R.id.ivSort);
        ivSearch = (ImageView) activity.findViewById(R.id.ivSearch);
    }


    private void setupToolbar() {
        Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
        activity.setSupportActionBar(toolbar);
    }

    private void setupFabClickListener() {
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onFabClick();
            }
        });
    }

    private void setupSortClickListener() {
        ivSort.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onSortClick();
            }
        });
    }

    private void setupSpinnerItemSelectedListener() {
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                listener.onSpinnerItemSelected(parent, view, position, id);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    private void setupSearchVisibility() {
        etSearch.setFocusable(true);
        etSearch.setVisibility(View.GONE);
    }

    private void setupSearchIconClickListener() {
        ivSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onSearchClick();
            }
        });
        etSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                listener.onEtSearchFocusChange(v, hasFocus);
            }
        });
    }

    private void setupEtSearchTextChangeListener() {
        etSearch.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                listener.onEtSearchTextChanged(s, start, before, count);
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

    private void setupRvDrills() {
        rvDrills = (RecyclerView) activity.findViewById(R.id.rvDrills);
        rvDrills.setAdapter(new DrillsRvAdapter(getDrillsListFromDatabase()));
        rvDrills.setLayoutManager(
                new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false));
        setupRvDrillsItemClickListener();
    }

    private ArrayList<Drill> getDrillsListFromDatabase() {
        Cursor cursor = activity.getContentResolver()
                .query(CONTENT_URI_DRILLS, DrillsTable.ALL_DRILL_COLUMNS,
                        null, null, null);
        if (cursor == null) { return null; }
        ArrayList<Drill> listAllDrills = new ArrayList<>();
        addAllDrillsData(cursor, listAllDrills);
        cursor.close();
        return listAllDrills;
{'fraction_non_alphanumeric': 0.09058713886300093, 'fraction_numerical': 0.0005591798695246971, 'mean_word_length': 2.746857541899441, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '678184', 'n_tokens_mistral': 2907, 'n_tokens_neox': 2789, 'n_words': 543}