Esempio n. 1
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (resultCode == PoiSelectActivity.RESULT_OK)
            {
                var id = data.GetLongExtra("Id", 0);

                var selectedPoint = (id == (long)PoiId.CURRENT_LOCATION)
                    ? PoiSelectActivity.GetMyLocationPoi(AppContext)
                    : AppContext.Database.GetItem(id);

                if (requestCode == PoiSelectActivity.REQUEST_SELECT_CAMERADIRECTION)
                {
                    if (!TryGetGpsLocation(out GpsLocation location, false))
                    {
                        PopupHelper.ErrorDialog(this, Resource.String.PhotoParameters_SetCameraLocationFirst);
                    }
                    var bearing = GpsUtils.QuickBearing(location, new GpsLocation(selectedPoint.Longitude, selectedPoint.Latitude, selectedPoint.Altitude));
                    UpdateHeading(bearing);
                }
                else if (requestCode == PoiSelectActivity.REQUEST_SELECT_CAMERALOCATION)
                {
                    var location = new GpsLocation(selectedPoint.Longitude, selectedPoint.Latitude, selectedPoint.Altitude);
                    UpdateCameraLocation(location);
                    UpdateCameraAltitude(location);
                }
            }
        }
Esempio n. 2
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (requestCode == PoiSelectActivity.REQUEST_SELECT_DOWNLOADELEVATIONDATAAREA)
            {
                if (resultCode == PoiSelectActivity.RESULT_OK)
                {
                    var id = data.GetLongExtra("Id", 0);

                    _selectedPoint = (id == (long)PoiId.CURRENT_LOCATION)
                        ? PoiSelectActivity.GetMyLocationPoi(AppContext)
                        : AppContext.Database.GetItem(id);

                    OnSelectionUpdated(_selectedPoint);
                    CalculateDownloadSize(_selectedPoint);
                }
            }
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AppContextLiveData.Instance.SetLocale(this);
            Platform.Init(this, savedInstanceState);

            if (AppContextLiveData.Instance.IsPortrait)
            {
                SetContentView(Resource.Layout.AddElevationDataActivityPortrait);
            }
            else
            {
                SetContentView(Resource.Layout.AddElevationDataActivityLandscape);
            }

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);

            ActionBar.SetDisplayShowHomeEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowTitleEnabled(true);
            ActionBar.SetTitle(Resource.String.DownloadElevationDataActivity);

            FindViewById <Button>(Resource.Id.buttonSave).SetOnClickListener(this);
            FindViewById <Button>(Resource.Id.buttonSelect).SetOnClickListener(this);
            FindViewById <LinearLayout>(Resource.Id.linearLayoutSelectedPoint).SetOnClickListener(this);
            FindViewById <RadioButton>(Resource.Id.radioButton100km).SetOnClickListener(this);
            FindViewById <RadioButton>(Resource.Id.radioButton200km).SetOnClickListener(this);
            FindViewById <RadioButton>(Resource.Id.radioButton300km).SetOnClickListener(this);

            var id = Intent.GetLongExtra("Id", -1);

            if (id != -1)
            {
                _oldDedItem    = AppContext.Database.GetDownloadedElevationDataItem(id);
                _selectedPoint = new Poi()
                {
                    Latitude  = _oldDedItem.Latitude,
                    Longitude = _oldDedItem.Longitude,
                    Altitude  = _oldDedItem.Altitude,
                    Name      = _oldDedItem.PlaceName,
                    Country   = _oldDedItem.Country
                };
                SetDownloadDistance(_oldDedItem.Distance);
                FindViewById <Button>(Resource.Id.buttonSelect).Enabled = false;
            }
            else if (Peaks360Lib.Utilities.GpsUtils.HasLocation(AppContext.MyLocation))
            {
                _selectedPoint = PoiSelectActivity.GetMyLocationPoi(AppContext);
                FindViewById <Button>(Resource.Id.buttonSelect).Enabled = true;
            }
            else
            {
                _selectedPoint = GetUnknownPoi(AppContext);
                FindViewById <Button>(Resource.Id.buttonSelect).Enabled = true;
            }

            OnSelectionUpdated(_selectedPoint);
            CalculateDownloadSize(_selectedPoint);

            Task.Run(async() => { _allElevationData = await AppContext.Database.GetDownloadedElevationDataAsync(); });
        }