public void IntersectWith(IEnumerable <T> other) { var wrap = other as IJavaCollectionWrapper <T>; if (wrap != null) { hset.RetainAll((Java.Util.ICollection <object>)wrap.Collection); } else { var remove = new Java.Util.HashSet <T>(hset); foreach (var e in other) { remove.Remove(e); } hset.RemoveAll((Java.Util.ICollection <object>)remove); } }
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> /// Remove the given item from this set. /// </summary> public bool Remove(T item) { return(hset.Remove(item)); }