<commit_before>package com.cesarsk.say_it.ui.fragments;


import android.app.Activity;
import android.app.ActivityOptions;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.app.Fragment;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import android.support.v4.widget.NestedScrollView;

import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.app.FragmentManager;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.cesarsk.say_it.ui.MainActivity;
import com.cesarsk.say_it.ui.PlayActivity;
import com.cesarsk.say_it.R;
import com.cesarsk.say_it.ui.components.FadingTextView;
import com.cesarsk.say_it.ui.SettingsActivity;
import com.cesarsk.say_it.utility.SayItPair;
import com.cesarsk.say_it.utility.Utility;
import com.cesarsk.say_it.utility.UtilityRecordings;
import com.cesarsk.say_it.utility.UtilitySharedPrefs;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.NativeExpressAdView;

import java.util.ArrayList;

import static android.speech.tts.TextToSpeech.QUEUE_FLUSH;
import static com.cesarsk.say_it.ui.MainActivity.IPAofTheDay;
import static com.cesarsk.say_it.ui.MainActivity.wordOfTheDay;
import static com.cesarsk.say_it.utility.UtilityDictionary.getDailyRandomQuote;


/*
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment extends Fragment {

    public static int RECENT_HISTORY_CARD_ROW_LIMIT = 5;
    private boolean favorite_flag = false;
    View view;

    ArrayList<SayItPair> recentHistory;
    LinearLayout recentHistoryLinearLayout;
    LinearLayout.LayoutParams layoutParams;
    float scale;
    RelativeLayout recent_search = null;

    public HomeFragment() {
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        recentHistory = UtilitySharedPrefs.getRecentHistory(getActivity(), RECENT_HISTORY_CARD_ROW_LIMIT);
        layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        scale = getResources().getDisplayMetrics().density;

    }

    @Override
    public void onResume() {
        //TODO: Fix multiple list bug
        super.onResume();
        /*if(recentHistory != null && !(recentHistory.isEmpty())) {
            recent_search.setVisibility(View.VISIBLE);
            for (int i = 0; i < recentHistory.size(); i++) {
                LinearLayout current_LL = new LinearLayout(getActivity());
                recentHistoryLinearLayout.addView(current_LL);
                current_LL.setLayoutParams(layoutParams);
                TextView wordTextView = new TextView(getActivity());
                wordTextView.setLayoutParams(layoutParams);
                wordTextView.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary_dark));
                wordTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
                wordTextView.setTypeface(Typeface.DEFAULT_BOLD);
                wordTextView.setPaddingRelative((int) (12 * scale + 0.5f), 0, (int) (16 * scale + 0.5f), 0);
                wordTextView.setText(recentHistory.get(i).first);
                current_LL.addView(wordTextView);
                TextView ipaTextView = new TextView(getActivity());
                ipaTextView.setLayoutParams(layoutParams);
                ipaTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
                ipaTextView.setPaddingRelative((int) (16 * scale + 0.5f), 0, (int) (8 * scale + 0.5f), 0);
                ipaTextView.setText(recentHistory.get(i).second);
                current_LL.addView(ipaTextView);
            }
        }

        else{
            LinearLayout norecent_LL = new LinearLayout(getActivity());
            recentHistoryLinearLayout.addView(norecent_LL);
            norecent_LL.setLayoutParams(layoutParams);
            TextView norecentTextView = new TextView(getActivity());
            norecentTextView.setLayoutParams(layoutParams);
            norecentTextView.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary_dark));
            norecentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
            norecentTextView.setTypeface(Typeface.DEFAULT_BOLD);
            norecentTextView.setPaddingRelative((int) (12 * scale + 0.5f), 0, (int) (16 * scale + 0.5f), 0);
            norecentTextView.setText(R.string.NoRecent_Text);
            norecent_LL.addView(norecentTextView);
        }*/<commit_msg>Added onResume implementation in the Home Fragment<commit_after>package com.cesarsk.say_it.ui.fragments;


import android.app.Activity;
import android.app.ActivityOptions;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.app.Fragment;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import android.support.v4.widget.NestedScrollView;

import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.app.FragmentManager;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.cesarsk.say_it.ui.MainActivity;
import com.cesarsk.say_it.ui.PlayActivity;
import com.cesarsk.say_it.R;
import com.cesarsk.say_it.ui.components.FadingTextView;
import com.cesarsk.say_it.ui.SettingsActivity;
import com.cesarsk.say_it.utility.SayItPair;
import com.cesarsk.say_it.utility.Utility;
import com.cesarsk.say_it.utility.UtilityRecordings;
import com.cesarsk.say_it.utility.UtilitySharedPrefs;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.NativeExpressAdView;

import java.util.ArrayList;

import static android.speech.tts.TextToSpeech.QUEUE_FLUSH;
import static com.cesarsk.say_it.ui.MainActivity.IPAofTheDay;
import static com.cesarsk.say_it.ui.MainActivity.wordOfTheDay;
import static com.cesarsk.say_it.utility.UtilityDictionary.getDailyRandomQuote;


/*
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment extends Fragment {

    public static int RECENT_HISTORY_CARD_ROW_LIMIT = 5;
    private boolean favorite_flag = false;
    View view;

    ArrayList<SayItPair> recentHistory;
    LinearLayout recentHistoryLinearLayout;
    LinearLayout.LayoutParams layoutParams;
    float scale;
    RelativeLayout recent_search = null;

    public HomeFragment() {
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        scale = getResources().getDisplayMetrics().density;

    }

    @Override
    public void onResume() {
        //TODO: Fix multiple list bug
        super.onResume();
        recentHistory = UtilitySharedPrefs.getRecentHistory(getActivity(), RECENT_HISTORY_CARD_ROW_LIMIT);
        if(recentHistory != null && !(recentHistory.isEmpty())) {
            recentHistoryLinearLayout.removeAllViews();
            recent_search.setVisibility(View.VISIBLE);
            for (int i = 0; i < recentHistory.size(); i++) {
                LinearLayout current_LL = new LinearLayout(getActivity());
                recentHistoryLinearLayout.addView(current_LL);
                current_LL.setLayoutParams(layoutParams);
                TextView wordTextView = new TextView(getActivity());
                wordTextView.setLayoutParams(layoutParams);
                wordTextView.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary_dark));
                wordTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
                wordTextView.setTypeface(Typeface.DEFAULT_BOLD);
                wordTextView.setPaddingRelative((int) (12 * scale + 0.5f), 0, (int) (16 * scale + 0.5f), 0);
                wordTextView.setText(recentHistory.get(i).first);
                current_LL.addView(wordTextView);
                TextView ipaTextView = new TextView(getActivity());
                ipaTextView.setLayoutParams(layoutParams);
                ipaTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
                ipaTextView.setPaddingRelative((int) (16 * scale + 0.5f), 0, (int) (8 * scale + 0.5f), 0);
                ipaTextView.setText(recentHistory.get(i).second);
                current_LL.addView(ipaTextView);
            }
        }

        else{
            LinearLayout norecent_LL = new LinearLayout(getActivity());
            recentHistoryLinearLayout.addView(norecent_LL);
            norecent_LL.setLayoutParams(layoutParams);
            TextView norecentTextView = new TextView(getActivity());
            norecentTextView.setLayoutParams(layoutParams);
            norecentTextView.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary_dark));
            norecentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
            norecentTextView.setTypeface(Typeface.DEFAULT_BOLD);
            norecentTextView.setPaddingRelative((int) (12 * scale + 0.5f), 0, (int) (16 * scale + 0.5f), 0);
            norecentTextView.setText(R.string.NoRecent_Text);
            norecent_LL.addView(norecentTextView);
        }
{'fraction_non_alphanumeric': 0.09904687039402574, 'fraction_numerical': 0.007860862729684583, 'mean_word_length': 3.6666666666666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3633635', 'n_tokens_mistral': 3073, 'n_tokens_neox': 2886, 'n_words': 485}