private void OnSelectionUpdated(Poi poi) { FindViewById <TextView>(Resource.Id.textViewPlaceName).Text = poi.Name; FindViewById <TextView>(Resource.Id.textViewPlaceCountry).Text = PoiCountryHelper.GetCountryName(poi.Country); FindViewById <TextView>(Resource.Id.textViewAltitude).Text = $"{poi.Altitude:F0} m"; FindViewById <TextView>(Resource.Id.textViewGpsLocation).Text = GpsUtils.LocationAsString(poi.Latitude, poi.Longitude); var thumbnail = FindViewById <ImageView>(Resource.Id.Thumbnail); thumbnail.SetImageResource(PoiCategoryHelper.GetImage(poi.Category)); CalculateDownloadSize(poi); }
private void OnIndexDownloaded(string json) { try { _downloadViewItems = new List <DownloadViewItem>(); //fetch list of already downladed items from database var downloadedTask = AppContext.Database.GetDownloadedPoisAsync(); downloadedTask.Wait(); var _downloadItems = downloadedTask.Result.ToList(); if (!String.IsNullOrEmpty(json)) { var _horizonIndex = JsonConvert.DeserializeObject <HorizonIndex>(json); //combine those two lists together foreach (var country in _horizonIndex) { foreach (var item in country.PoiData) { var fromDB = _downloadItems.Find(x => x.Id == item.Id); if (fromDB == null) { fromDB = new PoisToDownload() { Id = item.Id, Description = item.Description, Category = item.Category, Url = item.Url, Country = country.Country, PointCount = item.PointCount, DateCreated = item.DateCreated, DownloadDate = null }; } var x = new DownloadViewItem(fromDB, item); _downloadViewItems.Add(x); } } } } catch (Exception e) { PopupHelper.ErrorDialog(this, Resource.String.Download_ErrorDownloading, e.Message); return; } var countries = _downloadViewItems.Select(x => x.fromDatabase.Country) .Distinct() .OrderBy(x => PoiCountryHelper.GetCountryName(x)) .ToList(); Task.Run(async() => { var defaultCountry = await PoiCountryHelper.GetDefaultCountryByPhoneLocation(); MainThread.BeginInvokeOnMainThread(() => { _countryAdapter.SetItems(countries); SelectCountry(defaultCountry); }); }); }