public HomeViewModel(IDeviceService deviceService, IShareService shareService, ISettings settings, ILocationService locationService, IMvxMessenger messenger, ISendPositionService sendPositionService, IPopupService popupService, ITimerService timer) { _deviceService = deviceService; _shareService = shareService; _settings = settings; _locationService = locationService; _messenger = messenger; _sendPositionService = sendPositionService; _popupService = popupService; _timer = timer; Title = "TrackMe"; PossibleTimes = new PossibleTimeProvider().GetPossibleTimes().ToObservable(); SelectedTime = new PossibleTime(240); _deviceService.LocationStatusChanged += (sender, args) => { GpsStatus = args.Status; if (!_locationService.IsWatching && args.Status == LocationStatus.Started) { _locationService.StartWatching(); } }; GpsStatus = _deviceService.LocationStatus; _locationMessageToken = _messenger.Subscribe <LocationMessage>(GotLocation); _requestStartTrackingToken = _messenger.Subscribe <RequestStartTrackingMessage>(OnRequestStartTracking); _messenger.Subscribe <CloseAppMessage>(message => { _messenger.Publish(new StopTrackingMessage(this, true, Token, PrivateToken, _timeEnd)); }); TrackConnectionStatus(); }
public LocationTrackerService(IMvxMessenger messenger, ISendPositionService sendPositionService, ISettings settings) { _messenger = messenger; _sendPositionService = sendPositionService; _settings = settings; TryRestore(); }
public LocationTrackerService() { _sendPositionService = Mvx.Resolve <ISendPositionService>(); _settings = Mvx.Resolve <ISettings>(); _messenger = Mvx.Resolve <IMvxMessenger>(); TryRestore(); }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { // TODO this method can return value that force to redeliver intent, but app is still crashing, because Resolvers aren't working due to main process kill if (intent == null) { _nullInttent = true; StopSelf(); } else { _sendPositionService = Mvx.Resolve <ISendPositionService>(); var extras = intent.Extras; _token = extras.GetString("token"); _duration = extras.GetInt("duration"); _startTime = DateTime.Now; Subscribe(); } return(base.OnStartCommand(intent ?? new Intent(this, typeof(LocationTrackerService)), flags, startId)); }