Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public async void DeletePOIAsync()
        {
            POIService service = new POIService();

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

            string response = await service.DeletePOIAsync(_poi.Id);

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

                DBManager.Instance.DeletePOI(_poi.Id);

                if (!POIListActivity.isDualMode)
                {
                    activity.Finish();
                }
            }
            else
            {
                Toast toast = Toast.MakeText(activity, "Something went wrong!", ToastLength.Short);
                toast.Show();
            }
        }
Exemplo n.º 3
0
        void NewPhotoClicked(object sender, EventArgs e)
        {
            if (_poi.Id <= 0)
            {
                Toast.MakeText(activity, "You must save the POI before attaching a photo.", ToastLength.Short).Show();
                return;
            }

            Intent              cameraIntent   = new Intent(MediaStore.ActionImageCapture);
            PackageManager      packageManager = Activity.PackageManager;
            IList <ResolveInfo> activities     = packageManager.QueryIntentActivities(cameraIntent, 0);

            if (activities.Count == 0)
            {
                Toast.MakeText(activity, "No camera app available.", ToastLength.Short).Show();
            }
            else
            {
                string          path      = POIService.GetFileName(_poi.Id);
                Java.IO.File    imageFile = new Java.IO.File(path);
                Android.Net.Uri imageUri  = Android.Net.Uri.FromFile(imageFile);
                cameraIntent.PutExtra(MediaStore.ExtraOutput, imageUri);
                cameraIntent.PutExtra(MediaStore.ExtraSizeLimit, 1 * 1024 * 1024);
                StartActivityForResult(cameraIntent, CAPTURE_PHOTO);
            }
        }
Exemplo n.º 4
0
        public async void DownloadPoisListAsync()
        {
            POIService service = new POIService();

            if (!service.isConnected(activity))
            {
                Toast toast = Toast.MakeText(activity, "Not conntected to the internet. Please, check your device network settings.", ToastLength.Short);
                toast.Show();
                poiListData = DBManager.Instance.GetPOIListFromCache();
            }
            else
            {
                progressBar.Visibility = ViewStates.Visible;
                poiListData            = await service.GetPOIListAsync();

                // Clear cached data
                DBManager.Instance.ClearPOICache();

                // Save updated POI data
                DBManager.Instance.InsertAll(poiListData);

                progressBar.Visibility = ViewStates.Gone;
            }

            poiListAdapter   = new POIListViewAdapter(activity, poiListData);
            this.ListAdapter = poiListAdapter;
            ListView.Post(() => {
                ListView.SetSelection(scrollPosition);
            });
        }
Exemplo n.º 5
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;
            }
        }