コード例 #1
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            FacebookSdk.SdkInitialize(this);
            SetFullscreenOptions();
            SetContentView(Resource.Layout.StartActivity);
            progressHelper = new ProgressDialogHelper(this);
            SetupViews();
            var gps = new GpsLocationService(this, this);

            if (!gps.CanGetLocation)
            {
                settingsAlertIsShow = true;
                gps.ShowSettingsAlert();
            }

            try
            {
                userIsLogged = await SignInUser();
            }
            catch (UserHasToSetNickNameException exc)
            {
                logoLayout.Visibility        = ViewStates.Gone;
                setUserNameLayout.Visibility = ViewStates.Visible;
                return;
            }
            catch (Exception exc)
            {
                AlertsService.ShowAlertDialog(this, "Wystąpił problem z połączeniem z serwerem. Spróbuj ponownie później");
                return;
            }

            if (!settingsAlertIsShow)
            {
                StartMainOrLoginActivity(userIsLogged);
            }
            else
            {
                actionToExecuteAfterCloseSettingsDialog = StartMainOrLoginActivity;
            }
        }
コード例 #2
0
        private void ImgBtnHomeLocalization_Click(object sender, EventArgs e)
        {
            var confirmMessage = "Czy na pewno chcesz ustaliæ aktualn¹ lokalizacjê i ustawiæ j¹ jako domow¹?";

            AlertsService.ShowConfirmDialog(activity, confirmMessage, async() =>
            {
                this.progressDialogHelper.ShowProgressDialog("Trwa ustalanie Twojej aktualnej lokalizacji");
                try
                {
                    if (!this.gpsService.CanGetLocation)
                    {
                        AlertsService.ShowLongToast(activity, "W³¹cz gps w ustawieniach");
                    }
                    else
                    {
                        var location = this.gpsService.GetLocation();
                        var address  = await this.googleMapsAPIService.GetAddress(location.Latitude, location.Longitude);
                        appSettings.LocationSettings.Latitude        = location.Latitude;
                        appSettings.LocationSettings.Longitude       = location.Longitude;
                        appSettings.LocationSettings.LocationAddress = address;
                        SetAppSettings(appSettings);
                        SetHomeLocationSettings(appSettings);
                        if (address != string.Empty)
                        {
                            var infoMessage = String.Format("Adres lokalizacji to w przybli¿eniu: {0}. Na odczyt lokalizacji wp³ywa wiele czynników dlatego wiemy, ¿e adres mo¿e nie byæ w 100% idealny. Twoja lokalizacja wraz z adresem nie bêdzie nikomu udostêpniona.", address);
                            AlertsService.ShowAlertDialog(activity, infoMessage);
                        }
                    }
                }
                catch (Exception)
                {
                    AlertsService.ShowLongToast(activity, "Wyst¹pi³ problem z okreœleniem Twojej lokalizacji. Spróbuj ponownie póŸniej");
                }
                finally
                {
                    this.progressDialogHelper.CloseProgressDialog();
                }
            });
        }