void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e) { try { //Device.BeginInvokeOnMainThread(() => //{ var position = e.Position; gp.SetLocationData(position, DateTimeOffset.Now, GpsPodatek.SwitchType.Podatek); //TODO malenkost bolje, vendar znaš še bolje? if (EnableSaveAcceleration) //TODO mislm da si tuki neki narobe razumu, povpraši! { Database.SaveItemAsync(gp); } MainActivity.Poz = position; /*if (EnableSaveAcceleration && (gp.MaxAccX_TS!=null || !lai.IsActive(SensorType.Accelerometer)) && (gp.LinMaxAccX_TS != null || !lai.IsActive(SensorType.LinearAcceleration))) //in pogoj je preventiva ker se praktično ne more ponovit le v primeru da se 2x isto pokliče event * { * Database.SaveItemAsync(gp); * }else if()// TODO DODEJ TUKI SE ELSE IF POGOJ ČE SO VSAJ GPS PODATKI DA VSAJ TE V BAZO RUKNE * { * * }*/ gp.resetLinearAccelerationData(); gp.resetAccelerationData(); //TODO tuki pošilji na mainactivity podatke gps tm pa pol na XForms -> IMPLEMENTED FOR CURRENT NEEDS //////////////////////////////////////// //NOTE:XAMARIN FORMS STVARI NE KLICAT V SERVISU, PA APLIKACIJSKE STVARI RAJŠ V APLIKACIJ SPREMINJI, ANDROID APP KER JE ANDROID SPECIFIC SERVIS //IN NE MORE SERVISA POSLUŠAT FORMS...// //UpdateMaps(position); //DependencyService.Get<ICommunication>().NewGpsData(position); //////////////////////////////////////// //}); if (thread != null) { thread.Abort(); } thread = new Thread(() => { Thread.CurrentThread.IsBackground = true; Thread.Sleep(5000); //11000 default //et.callEvent(); Looper.Prepare(); TimeoutThread(); handlermain.Post(() => //Device.BeginInvokeOnMainThread(() => { gp.SetLocationData(MainActivity.Poz, DateTimeOffset.Now, GpsPodatek.SwitchType.Izklop); Database.SaveItemAsync(gp); MainActivity.Poz = MainActivity.Poz; //just to trigger ui refresh tz.spremenivrednost("Omrežje"); }); }); thread.Start(); }catch (Exception ex) { //Toast.MakeText(this, ex.Message, ToastLength.Long).Show(); } }
public override void OnCreate() { mBinder = new LocalBinder(this); base.OnCreate(); Log.Debug(TAG, "OnCreate"); //Toast.MakeText(this, "Pride do Servisa", ToastLength.Long).Show(); /*if (MainActivity.InstanceCount < 1) * { * StartActivity(new Intent(this,typeof(MainActivity))); * }*/ //handler = new Handler(); handlermain = new Handler(Looper.MainLooper); //var test = ((FileHelper)new FileHelper()).GetLocalFilePath("BazaGpsPodatkov.db3"); lowController = new Wifi_coarse(this); lowController.Start(); //StartTrack(); //ta ali pa lowcontroller.start() je lahko naenkrat przgan drugac bo exception unhandled tz = new Sensors.TipZemljevida(); // za hendlanje izpisa na mapspageu tz.attach(tz); tdp = new TriDimPodatek(); gp = new GpsPodatek(); gp.resetAccelerationData(); gp.resetLinearAccelerationData(); //LastPosition = null; try { //LoadSave<string> ls = new LoadSave<string>(); //username = ls.LoadJson("username.json"); Json js = new Json(); username = js.LoadJson("username.json"); }catch (Exception e) { username = Guid.NewGuid().ToString(); } lai = new LinearAccelerationImplementation(); lai.SensorValueChanged += (s, a) => { //TODO - dodej še 12 polj za podatke linearnega senzorja v gpspodatek DB switch (a.SensorType) { case SensorType.Accelerometer: gp.CheckAccelerationData(((MotionVector)a.Value).X, ((MotionVector)a.Value).Y, ((MotionVector)a.Value).Z, DateTimeOffset.Now); tdp.Set(TriDimPodatek.Tip.Accelerometer, ((MotionVector)a.Value).X, ((MotionVector)a.Value).Y, ((MotionVector)a.Value).Z, DateTimeOffset.Now); break; case SensorType.LinearAcceleration: gp.CheckLinearAccelerationData(((MotionVector)a.Value).X, ((MotionVector)a.Value).Y, ((MotionVector)a.Value).Z, DateTimeOffset.Now); tdp.Set(TriDimPodatek.Tip.LinearAcceleration, ((MotionVector)a.Value).X, ((MotionVector)a.Value).Y, ((MotionVector)a.Value).Z, DateTimeOffset.Now); break; default: Console.WriteLine("noben senzor ne ustreza temu"); return; } Database3D.SaveItemAsync(tdp); }; try { sendToServer(); }catch (Exception e) { } }