<commit_before>using System;

using Android.Support.V4.App;
using Android.Content;
using Android.OS;
using Android.Views;
using Android.Widget;
using Android.Gms.Maps.Model;
using Android.Graphics;
using Android.Util;
using Plugin.Media;
using System.IO;
using DayTomato.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Java.Lang;

namespace DayTomato.Droid
{
    public class AddPinsDialogFragment : DialogFragment
    {
        private readonly static string TAG = "ADD_PINS_DIALOG_FRAGMENT";

        public event EventHandler<AddPinsDialogEventArgs> AddPinsDialogClosed;      // Event handler when user presses create
        private Button _createTripButton;                               // Create trip button
        private Button _cancelButton;                                   // Cancel create trip button
        private Button _addPinButton;                                   // Add pin to trip button
        private List<string> _addedPins = new List<string> ();                                  // Array of added pins
        private List<Pin> _allPins;                                     // All pins currently on server
        private AutoCompleteTextView autocompleteTextView;              // Search for pins
        private TextView _listPins;                                     // List of added pins
        private bool _createTrip;                                        // Check if they pressed create or not

        public static AddPinsDialogFragment NewInstance()
        {
            AddPinsDialogFragment fragment = new AddPinsDialogFragment();
            return fragment;
        }

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.add_pins_dialog_fragment, container, false);
            _createTripButton = (Button)view.FindViewById(Resource.Id.add_pins_dialog_create_button);
            _cancelButton = (Button)view.FindViewById(Resource.Id.add_pins_dialog_cancel_button);
            _addPinButton = (Button)view.FindViewById(Resource.Id.add_pins_dialog_add_button);
            
            _listPins = view.FindViewById<TextView>(Resource.Id.add_pins_dialog_listpins);

            // Anytime the user clicks on the add button, add that pin to the trip and display the list of pins on the screen
            _addPinButton.Click += (sender, e) =>
            {
                if (autocompleteTextView.Text != null)
                {
                    Pin _pin = _allPins.Find(p => p.Name == autocompleteTextView.Text);
                    if (_pin != null)
                    {
                        _addedPins.Add(_pin.Id);
                        Toast.MakeText(this.Activity, "Added Pin", ToastLength.Short).Show();
                        _listPins.Text += autocompleteTextView.Text + "\n";
                        _pin = null;
                    }
                    else { Toast.MakeText(this.Activity, "Could not find pin", ToastLength.Short).Show(); }
                }
                else { Toast.MakeText(this.Activity, "Type the name of a pin to add", ToastLength.Short).Show(); }
            };

            ArrayAdapter autoCompleteAdapter = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleDropDownItem1Line, new List<string>());

            autocompleteTextView = view.FindViewById<AutoCompleteTextView>(Resource.Id.add_pins_dialog_autocomplete);
            // Minimum number of characters to begin autocompletet for
            autocompleteTextView.Threshold = 1;<commit_msg>Clear autocompleteTextView after successfully adding pin to trip<commit_after>using System;

using Android.Support.V4.App;
using Android.Content;
using Android.OS;
using Android.Views;
using Android.Widget;
using Android.Gms.Maps.Model;
using Android.Graphics;
using Android.Util;
using Plugin.Media;
using System.IO;
using DayTomato.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Java.Lang;

namespace DayTomato.Droid
{
    public class AddPinsDialogFragment : DialogFragment
    {
        private readonly static string TAG = "ADD_PINS_DIALOG_FRAGMENT";

        public event EventHandler<AddPinsDialogEventArgs> AddPinsDialogClosed;      // Event handler when user presses create
        private Button _createTripButton;                               // Create trip button
        private Button _cancelButton;                                   // Cancel create trip button
        private Button _addPinButton;                                   // Add pin to trip button
        private List<string> _addedPins = new List<string> ();                                  // Array of added pins
        private List<Pin> _allPins;                                     // All pins currently on server
        private AutoCompleteTextView autocompleteTextView;              // Search for pins
        private TextView _listPins;                                     // List of added pins
        private bool _createTrip;                                        // Check if they pressed create or not

        public static AddPinsDialogFragment NewInstance()
        {
            AddPinsDialogFragment fragment = new AddPinsDialogFragment();
            return fragment;
        }

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.add_pins_dialog_fragment, container, false);
            _createTripButton = (Button)view.FindViewById(Resource.Id.add_pins_dialog_create_button);
            _cancelButton = (Button)view.FindViewById(Resource.Id.add_pins_dialog_cancel_button);
            _addPinButton = (Button)view.FindViewById(Resource.Id.add_pins_dialog_add_button);
            
            _listPins = view.FindViewById<TextView>(Resource.Id.add_pins_dialog_listpins);

            // Anytime the user clicks on the add button, add that pin to the trip and display the list of pins on the screen
            _addPinButton.Click += (sender, e) =>
            {
                if (autocompleteTextView.Text != null)
                {
                    Pin _pin = _allPins.Find(p => p.Name == autocompleteTextView.Text);
                    if (_pin != null)
                    {
                        _addedPins.Add(_pin.Id);
                        Toast.MakeText(this.Activity, "Added Pin", ToastLength.Short).Show();
                        _listPins.Text += autocompleteTextView.Text + "\n";
                        _pin = null;
                        autocompleteTextView.Text = "";
                    }
                    else { Toast.MakeText(this.Activity, "Could not find pin", ToastLength.Short).Show(); }
                }
                else { Toast.MakeText(this.Activity, "Type the name of a pin to add", ToastLength.Short).Show(); }
            };

            ArrayAdapter autoCompleteAdapter = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleDropDownItem1Line, new List<string>());

            autocompleteTextView = view.FindViewById<AutoCompleteTextView>(Resource.Id.add_pins_dialog_autocomplete);
            // Minimum number of characters to begin autocompletet for
            autocompleteTextView.Threshold = 1;
{'fraction_non_alphanumeric': 0.07366707366707367, 'fraction_numerical': 0.000814000814000814, 'mean_word_length': 1.987034035656402, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4228202', 'n_tokens_mistral': 1848, 'n_tokens_neox': 1731, 'n_words': 469}