Пример #1
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();
            }
        }
Пример #2
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);
            });
        }
Пример #3
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;
            }
        }