コード例 #1
0
        // what to do as the user types in searchbox
        void SetContactsFiltered()
        {
            if (ContactsGrouped == null)
            {
                return;
            }

            ContactsFiltered = new ObservableCollection <Grouping <string, ContactCellViewModel> >(
                ContactsGrouped.Select(group => new Grouping <string, ContactCellViewModel>(group.Key,
                                                                                            group.Where(contact => contact.Last.ToLower().Contains(SearchText.ToLower()) ||
                                                                                                        contact.First.ToLower().Contains(SearchText.ToLower())))).Where(group => group.Any())
                );
        }
コード例 #2
0
        async Task ExecuteRefreshCommand(bool forceRefresh)
        {
            if (IsBusy)
            {
                return;
            }

            if (!await CheckConnectivityAsync())
            {
                return;
            }

            IsBusy = true;

            try
            {
                Analytics.TrackEvent("SerchedForNearby");
                var position = await GeolocationService.GetCurrentPositionAsync();

                if (position == null)
                {
                    throw new Exception("Unable to get location.");
                }

                ContactsGrouped.Clear();
                var contacts = await DataService.GetNearbyAsync(position.Longitude, position.Latitude);

                if (contacts.Count() > 0)
                {
                    ContactsGrouped.AddRange(contacts);
                }
                else
                {
                    await Dialogs.AlertAsync(null, AppResources.NoCDAsNearby, AppResources.OK);
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                System.Diagnostics.Debug.WriteLine($"*** ERROR: {ex.Message}");
            }
            finally
            {
                IsBusy = false;
            }
        }