Esempio n. 1
0
            protected override FilterResults PerformFiltering(ICharSequence constraint)
            {
                FilterResults filterResults = new FilterResults();

                if (constraint == null)
                {
                    return(filterResults);
                }

                string filter = new string(constraint.Select(c => c).ToArray());

                Predicate <string> predicate = s =>
                {
                    // ASCII normalize strings
                    string value   = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(s.ToLowerInvariant()));
                    string pattern = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(filter.ToLowerInvariant()));

                    // Remove non character strings
                    value   = new string(value.Select(c => char.IsLetter(c) ? c : ' ').ToArray());
                    pattern = new string(pattern.Select(c => char.IsLetter(c) ? c : ' ').ToArray());

                    return(value.Contains(pattern));
                };

                string[] values = stopNames.Where(s => predicate(s)).ToArray();

                filterResults.Values = FromArray(values.Select(s => new Java.Lang.String(s)).ToArray());
                filterResults.Count  = values.Length;

                constraint.Dispose();

                return(filterResults);
            }