public void InsertItem(DownloadedElevationData item) { _database.InsertItem(item); MainThread.BeginInvokeOnMainThread(() => DownloadedElevationDataAdded?.Invoke(this, new DownloadedElevationDataEventArgs() { data = item }) ); }
public void InsertItem(PhotoData item) { _database.InsertItem(item); MainThread.BeginInvokeOnMainThread(() => PhotoAdded?.Invoke(this, new PhotoDataEventArgs() { data = item }) ); }
public void Run() { var imgWidth = _context.IsPortrait ? _Image.Height : _Image.Width; var imgHeight = _context.IsPortrait ? _Image.Width : _Image.Height; var thumbWidth = _context.IsPortrait ? THUMBNAIL_HEIGHT : THUMBNAIL_WIDTH; var thumbHeight = _context.IsPortrait ? THUMBNAIL_WIDTH : THUMBNAIL_HEIGHT; ByteBuffer buffer = _Image.GetPlanes()[0].Buffer; byte[] bytes = new byte[buffer.Remaining()]; buffer.Get(bytes); var filename = ImageSaverUtils.GetPhotoFileName(); var filepath = System.IO.Path.Combine(ImageSaverUtils.GetPhotosFileFolder(), filename); var file = new Java.IO.File(filepath); byte[] thumbnail = ImageResizer.ResizeImageAndroid(bytes, thumbWidth, thumbHeight, THUMBNAIL_QUALITY); using (var output = new Java.IO.FileOutputStream(file)) { try { output.Write(bytes); PoiDatabase poiDatabase = new PoiDatabase(); string jsonCategories = JsonConvert.SerializeObject(_context.Settings.Categories); var tag = _context.MyLocationPlaceInfo.PlaceName + " -> "; if (_context.SelectedPoi != null) { tag += _context.SelectedPoi.Poi.Name; } else { tag += Android.App.Application.Context.Resources.GetText(Resource.String.Common_Heading); tag += _context.HeadingX.HasValue ? $" {GpsUtils.Normalize360((_context.HeadingX.Value)):F0}°" : "?°"; } PhotoData photodata = new PhotoData { Tag = tag, Datetime = DateTime.Now, DatetimeTaken = DateTime.Now, PhotoFileName = filename, Longitude = _context.MyLocation.Longitude, Latitude = _context.MyLocation.Latitude, Altitude = _context.MyLocation.Altitude, Heading = (_context.HeadingX ?? 0) + _context.HeadingCorrector, LeftTiltCorrector = _context.LeftTiltCorrector, RightTiltCorrector = _context.RightTiltCorrector, Thumbnail = thumbnail, JsonCategories = jsonCategories, ViewAngleVertical = _context.ViewAngleVertical, ViewAngleHorizontal = _context.ViewAngleHorizontal, PictureWidth = imgWidth, PictureHeight = imgHeight, MinAltitude = _context.Settings.MinAltitute, MaxDistance = _context.Settings.MaxDistance, FavouriteFilter = _context.ShowFavoritesOnly, ShowElevationProfile = _context.Settings.ShowElevationProfile }; if (_context.ElevationProfileData != null) { photodata.JsonElevationProfileData = _context.ElevationProfileData.Serialize(); } poiDatabase.InsertItem(photodata); } catch (Java.IO.IOException e) { e.PrintStackTrace(); } finally { _Image.Close(); } } }