Пример #1
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);
            }
        }
        public async void DownloadPoisListAsync()
        {
            POIService service = new POIService();

            if (!service.isConnected(activity))
            {
                Toast toast = Toast.MakeText(activity,
                                             "Not conntected to 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
        public async void DeletePOIAsync()
        {
            POIService service = new POIService();

            if (!service.isConnected(activity))
            {
                Toast toast = Toast.MakeText(activity,
                                             "Not conntected to 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();
            }
        }
Пример #4
0
        public async Task <BaiYeMapItem> Test(string loc)
        {
            // return OpenCC.Converter.Trad2Simple("紹興路") + "=" + OpenCC.Converter.Trad2Simple("绍兴路");
            POIService      poiservice = new POIService(_baiyecontext, _logger);
            BaiYeMapService service    = new BaiYeMapService(ossOption, baiduapiOption, _baiyecontext, _logger, poiservice);

            return(await service.GetMapInfo("绍兴路", false));
        }
 public WeixinMessageHandler(XDocument input, PostModel post,
                             OssOption ossoption,
                             BaiduApiOption baiduapiOption,
                             BaiYeContext baiyecontext, ILogger logger) : base(input, post)
 {
     _logger    = logger;
     POIService = new POIService(baiyecontext, _logger);
     service    = new BaiYeMapService(ossoption, baiduapiOption, baiyecontext, _logger, POIService);
 }
Пример #6
0
        private async void CreateOrUpdatePOIAsync(PointOfInterest poi)
        {
            POIService service = new POIService();

            if (!service.isConnected(activity))
            {
                Toast toast = Toast.MakeText(activity,
                                             "Not conntected to 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;

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

            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();
            }
        }
Пример #7
0
 public override void OnActivityResult(int requestCode, int resultCode, Intent data)
 {
     if (requestCode == CAPTURE_PHOTO)
     {
         if (resultCode == (int)Result.Ok)
         {
             Bitmap bitmap = POIService.GetImage(_poi.Id);
             _poiImageView.SetImageBitmap(bitmap);
             if (bitmap != null)
             {
                 bitmap.Dispose();
                 bitmap = null;
             }
         }
         else
         {
             Toast.MakeText(Activity, "No picture captured.", ToastLength.Short).Show();
         }
     }
     else
     {
         base.OnActivityResult(requestCode, resultCode, data);
     }
 }