public static List <Contact> GetFromMobile() { return(contOperator.GetFromMobile()); }
public void Load(IContactOperator op) { contOperator = op; contacts = contOperator.GetFromMobile(); List <Contact> markedContacts = new List <Contact> (); var usedPhones = contOperator.GetPhones(); var usedSkypes = contOperator.GetSkypes(); tableView = new TableView { Intent = TableIntent.Form, Root = new TableRoot { } }; contCells.Clear(); // в первую очередь высвечиваем ранее выбранные контакты for (int i = 0; i < contacts.Count(); ++i) { var cont = contacts [i]; if (cont.phone == "" || cont.phone == null) { continue; } if (usedPhones.Any((x) => { return(x == cont.phone); }) || usedSkypes.Any((x) => { return(x == cont.skype); })) { SwitchCell cntSwt = new SwitchCell(); TableSection newTS = new TableSection { cntSwt }; tableView.Root.Add(newTS); cntSwt.Text = cont.name; cntSwt.On = true; cont.isSelected = true; cntSwt.OnChanged += (sender, e) => { cont.isSelected = cntSwt.On; }; contCells [newTS] = cntSwt; markedContacts.Add(contacts[i]); } } // Далее выводим все прочие контакты for (int i = 0; i < contacts.Count(); ++i) { if (contacts [i] == null) { continue; } var cont = contacts [i]; if (cont.phone == "" || cont.phone == null) { continue; } // Если контакт уже был выбран ранее - не показываем его if (markedContacts.Any((x) => (x == cont))) { continue; } SwitchCell cntSwt = new SwitchCell(); TableSection newTS = new TableSection { cntSwt }; tableView.Root.Add(newTS); cntSwt.Text = cont.name; cntSwt.On = false; cntSwt.OnChanged += (sender, e) => { cont.isSelected = cntSwt.On; }; contCells[newTS] = cntSwt; } ContactsLayout.Children.Add(tableView); }