/// <summary> /// Default ctor /// </summary> public HashSet(IEnumerable <T> source) { hset = new Java.Util.HashSet <T>(); foreach (var item in source) { hset.Add(item); } }
/// <summary> /// Default ctor /// </summary> public HashSet(IEnumerable <T> source, IEqualityComparer <T> comparer) { hset = new Java.Util.HashSet <T>(); foreach (var item in source) { hset.Add(item); } }
public virtual bool OnSelection(MaterialDialog dialog, int[] which, string[] text) { preference.OnClick(null, (int)DialogButtonType.Positive); dialog.Dismiss(); var values = new Java.Util.HashSet(); foreach (string s in text) { values.Add((string)s); } if (preference.CallChangeListener(values)) { preference.Values = text.ToList(); } return(true); }
///// <summary> ///// Default ctor ///// </summary> public HashSet(IEnumerable <T> source, IEqualityComparer <T> comparer) { if (comparer != null && comparer != EqualityComparer <T> .Default) { throw new NotImplementedException("comparer not supported"); } var wrap = source as IJavaCollectionWrapper <T>; if (wrap != null) { hset = new Java.Util.HashSet <T>(wrap.Collection); } else { hset = new Java.Util.HashSet <T>(); foreach (var item in source) { hset.Add(item); } } }
protected override void OnPrepareDialogBuilder(AlertDialog.Builder builder) { base.OnPrepareDialogBuilder(builder); var preference = GetPreference(); if (preference.GetEntries() == null || preference.GetEntryValues() == null) { throw new Java.Lang.IllegalStateException( "MultiSelectListPreference requires an entries array and an entryValues array."); } var checkedItems = preference.GetSelectedItems(); var values = preference.GetEntryValues(); var entries = preference.GetEntries(); builder.SetMultiChoiceItems(entries, checkedItems, (s, e) => { if (_readOnlyEntriesPosition?.Count > 0 && _listView != null && _readOnlyEntriesPosition.Contains(e.Which)) { _listView.SetItemChecked(e.Which, !e.IsChecked); return; } _preferenceChanged = true; if (e.IsChecked) { _newValues.Add(values[e.Which]); } else { _newValues.Remove(values[e.Which]); } }); if (preference.ReadOnlyEntries?.Count > 0) { var entriesList = preference.GetEntries().ToList(); if (entriesList.Count > 0) { var readOnlyEntries = (from entry in entriesList from readOnlyEntry in preference.ReadOnlyEntries where string.Equals(entry, readOnlyEntry, StringComparison.OrdinalIgnoreCase) select entry).ToArray(); if (readOnlyEntries.Length > 0) { _readOnlyEntriesPosition = readOnlyEntries.Select(p => entriesList.IndexOf(p)).ToArray(); } } } _newValues.Clear(); for (var i = 0; i < checkedItems.Length; i++) { if (!checkedItems[i]) { continue; } _newValues.Add(values[i]); } }
/// <summary> /// Add the given item to this set. /// </summary> public bool Add(T item) { return(hset.Add(item)); }