public EstimoteBeaconProbeBeaconsPage(EstimoteBeaconProbe probe) { Title = "Beacons"; ListView beaconList = new ListView(ListViewCachingStrategy.RecycleElement); beaconList.ItemTemplate = new DataTemplate(typeof(TextCell)); beaconList.ItemTemplate.SetBinding(TextCell.TextProperty, new Binding(".", stringFormat: "{0}")); beaconList.ItemsSource = probe.Beacons; beaconList.ItemTapped += async(o, e) => { if (beaconList.SelectedItem == null) { return; } EstimoteBeacon selectedBeacon = beaconList.SelectedItem as EstimoteBeacon; string selectedAction = await DisplayActionSheet(selectedBeacon.ToString(), "Cancel", null, "Delete"); if (selectedAction == "Delete") { if (await DisplayAlert("Confirm Delete", "Are you sure you want to delete the selected beacon?", "Yes", "Cancel")) { probe.Beacons.Remove(selectedBeacon); beaconList.SelectedItem = null; // must reset this, since it isn't reset automatically } } }; Content = beaconList; ToolbarItems.Add(new ToolbarItem(null, "plus.png", async() => { await Task.Run(async() => { EstimoteBeaconProbe estimoteBeaconProbe = probe as EstimoteBeaconProbe; List <string> beacons; try { beacons = estimoteBeaconProbe.GetSensusBeaconNamesFromCloud(); if (beacons == null) { throw new Exception("No beacons"); } } catch (Exception ex) { await SensusServiceHelper.Get().FlashNotificationAsync("Failed to retrieve Estimote beacons from Cloud: " + ex); return; } List <Input> inputs = await SensusServiceHelper.Get().PromptForInputsAsync("Add Beacon", new Input[] { new ItemPickerDialogInput("Beacon Name:", null, beacons) { AllowClearSelection = false }, new NumberEntryInput("Proximity (Meters):"), new SingleLineTextInput("Event Name (Defaults To Beacon Name):", Keyboard.Default) { Required = false } }, null, true, null, null, null, null, false); if (inputs != null) { try { string beaconName = inputs[0].Value.ToString(); double beaconProximity = double.Parse(inputs[1].Value.ToString()); string eventName = inputs[2].Value?.ToString(); EstimoteBeacon beacon = new EstimoteBeacon(beaconName, beaconProximity, eventName); estimoteBeaconProbe.Beacons.Add(beacon); } catch (Exception) { await SensusServiceHelper.Get().FlashNotificationAsync("Failed to add beacon."); } } }); })); }
public ProximityHandler(AndroidEstimoteBeaconProbe probe, EstimoteBeacon beacon, EstimoteBeaconProximityEvent proximityEvent) { _probe = probe; _beacon = beacon; _proximityEvent = proximityEvent; }