public void DidRemoveNewAccessory(HMAccessoryBrowser browser, HMAccessory accessory) { var removedAccessory = Accessory.CreateHomeKitObject(accessory); var removedIndex = displayedAccessories.IndexOf(removedAccessory); if (removedIndex < 0) { return; } var removedIndexPath = NSIndexPath.FromRowSection(removedIndex, 0); displayedAccessories.RemoveAt(removedIndex); TableView.DeleteRows(new [] { removedIndexPath }, UITableViewRowAnimation.Automatic); }
public void DidFindNewAccessory(HMAccessoryBrowser browser, HMAccessory accessory) { var newAccessory = Accessory.CreateHomeKitObject(accessory); if (displayedAccessories.Contains(newAccessory)) { return; } displayedAccessories.Add(newAccessory); displayedAccessories.SortByLocalizedName(a => a.Name); var newIndex = displayedAccessories.IndexOf(newAccessory); if (newIndex >= 0) { var newIndexPath = NSIndexPath.FromRowSection(newIndex, 0); TableView.InsertRows(new [] { newIndexPath }, UITableViewRowAnimation.Automatic); } }
/// <Docs>Called after the object has been loaded from the nib file. Overriders must call base.AwakeFromNib().</Docs> /// <summary> /// Awakes from nib. /// </summary> public override void AwakeFromNib () { base.AwakeFromNib (); // Create a new accessory browser AccessoryBrowser = new HMAccessoryBrowser (); // Wireup changes AccessoryBrowser.DidFindNewAccessory += (sender, e) => { // Update display ReloadData(); }; AccessoryBrowser.DidRemoveNewAccessory += (sender, e) => { // Update display ReloadData(); // Inform the rest of the UI that it needs to refresh ThisApp.RaiseUpdateGUI(); }; }
/// <Docs>Called after the object has been loaded from the nib file. Overriders must call base.AwakeFromNib().</Docs> /// <summary> /// Awakes from nib. /// </summary> public override void AwakeFromNib() { base.AwakeFromNib(); // Create a new accessory browser AccessoryBrowser = new HMAccessoryBrowser(); // Wireup changes AccessoryBrowser.DidFindNewAccessory += (sender, e) => { // Update display ReloadData(); }; AccessoryBrowser.DidRemoveNewAccessory += (sender, e) => { // Update display ReloadData(); // Inform the rest of the UI that it needs to refresh ThisApp.RaiseUpdateGUI(); }; }