Exemplo n.º 1
0
        public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.Back)
            {
                if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean("UseGPS", true))
                {
                    StartService(new Intent("ru.nwdgroup.geolocationservice"));
                    Requests.SetMode(UserInfo.UserId, "1");
                    Finish( );
                }
                else
                {
                    StopService(new Intent("ru.nwdgroup.geolocationservice"));

                    var dialog = new AlertDialog.Builder(this);

                    dialog.SetTitle(Resource.String.ChooseArea);
                    dialog.SetCancelable(true);
                    dialog.SetAdapter(UserInfo.AreasArrayAdapter, (sender, args) => ThreadPool.QueueUserWorkItem(o =>
                    {
                        Requests.SetArea(UserInfo.UserId, UserInfo.AreasId [args.Which]);
                        Requests.SetMode(UserInfo.UserId, "2");
                        RunOnUiThread(Finish);
                    }));

                    dialog.Show( );
                }
                return(true);
            }

            return(base.OnKeyDown(keyCode, e));
        }
Exemplo n.º 2
0
        private void ShowSetAreaDialog( )
        {
            var dialog = new AlertDialog.Builder(this);

            dialog.SetTitle(Resource.String.ChooseArea);
            dialog.SetCancelable(true);
            dialog.SetAdapter(UserInfo.AreasArrayAdapter, (sender, args) => ThreadPool.QueueUserWorkItem(o =>
            {
                Requests.SetArea(UserInfo.UserId, UserInfo.AreasId [args.Which]);
                PreferenceManager.GetDefaultSharedPreferences(this).Edit( ).PutBoolean("UseGPS", false).Commit( );
                Requests.SetMode(UserInfo.UserId, "2");
                StopService(new Intent("ru.nwdgroup.geolocationservice"));
            }));

            dialog.Show( );
        }