private void _beaconManager_Nearable(object sender, BeaconManager.NearableEventArgs e) { if (e.Nearables.Count > 0) { myBeacons = new List <BeaconView>(); IList <Nearable> beacons = e.Nearables; for (int i = 0; i < e.Nearables.Count; i++) { myBeacons.Add(new BeaconView(beacons[i].Identifier)); } beaconStatus.Text = ""; dropCount = 0; } else if (e.Nearables.Count < myBeacons.Count && dropCount < 5 && myBeacons.Count > 0) { dropCount++; } else { beaconStatus.Text = "No beacons in range"; myBeacons = new List <BeaconView>(); dropCount = 0; } }
private async void UpdateBoardNames(object sender, BeaconManager.NearableEventArgs e) { for (int i = 0; i < myBeacons.Count; i++) { try { beaconStatus.Text = "Loading Beacons"; BeaconView beaconView = myBeacons[i]; //bool boardCreated = await db_accessBoard.createNewBoard(beaconView.BeaconId, new MainBoard(beaconView.BeaconId, "Ryan Barrett", "Test Board 1")); string boardname = "Not Found"; if (beaconsList.ContainsKey(beaconView.BeaconId)) { beaconsList.TryGetValue(beaconView.BeaconId, out boardname); myBeacons[i].BoardName = boardname; } else { MainBoard mb = await db_accessBoard.returnMainBoard(beaconView.BeaconId); if (mb != null) { myBeacons[i].BoardName = mb.BoardName; if (!beaconsList.ContainsKey(myBeacons[i].BeaconId)) { beaconsList.Add(myBeacons[i].BeaconId, myBeacons[i].BoardName); } } } beaconStatus.Text = ""; } catch (System.Exception ex) { if (ex is System.Net.WebException) { beaconStatus.Text = "Web error"; } } } viewList.Adapter = new BeaconAdapter(this, myBeacons); }