<commit_before>package eu.redray.trevie;

import android.content.Context;
import android.net.Uri;
import android.support.v4.content.AsyncTaskLoader;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by frano on 18/01/2016.
 */
public class MoviesLoader extends AsyncTaskLoader<Movie[]> {
    private final String TAG = MoviesLoader.class.getSimpleName();
    public final String VOTE_COUNT = "100";
    private String mSortParameter;
    private int mPageToLoad;
    private boolean DEBUG = true;

    // We hold a reference to the Loader's data here.
    private Movie[] mMovies;

    // Construct query URL
    final String TMDB_BASE_URL = "https://api.themoviedb.org/3";
    final String DISCOVER_PATH = "discover";
    final String MOVIE_PATH = "movie";
    final String SORT_PARAM = "sort_by";
    final String VOTE_COUNT_PARAM = "vote_count.gte";
    final String PAGE_NUMBER = "page";
    final String API_KEY_PARAM = "api_key";

    public MoviesLoader(Context context, String sortParameter, int page) {
        super(context);
        mSortParameter = sortParameter;
        mPageToLoad = page;
    }

    @Override
    public Movie[] loadInBackground() {
        Log.v("TREVIE-ML", "Started background thread");
        //Verify size of parameters to ensure there's something to look up
        if (mSortParameter == null) {
            return null;
        }

        Uri moviesUri = Uri.parse(TMDB_BASE_URL).buildUpon()
                .appendPath(DISCOVER_PATH)
                .appendPath(MOVIE_PATH)
                .appendQueryParameter(SORT_PARAM, mSortParameter)
                .appendQueryParameter(VOTE_COUNT_PARAM, VOTE_COUNT)
                .appendQueryParameter(PAGE_NUMBER, String.valueOf(mPageToLoad))
                .appendQueryParameter(API_KEY_PARAM, BuildConfig.OPEN_THE_MOVIEDB_API_KEY)
                .build();
        Log.v("TREVIE-ML", "Loading page... " + mPageToLoad);

        String moviesJsonString = getJsonString(moviesUri);
        if (moviesJsonString == null) return null;

        try {
            return getMovieDataFromJsonString(moviesJsonString);
        } catch (JSONException e) {
            Log.e(TAG, e.getMessage(), e);
            e.printStackTrace();<commit_msg>feat: Disable some log calls<commit_after>package eu.redray.trevie;

import android.content.Context;
import android.net.Uri;
import android.support.v4.content.AsyncTaskLoader;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by frano on 18/01/2016.
 */
public class MoviesLoader extends AsyncTaskLoader<Movie[]> {
    private final String TAG = MoviesLoader.class.getSimpleName();
    public final String VOTE_COUNT = "100";
    private String mSortParameter;
    private int mPageToLoad;
    private boolean DEBUG = false;

    // We hold a reference to the Loader's data here.
    private Movie[] mMovies;

    // Construct query URL
    final String TMDB_BASE_URL = "https://api.themoviedb.org/3";
    final String DISCOVER_PATH = "discover";
    final String MOVIE_PATH = "movie";
    final String SORT_PARAM = "sort_by";
    final String VOTE_COUNT_PARAM = "vote_count.gte";
    final String PAGE_NUMBER = "page";
    final String API_KEY_PARAM = "api_key";

    public MoviesLoader(Context context, String sortParameter, int page) {
        super(context);
        mSortParameter = sortParameter;
        mPageToLoad = page;
    }

    @Override
    public Movie[] loadInBackground() {
        //Verify size of parameters to ensure there's something to look up
        if (mSortParameter == null) {
            return null;
        }

        Uri moviesUri = Uri.parse(TMDB_BASE_URL).buildUpon()
                .appendPath(DISCOVER_PATH)
                .appendPath(MOVIE_PATH)
                .appendQueryParameter(SORT_PARAM, mSortParameter)
                .appendQueryParameter(VOTE_COUNT_PARAM, VOTE_COUNT)
                .appendQueryParameter(PAGE_NUMBER, String.valueOf(mPageToLoad))
                .appendQueryParameter(API_KEY_PARAM, BuildConfig.OPEN_THE_MOVIEDB_API_KEY)
                .build();

        String moviesJsonString = getJsonString(moviesUri);
        if (moviesJsonString == null) return null;

        try {
            return getMovieDataFromJsonString(moviesJsonString);
        } catch (JSONException e) {
            Log.e(TAG, e.getMessage(), e);
            e.printStackTrace();
{'fraction_non_alphanumeric': 0.0937178166838311, 'fraction_numerical': 0.005355303810504634, 'mean_word_length': 2.954397394136808, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5521574', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1397, 'n_words': 341}