示例#1
0
        public override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (requestCode == CAPTURE_PHOTO)
            {
                if (resultCode == Result.Ok)
                {
                    // Display saved image
                    Bitmap bitmap = POIService.GetImage(_poi.Id);
                    _poiImageView.SetImageBitmap(bitmap);

                    // Dispose image after upload
                    if (bitmap != null)
                    {
                        bitmap.Dispose();
                        bitmap = null;
                    }
                }
                else
                {
                    // Let the user know the photo was cancelled
                    Toast.MakeText(Activity, "No picture captured.", ToastLength.Short).Show();
                }
            }
            else
            {
                base.OnActivityResult(requestCode, resultCode, data);
            }
        }
示例#2
0
        private async void CreateOrUpdatePOIAsync(PointOfInterest poi)
        {
            POIService service = new POIService();

            if (!service.isConnected(activity))
            {
                Toast toast = Toast.MakeText(activity, "Not connected to the internet. Please, check your device network settings.", ToastLength.Short);
                toast.Show();
                return;
            }

            Bitmap bitmap = null;

            if (_poi.Id > 0)
            {
                bitmap = POIService.GetImage(_poi.Id);
            }

            string response = null;

            if (bitmap != null)
            {
                response = await service.CreateOrUpdatePOIAsync(_poi, bitmap);
            }
            else
            {
                response = await service.CreateOrUpdatePOIAsync(_poi);
            }

            if (!string.IsNullOrEmpty(response))
            {
                Toast toast = Toast.MakeText(activity, String.Format("{0} saved.", _poi.Name), ToastLength.Short);
                toast.Show();

                DBManager.Instance.SavePOI(poi);

                if (!POIListActivity.isDualMode)
                {
                    activity.Finish();
                }
            }
            else
            {
                Toast toast = Toast.MakeText(activity, "Something went wrong!", ToastLength.Short);
                toast.Show();
            }


            if (bitmap != null)
            {
                bitmap.Dispose();
                bitmap = null;
            }
        }