private IEnumerator _CheckGPS()
    {
        bool mustCheckGPS = false;

        GPSService.StartGPS();

        if (!GPSService.IsActive())
        {
            gpsStatus.text = "Aguardando ativação do GPS no celular";
            mustCheckGPS   = true;
        }
        else if (GPSService.location[0] == 0.0 || GPSService.location[1] == 0.0)
        {
            GPSService.ReceivePlayerLocation();
            gpsStatus.text = "Obtendo localização...";
            mustCheckGPS   = true;
        }
        else
        {
            gpsStatus.text = "Localização obtida";
        }

        if (mustCheckGPS)
        {
            yield return(new WaitForSeconds(2));

            yield return(StartCoroutine(_CheckGPS()));
        }
        else
        {
            yield return(null);
        }
    }
Exemple #2
0
        // Create the delegate that invokes methods for the timer.
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Instance = this;
            base.OnCreate(bundle);
            service = new GPSService();

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            _addressText = FindViewById<TextView>(Resource.Id.txtAddress);
            _locationText = FindViewById<TextView>(Resource.Id.txtLocation);
            _remarksText = FindViewById<TextView>(Resource.Id.txtRemarks);
            FileText = FindViewById<TextView>(Resource.Id.FileText);
            var button = FindViewById<Button>(Resource.Id.MyButton);

            Console.WriteLine("Starting app");
            RegisterService();

            TimerExampleState s = new TimerExampleState();
            TimerCallback timerDelegate = new TimerCallback(CheckStatus);
            Timer timer = new Timer(timerDelegate, s, 1000, 1000);

            // Keep a handle to the timer, so it can be disposed.
            s.tmr = timer;

            //service.startTimer();
            while (s.tmr != null)
                Thread.Sleep(0);
            Console.WriteLine("Timer example done.");
        }
        //private void SetUpMap(View view)
        //{
        //    if (GMap == null)
        //    {
        //

        //        FragmentManager.FindViewById<MapView>(Resource.Id.fragmentMap3).GetMapAsync(this);
        //    }
        //}

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = null;

            view    = inflater.Inflate(Resource.Layout.driver_tasks, container, false);
            lstTask = view.FindViewById <ListView>(Resource.Id.tasklistview);

            var result = GetTasks();

            if (result.Result == TaskStatus.OK)
            {
                //LayoutInflater layoutInflater = LayoutInflater.From(Activity);
                //ViewGroup view_task = (ViewGroup)layoutInflater.Inflate(Resource.Layout.driver_header_task, null);
                //lstTask.AddHeaderView(view_task);
                bundle      = savedInstanceState;
                _gpsService = new GPSService(Activity);
                _gpsService.UpdateLocation();
            }
            else
            {
                FragmentTransaction  transaction1 = this.FragmentManager.BeginTransaction();
                TaskNotFoundActivity content      = new TaskNotFoundActivity();
                transaction1.Replace(Resource.Id.frameDriverlayout, content).AddToBackStack(null).Commit();
            }
            return(view);
        }
        private async void OnAppResume(object sender, Page e)
        {
            var canUseLocationService = await GPSService.CanUseLocationService();

            if (canUseLocationService)
            {
                App.Current.MainPage = new LoginPage();
            }
        }
        private async void CheckPermissionAndGPS()
        {
            var canUseLocationService = await GPSService.RequestLocationService();

            if (canUseLocationService)
            {
                App.Current.MainPage = new LoginPage();
            }
        }
Exemple #6
0
        private void StartGPSService()
        {
            LocationManager manager = (LocationManager)GetSystemService(Context.LocationService);
            GPSService      service = new GPSService(manager);

            if (service.IsSupported)
            {
                service.StartGettingLocation();
            }
        }
Exemple #7
0
 public void TestGeoCoordinates()
 {
     var service = new GPSService();
     var result  = service.GetCartesianPoint(new SmartPlayerAPI.ViewModels.Pitch.PitchCornersPoints()
     {
         LeftUpPoint    = new GPSPoint(54.370416, 18.630052),
         LeftDownPoint  = new GPSPoint(54.370014, 18.629365),
         RightUpPoint   = new GPSPoint(54.369786, 18.631127),
         RightDownPoint = new GPSPoint(54.369383, 18.630432)
     }, new GPSPoint(54.369568, 18.630247));
 }
Exemple #8
0
        public async void OpenMapDirection(string directionParam)
        {
            var latLon = ConvertParameterFromWebView <OpenDirectionParam>(directionParam);

            if (latLon != null)
            {
                await GPSService.OpenMapDirection(latLon.Latitude, latLon.Longitude);
            }
            else
            {
                PageService.DisplayAlert("แจ้งเตือน", "ไม่สามารถเปิดแผนที่ได้ กรุณาลองใหม่อีกครัง", "ปิด");
            }
        }
Exemple #9
0
        private async void NavigateToFirstPage()
        {
            var isGpsReady = await GPSService.CanUseLocationService();

            if (isGpsReady)
            {
                MainPage = new LoginPage();
            }
            else
            {
                MainPage = new LocationPermissionPage();
            }
        }
    public void Start()
    {
        previousView = "Plants";

        detailsCardObj.SetActive(true);
        addressCardObj.SetActive(false);
        sideWalkSizeObj.SetActive(false);
        if (!UserService.user.IsMinor())
        {
            termsToggle.gameObject.SetActive(false);
        }

        camService.resetFields("pot_seeding");
        StartCoroutine(_CheckCapturedPhoto());

        GPSService.StartGPS();
    }
Exemple #11
0
 public SensorsController(SmartPlayerContext smartPlayerContext,
                          IAccelerometerAndGyroscopeRepository accelerometerAndGyroscopeRepository,
                          IGPSLocationRepository gpsLocationRepository,
                          IPlayerInGameRepository playerInGameRepository,
                          IModuleRepository moduleRepository,
                          IMapper mapper,
                          IPitchRepository pitchRepository,
                          IGameRepository gameRepository)
 {
     _smartPlayerContext = smartPlayerContext;
     _accelerometerAndGyroscopeRepository = accelerometerAndGyroscopeRepository;
     GPSLocationRepository   = gpsLocationRepository;
     _playerInGameRepository = playerInGameRepository;
     _moduleRepository       = moduleRepository;
     _mapper          = mapper;
     _pitchRepository = pitchRepository;
     _gameRepository  = gameRepository;
     _gpsService      = new GPSService();
 }
Exemple #12
0
        protected override void OnDestroy()
        {
            string dir_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            File.Delete(dir_path + "user_data.txt");

            //CrossSettings.Current.AddOrUpdateValue("PresenceOnPage", "false");
            StaticUser.PresenceOnPage = false;
            //CrossSettings.Current.AddOrUpdateValue("role", "");
            //StartUp.StopTracking(this);

            if (StaticDriver.busy == "0")
            {
                _gpsService = new GPSService(this);
                //_gpsService.UpdateLocation();
                _gpsService.RemoveLocation();
            }

            base.OnDestroy();
            //StartUp.StopTracking();
        }
Exemple #13
0
        public WebSocketService NewServiceMap(WebSocketServiceManager _manager, IWebSocketConnection socket)
        {
            WebSocketService service = null;

            switch (_manager.managerName)
            {
            case "/gps":
                service = new GPSService(_manager, socket);
                //service.
                break;

            case "/uhf":
                service = new UHFService(_manager, socket);
                break;

            case "/green_light":
                service = new GreenLightService(_manager, socket);
                break;

            case "/red_light":
                service = new RedLightService(_manager, socket);
                break;

            case "/yellow_light":
                service = new YellowLightService(_manager, socket);
                break;

            case "/fan":
                service = new FanService(_manager, socket);
                break;

            case "/engine":
                service = new EngineService(_manager, socket);
                break;
            }
            return(service);
        }
Exemple #14
0
        private void Leaveprofile()
        {
            string dir_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            File.Delete(dir_path + "user_data.txt");

            //CrossSettings.Current.AddOrUpdateValue("PresenceOnPage", "false");
            StaticUser.PresenceOnPage = false;
            CrossSettings.Current.AddOrUpdateValue("role", "");
            StartUp.StopTracking(this);


            if (StaticDriver.busy == "0")
            {
                _gpsService = new GPSService(this);
                //_gpsService.UpdateLocation();
                _gpsService.RemoveLocation();
            }

            Intent content1 = new Intent(this, typeof(MainActivity));

            StartActivity(content1);
            this.Finish();
        }
Exemple #15
0
        public WebSocketService NewServiceMap(WebSocketServiceManager _manager, IWebSocketConnection socket)
        {
            WebSocketService service = null;

            switch (_manager.managerName)
            {
            case "/" + TargetDeiveName.GPS:
                service = new GPSService(_manager, socket);
                break;

            case "/" + TargetDeiveName.UHF:
                service = new UHFService(_manager, socket);
                break;

            case "/" + TargetDeiveName.绿灯:
                service = new GreenLightService(_manager, socket);
                break;

            case "/" + TargetDeiveName.红灯:
                service = new RedLightService(_manager, socket);
                break;

            case "/" + TargetDeiveName.黄灯:
                service = new YellowLightService(_manager, socket);
                break;

            case "/" + TargetDeiveName.电风扇:
                service = new FanService(_manager, socket);
                break;

            case "/" + TargetDeiveName.电机:
                service = new EngineService(_manager, socket);
                break;
            }
            return(service);
        }
Exemple #16
0
 public GPSController(GPSService gpsService)
 {
     this._service = gpsService;
 }
Exemple #17
0
 public static void Initialize(Context context)
 {
     _context = context;
     GPSService.Init(new GPSServiceAndroid());
 }
Exemple #18
0
 private async void GetCoordonne(string obj)
 {
     Coordonnee = await GPSService.Get(SelectedAdresse);
 }
    private string CheckFields()
    {
        string message = CHECK_OK;

        GPSService.ReceivePlayerLocation();

        if (CURRENT_GET_LOCATION == "GPS" &&
            (GPSService.location[0] == 0.0 ||
             GPSService.location[1] == 0.0 ||
             !GPSService.IsActive())
            )
        {
            message = "Ainda não obtivemos sua geolocalização. Verifique se seu GPS está ligado.";
        }

        if (camService.photoBase64 == null)
        {
            message = "Capture ou selecione a foto do local que deseja realizar o plantio.";
        }

        if (placeDropdown.captionText.text == "Calçada" &&
            sideWalkSize.text.Length < 2)
        {
            message = "Escreva o tamanho de sua calçada em centímetros.";
        }

        if (plantName.text.Length < 2)
        {
            message = "O nome da muda deve possuir, pelo menos, dois caracteres.";
        }

        if (requesterName.text.Length < 3)
        {
            message = "O nome do solicitante deve possuir, pelo menos, três caracteres.";
        }

        if (requesterPhone.text.Length < 8)
        {
            message = "O telefone do solicitante deve conter, pelo menos, oito dígitos.";
        }

        if (UserService.user.IsMinor() && !termsToggle.isOn)
        {
            message = "Você deve concordar com o termo de ciência de pedidos no Minha Árvore.";
        }

        if (quantityField.text.Length < 1 || int.Parse(quantityField.text) < 1)
        {
            message = "Você deve pedir, pelo menos, uma planta no campo de quantidade.";
        }

        if (CURRENT_GET_LOCATION == "MANUAL")
        {
            if (streetField.text.Length < 5 ||
                numberField.text.Length < 1 ||
                neighborhoodField.text.Length < 3 ||
                cityField.text.Length < 2 ||
                zipField.text.Length < 8)
            {
                message = "Preencha seu endereço por completo.";
            }
        }


        return(message);
    }
Exemple #20
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.driver_map, container, false);

            lstTask = view.FindViewById <ListView>(Resource.Id.tasklistview);
            var result = GetTasks();

            if (result.Result == TaskStatus.OK)
            {
                // Use this to return your custom view for this Fragment
                mMapView = view.FindViewById <MapView>(Resource.Id.fragmentMap3);
                var layout       = view.FindViewById <SlidingUpPanelLayout>(Resource.Id.sliding_layout);
                var btn_open_map = view.FindViewById <Button>(Resource.Id.btn_open_map);
                view.FindViewById <TextView>(Resource.Id.txt_title_tasks).MovementMethod = new LinkMovementMethod();
                lstTask = view.FindViewById <ListView>(Resource.Id.tasklistview);

                _gpsService = new GPSService(Activity);
                _gpsService.UpdateLocation();
                // layout.ShadowDrawable = Resources.GetDrawable(Resource.Drawable.above_shadow);
                layout.AnchorPoint     = 0.3f;
                layout.PanelExpanded  += (s, e) => Log.Info(Tag, "PanelExpanded");
                layout.PanelCollapsed += (s, e) => Log.Info(Tag, "PanelCollapsed");
                layout.PanelAnchored  += (s, e) => Log.Info(Tag, "PanelAnchored");
                layout.PanelSlide     += (s, e) =>
                {
                    if (e.SlideOffset < 0.2)
                    {
                        //if (SupportActionBar.IsShowing)
                        //    SupportActionBar.Hide();
                    }
                    else
                    {
                        //if (!SupportActionBar.IsShowing)
                        //    SupportActionBar.Show();
                    }
                };

                var actionBarHidden = savedInstanceState != null &&
                                      savedInstanceState.GetBoolean(SavedStateActionBarHidden, false);
                //if (actionBarHidden)
                //    SupportActionBar.Hide();
                btn_open_map.Click += async delegate
                {
                    var location = new Location(StaticTask.way_points[1].lat, StaticTask.way_points[1].lng);
                    var options  = new MapLaunchOptions
                    {
                        NavigationMode = NavigationMode.Driving
                    };
                    try
                    {
                        await Map.OpenAsync(location, options);
                    }
                    catch (System.Exception ex)
                    {
                        Toast.MakeText(Activity, ex.Message, ToastLength.Long);
                    }
                };

                MapsInitializer.Initialize(Activity);
                // HomeService.SetListViewHeightBasedOnChildren(lstTask);

                switch (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Activity))
                {
                case ConnectionResult.Success:
                    Toast.MakeText(Activity, "SUCCESS", ToastLength.Long).Show();
                    mMapView.OnCreate(savedInstanceState);
                    mMapView.GetMapAsync(this);
                    break;

                case ConnectionResult.ServiceMissing:
                    Toast.MakeText(Activity, "ServiceMissing", ToastLength.Long).Show();
                    break;

                case ConnectionResult.ServiceVersionUpdateRequired:
                    Toast.MakeText(Activity, "Update", ToastLength.Long).Show();
                    break;

                default:
                    Toast.MakeText(Activity, GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Activity), ToastLength.Long).Show();
                    break;
                }
            }
            else
            {
                FragmentTransaction  transaction1 = this.FragmentManager.BeginTransaction();
                TaskNotFoundActivity content      = new TaskNotFoundActivity();
                transaction1.Replace(Resource.Id.frameDriverlayout, content);
                transaction1.Commit();
            }

            return(view);
        }
Exemple #21
0
 public static void Initialize()
 {
     GPSService.Init(new GPSServiceIOS());
 }
Exemple #22
0
        public async Task <object[]> GetCurrentLocation(string param)
        {
            var location = await GPSService.GetCurrentLocation();

            return(new object[] { location });
        }