Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.POIDetail);

            _nameEditText     = FindViewById <EditText>(Resource.Id.nameEditText);
            _descrEditText    = FindViewById <EditText>(Resource.Id.descEditText);
            _addrEditText     = FindViewById <EditText>(Resource.Id.addeditText);
            _latEditText      = FindViewById <EditText>(Resource.Id.latEditText);
            _longEditText     = FindViewById <EditText>(Resource.Id.longEditText);
            _poiImageView     = FindViewById <ImageView>(Resource.Id.poiImageView);
            _photoImageButton = FindViewById <ImageButton>(Resource.Id.newPictureButton);
            _locMgr           = GetSystemService(Context.LocationService) as LocationManager;

            _locationImageButton        = FindViewById <ImageButton>(Resource.Id.locationImageButton);
            _locationImageButton.Click += GetLocationClicked;

            _mapImageButton        = FindViewById <ImageButton>(Resource.Id.mapImageButton);
            _mapImageButton.Click += MapImageClicked;

            _photoImageButton.Click += NewPhotoClicked;

            if (Intent.HasExtra("poiId"))
            {
                int poiId = Intent.GetIntExtra("poiId", -1);
                _poi = POIData.Service.GetPOI(poiId);
                UpdateUI();
            }
            else
            {
                _poi = new PointOfInterest();
            }

            if (Intent.HasExtra("poiId"))
            {
                int poiId = Intent.GetIntExtra("poiId", -1);
                _poi = POIData.Service.GetPOI(poiId);
                Android.Graphics.Bitmap poiImage = POIData.GetImageFile(_poi.Id.Value);
                _poiImageView.SetImageBitmap(poiImage);
                if (poiImage != null)
                {
                    poiImage.Dispose();
                }
            }
            else
            {
                _poi = new PointOfInterest();
            }
        }
Example #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView;

            if (view == null)
            {
                view = _context.LayoutInflater.Inflate(Resource.Layout.POIListItem, null);
            }

            var poi = POIData.Service.POIs[position];

            view.FindViewById <TextView>(Resource.Id.nameTextView).Text = poi.Name;
            if (string.IsNullOrWhiteSpace(poi.Address))
            {
                view.FindViewById <TextView>(Resource.Id.addressTextView).Visibility = ViewStates.Gone;
            }
            else
            {
                view.FindViewById <TextView>(Resource.Id.addressTextView).Text = poi.Address;
            }

            if (CurrentLocation != null && poi.Latitude.HasValue && poi.Longitude.HasValue)
            {
                var poiLocation = new Location(String.Empty);
                poiLocation.Latitude  = poi.Latitude.Value;
                poiLocation.Longitude = poi.Longitude.Value;
                float distance = CurrentLocation.DistanceTo(poiLocation) * 0.000621371F; // this magic number converts from meters to miles

                view.FindViewById <TextView>(Resource.Id.distanceTextView).Text = String.Format("{0:0,0.00} miles", distance);
            }
            else
            {
                view.FindViewById <TextView>(Resource.Id.distanceTextView).Text = "??";
            }

            var poiImage = POIData.GetImageFile(poi.Id.Value);

            view.FindViewById <ImageView>(Resource.Id.poiImageView).SetImageBitmap(poiImage);
            if (poiImage != null)
            {
                poiImage.Dispose();
            }

            return(view);
        }
Example #3
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == REQUEST_CODE_CAPTURE_PHOTO)
     {
         if (resultCode == Result.Ok)
         {
             var poiImage = POIData.GetImageFile(_poi.Id.Value);
             _poiImageView.SetImageBitmap(poiImage);
             if (poiImage != null)
             {
                 poiImage.Dispose();
             }
             else
             {
                 var toast = Toast.MakeText(this, "No picture captured", ToastLength.Short);
                 toast.Show();
             }
         }
     }
     else
     {
         base.OnActivityResult(requestCode, resultCode, data);
     }
 }
Example #4
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == CAPTURE_PHOTO)
     {
         if (resultCode == Result.Ok)
         {    // display saved image
             Android.Graphics.Bitmap poiImage = POIData.GetImageFile(_poi.Id.Value);
             _poiImageView.SetImageBitmap(poiImage);
             if (poiImage != null)
             {
                 poiImage.Dispose();
             }
         }
         else        // let the user know the photo was cancelled
         {
             Toast toast = Toast.MakeText(this, "No picture captured.", ToastLength.Short);
             toast.Show();
         }
     }
     else
     {
         base.OnActivityResult(requestCode, resultCode, data);
     }
 }