<commit_before>package ec327.caffiene;


import android.content.Intent;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class AddDrink extends AppCompatActivity {
    private Thread searchresults;
    public static ArrayList<String> matches;
    private static LinearLayout sublayout;
    public static EditText searchbar;
    public ArrayList<String> alldrinks;
    public boolean stopflag = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_add_drink);
        searchbar = (EditText) findViewById(R.id.search_bar);
        searchresults = new Thread(new dynamicSearch());
        //matches initially contains all possible drinks
        alldrinks = database.allDrinks();
        matches = database.allDrinks(); //create a new array to copy
        //sublayout which contains all buttons
        sublayout = (LinearLayout) findViewById(R.id.search_results);
        //buttons for each of these drinks is initially displayed
        addResults(matches);
        //start the thread that updates the search results
        searchresults.start();
    }


    @Override
    protected void onStop()
    {
        super.onStop();
        this.stopflag = true;

    }

    public void addDrink(View view) //callback function for add drink button
    {
        int numresults = sublayout.getChildCount();
        String drink = "unchecked";
        long time;
        for (int i = 0; i < numresults; i++)
        {
            ToggleButton child = (ToggleButton) sublayout.getChildAt(i);
            if (child.isChecked()) //get isChecked attribute to see if user has checked.
            {
                drink = child.getTextOn().toString();
                break; //ensures we only take into consideration the first checked button
            }
        }
        //if the user hasn't picked a drink, remind him to.

        if (drink.equals("unchecked"))
        {
            //display message if all drinks unchecked
            Toast toast = new Toast(this);
            toast.makeText(this,"Please select a drink",Toast.LENGTH_LONG);
            return;
        }
        int drinkindex = alldrinks.indexOf(drink);
        CheckBox drinknowbutton = (CheckBox) findViewById(R.id.drink_now);

        if (drinknowbutton.isChecked())
        {
            time = (new Date()).getTime()/1000;
        }
        else
        {
            EditText timeview = (EditText) findViewById(R.id.time);
            try
            {
                Date today = new Date();
                SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
                Date timeparsed = dateFormat.parse(timeview.getText().toString());
                time = timeparsed.getTime();
                 //as time is in milliseconds.

            }
            catch (Exception p)
            {
                Toast toast = Toast.makeText(getApplicationContext(), "Please enter a number",Toast.LENGTH_LONG);
                toast.show();
                return;
            }
        }
<commit_msg>changed the message of the toast<commit_after>package ec327.caffiene;


import android.content.Intent;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class AddDrink extends AppCompatActivity {
    private Thread searchresults;
    public static ArrayList<String> matches;
    private static LinearLayout sublayout;
    public static EditText searchbar;
    public ArrayList<String> alldrinks;
    public boolean stopflag = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_add_drink);
        searchbar = (EditText) findViewById(R.id.search_bar);
        searchresults = new Thread(new dynamicSearch());
        //matches initially contains all possible drinks
        alldrinks = database.allDrinks();
        matches = database.allDrinks(); //create a new array to copy
        //sublayout which contains all buttons
        sublayout = (LinearLayout) findViewById(R.id.search_results);
        //buttons for each of these drinks is initially displayed
        addResults(matches);
        //start the thread that updates the search results
        searchresults.start();
    }


    @Override
    protected void onStop()
    {
        super.onStop();
        this.stopflag = true;

    }

    public void addDrink(View view) //callback function for add drink button
    {
        int numresults = sublayout.getChildCount();
        String drink = "unchecked";
        long time;
        for (int i = 0; i < numresults; i++)
        {
            ToggleButton child = (ToggleButton) sublayout.getChildAt(i);
            if (child.isChecked()) //get isChecked attribute to see if user has checked.
            {
                drink = child.getTextOn().toString();
                break; //ensures we only take into consideration the first checked button
            }
        }
        //if the user hasn't picked a drink, remind him to.

        if (drink.equals("unchecked"))
        {
            //display message if all drinks unchecked
            Toast toast = new Toast(this);
            toast.makeText(this,"Please select a drink",Toast.LENGTH_LONG);
            return;
        }
        int drinkindex = alldrinks.indexOf(drink);
        CheckBox drinknowbutton = (CheckBox) findViewById(R.id.drink_now);

        if (drinknowbutton.isChecked())
        {
            time = (new Date()).getTime()/1000;
        }
        else
        {
            EditText timeview = (EditText) findViewById(R.id.time);
            try
            {
                Date today = new Date();
                SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
                Date timeparsed = dateFormat.parse(timeview.getText().toString());
                time = timeparsed.getTime();
                 //as time is in milliseconds.

            }
            catch (Exception p)
            {
                Toast toast = Toast.makeText(getApplicationContext(), "Please enter a valid time",Toast.LENGTH_LONG);
                toast.show();
                return;
            }
        }

{'fraction_non_alphanumeric': 0.08976660682226212, 'fraction_numerical': 0.0027620494406849884, 'mean_word_length': 2.308359981726816, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '976234', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1840, 'n_words': 514}