<commit_before>package com.telerikproject.tvshowcalendar.views.home;


import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.telerikproject.tvshowcalendar.BaseApplication;
import com.telerikproject.tvshowcalendar.R;
import com.telerikproject.tvshowcalendar.adapters.GridAdapter;
import com.telerikproject.tvshowcalendar.fragments.ILoadingFragment;
import com.telerikproject.tvshowcalendar.models.TvShowModel;
import com.telerikproject.tvshowcalendar.models.base.IPopularTvShowsModel;
import com.telerikproject.tvshowcalendar.modules.ControllerModule;
import com.telerikproject.tvshowcalendar.network.base.ITvShowData;
import com.telerikproject.tvshowcalendar.views.home.base.IHomeContract;

import java.util.ArrayList;
import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;


public class HomeContentFragment extends Fragment implements IHomeContract.View {

    private IHomeContract.Presenter presenter;

    @Inject
    ILoadingFragment loadingFragment;

    @Inject
    public Activity mActivity;

    @Inject
    ITvShowData tvShowData;


   public ArrayList<String> moviesImages;
// = {R.drawable.the_originals, R.drawable.game_of_thrones,
//            R.drawable.mr_robot, R.drawable.the_big_bang_theory,
//            R.drawable.the_vampire_diaries, R.drawable.un_barco_en_el_espejo};

    public ArrayList<String> moviesTitles;
    public ArrayList<String> moviesRating;
    public ArrayList<Integer> moviesIds;
    GridView gridView;


    public HomeContentFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_home_content, container, false);
        injectDependencies();
        BaseApplication.bind(this, view);

        this.moviesImages = new ArrayList<>();
        this.moviesTitles = new ArrayList<>();
        this.moviesRating = new ArrayList<>();
        this.moviesIds = new ArrayList<>();

        ILoadingFragment loading = loadingFragment.create(mActivity);

        getTopTvShows(loading);


        gridView = (GridView) view.findViewById(R.id.gv_top_10);
//        gridView.setAdapter(new GridAdapter(mActivity, moviesTitles, moviesRating, moviesImages));

        return view;
    }


    @Override
    public void setPresenter(IHomeContract.Presenter presenter) {
        this.presenter = presenter;
    }

    private void injectDependencies() {
        BaseApplication
                .from(getContext())
                .getAppComponent()
                .getControllerComponent(new ControllerModule(
                        getActivity(), getFragmentManager()
                ))
                .inject(this);
    }

    private void getTopTvShows(final ILoadingFragment loading) {
        tvShowData.getTopTvShows()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<IPopularTvShowsModel>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                        loading.show();
                    }

                    @Override
                    public void onNext(IPopularTvShowsModel value) {

                        ArrayList<TvShowModel> tvShows = value.getResults();

                        for(TvShowModel tvShow: tvShows) {
                            String poster = "https://image.tmdb.org/t/p/w640" + tvShow.getPoster();
                            String name = tvShow.getName();
                            double vote = tvShow.getVote();
                            int id = tvShow.getId();
                            moviesImages.add(poster);
                            moviesTitles.add(name);<commit_msg>rounding ratings to 1st digit after decimal place<commit_after>package com.telerikproject.tvshowcalendar.views.home;


import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.telerikproject.tvshowcalendar.BaseApplication;
import com.telerikproject.tvshowcalendar.R;
import com.telerikproject.tvshowcalendar.adapters.GridAdapter;
import com.telerikproject.tvshowcalendar.fragments.ILoadingFragment;
import com.telerikproject.tvshowcalendar.models.TvShowModel;
import com.telerikproject.tvshowcalendar.models.base.IPopularTvShowsModel;
import com.telerikproject.tvshowcalendar.modules.ControllerModule;
import com.telerikproject.tvshowcalendar.network.base.ITvShowData;
import com.telerikproject.tvshowcalendar.views.home.base.IHomeContract;

import java.util.ArrayList;
import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;


public class HomeContentFragment extends Fragment implements IHomeContract.View {

    private IHomeContract.Presenter presenter;

    @Inject
    ILoadingFragment loadingFragment;

    @Inject
    public Activity mActivity;

    @Inject
    ITvShowData tvShowData;


   public ArrayList<String> moviesImages;
// = {R.drawable.the_originals, R.drawable.game_of_thrones,
//            R.drawable.mr_robot, R.drawable.the_big_bang_theory,
//            R.drawable.the_vampire_diaries, R.drawable.un_barco_en_el_espejo};

    public ArrayList<String> moviesTitles;
    public ArrayList<String> moviesRating;
    public ArrayList<Integer> moviesIds;
    GridView gridView;


    public HomeContentFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_home_content, container, false);
        injectDependencies();
        BaseApplication.bind(this, view);

        this.moviesImages = new ArrayList<>();
        this.moviesTitles = new ArrayList<>();
        this.moviesRating = new ArrayList<>();
        this.moviesIds = new ArrayList<>();

        ILoadingFragment loading = loadingFragment.create(mActivity);

        getTopTvShows(loading);


        gridView = (GridView) view.findViewById(R.id.gv_top_10);
//        gridView.setAdapter(new GridAdapter(mActivity, moviesTitles, moviesRating, moviesImages));

        return view;
    }


    @Override
    public void setPresenter(IHomeContract.Presenter presenter) {
        this.presenter = presenter;
    }

    private void injectDependencies() {
        BaseApplication
                .from(getContext())
                .getAppComponent()
                .getControllerComponent(new ControllerModule(
                        getActivity(), getFragmentManager()
                ))
                .inject(this);
    }

    private void getTopTvShows(final ILoadingFragment loading) {
        tvShowData.getTopTvShows()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<IPopularTvShowsModel>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                        loading.show();
                    }

                    @Override
                    public void onNext(IPopularTvShowsModel value) {

                        ArrayList<TvShowModel> tvShows = value.getResults();

                        for(TvShowModel tvShow: tvShows) {
                            String poster = "https://image.tmdb.org/t/p/w640" + tvShow.getPoster();
                            String name = tvShow.getName();
                            double vote = (double) Math.round(tvShow.getVote() * 10) / 10;
                            int id = tvShow.getId();
                            moviesImages.add(poster);
                            moviesTitles.add(name);
{'fraction_non_alphanumeric': 0.08647817342955164, 'fraction_numerical': 0.0020111203123151546, 'mean_word_length': 2.5685943436048966, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '2410629', 'n_tokens_mistral': 2402, 'n_tokens_neox': 2252, 'n_words': 411}