private void FilterAndSort() { _entriesForViewing = new List <PwEntry>(); foreach (PwEntry entry in _group.Entries) { _entriesForViewing.Add(entry); } GroupViewSortOrderManager sortOrderManager = new GroupViewSortOrderManager(_act); var sortOrder = sortOrderManager.GetCurrentSortOrder(); if (sortOrder.RequiresSort) { var sortGroups = sortOrderManager.SortGroups; _groupsForViewing = new List <PwGroup>(_group.Groups); _groupsForViewing.Sort((x, y) => { if (sortGroups) { return(sortOrder.CompareGroups(x, y)); } else { return(String.Compare(x.Name, y.Name, true)); } }); _entriesForViewing.Sort(sortOrder.CompareEntries); } else { _groupsForViewing = new List <PwGroup>(_group.Groups); } }
private void ChangeSort() { var sortOrderManager = new GroupViewSortOrderManager(this); IEnumerable <string> sortOptions = sortOrderManager.SortOrders.Select( o => GetString(o.ResourceId) ); int selectedBefore = sortOrderManager.GetCurrentSortOrderIndex(); new AlertDialog.Builder(this) .SetSingleChoiceItems(sortOptions.ToArray(), selectedBefore, (sender, args) => { int selectedAfter = args.Which; sortOrderManager.SetNewSortOrder(selectedAfter); // Refresh menu titles ActivityCompat.InvalidateOptionsMenu(this); // Mark all groups as dirty now to refresh them on load Database db = App.Kp2a.GetDb(); db.MarkAllGroupsAsDirty(); // We'll manually refresh this group so we can remove it db.Dirty.Remove(Group); // Tell the adapter to refresh it's list BaseAdapter adapter = (BaseAdapter)ListAdapter; adapter.NotifyDataSetChanged(); }) .SetPositiveButton(Android.Resource.String.Ok, (sender, args) => ((Dialog)sender).Dismiss()) .Show(); }