Exemplo n.º 1
0
        public override void SetUp ()
        {
            base.SetUp ();

            RunAsync (async delegate {
                workspace = await DataStore.PutAsync (new WorkspaceData () {
                    Name = "Test",
                });

                user = await DataStore.PutAsync (new UserData () {
                    Name = "John Doe",
                    TrackingMode = TrackingMode.StartNew,
                    DefaultWorkspaceId = workspace.Id,
                });

                await SetUpFakeUser (user.Id);
                var activeManager = new ActiveTimeEntryManager ();
                await Util.AwaitPredicate (() => activeManager.ActiveTimeEntry != null);

                ServiceContainer.Register<ExperimentManager> (new ExperimentManager ());
                ServiceContainer.Register<ISyncManager> (Mock.Of<ISyncManager> (mgr => !mgr.IsRunning));
                ServiceContainer.Register<ActiveTimeEntryManager> (activeManager);
                ServiceContainer.Register<ITracker> (() => new FakeTracker ());
            });
        }
Exemplo n.º 2
0
        public override void OnDestroy ()
        {
            if (timeEntryManager != null) {
                timeEntryManager.PropertyChanged -= OnTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }

            base.OnDestroy ();
        }
        public override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            if (timeEntryManager == null) {
                timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
                timeEntryManager.PropertyChanged += OnTimeEntryManagerPropertyChanged;
            }

            ResetModel ();
        }
Exemplo n.º 4
0
        public void OnStart ()
        {
            // Hook up to time entry manager
            if (timeEntryManager == null) {
                timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
                timeEntryManager.PropertyChanged += OnActiveTimeEntryManagerPropertyChanged;
            }

            canRebind = true;
            SyncModel ();
            Rebind ();
        }
Exemplo n.º 5
0
        public WidgetSyncManager ()
        {
            authManager = ServiceContainer.Resolve<AuthManager>();
            authManager.PropertyChanged += OnAuthPropertyChanged;

            activeTimeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            widgetUpdateService = ServiceContainer.Resolve<IWidgetUpdateService> ();

            messageBus = ServiceContainer.Resolve<MessageBus> ();
            subscriptionSyncStarted = messageBus.Subscribe<SyncStartedMessage> (OnSyncWidget);
            subscriptionSyncFinished = messageBus.Subscribe<SyncFinishedMessage> (OnSyncWidget);
            subscriptionStartStopFinished = messageBus.Subscribe<StartStopMessage> (OnSyncWidget);
        }
        public AndroidNotificationManager ()
        {
            ctx = ServiceContainer.Resolve<Context> ();
            notificationManager = (NotificationManager)ctx.GetSystemService (Context.NotificationService);
            runningBuilder = CreateRunningNotificationBuilder (ctx);
            idleBuilder = CreateIdleNotificationBuilder (ctx);
            propertyTracker = new PropertyChangeTracker ();

            TimeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            binding = this.SetBinding (() => TimeEntryManager.ActiveTimeEntry).WhenSourceChanges (OnActiveTimeEntryChanged);

            var bus = ServiceContainer.Resolve<MessageBus> ();
            subscriptionSettingChanged = bus.Subscribe<SettingChangedMessage> (OnSettingChanged);
        }
Exemplo n.º 7
0
        public WidgetSyncManager ()
        {
            authManager = ServiceContainer.Resolve<AuthManager>();
            authManager.PropertyChanged += OnAuthPropertyChanged;

            widgetUpdateService = ServiceContainer.Resolve<IWidgetUpdateService>();
            timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            timeEntryManager.PropertyChanged += OnTimeEntryManagerPropertyChanged;
            ResetModelToRunning ();

            messageBus = ServiceContainer.Resolve<MessageBus> ();
            subscriptionSyncStarted = messageBus.Subscribe<SyncStartedMessage> (OnSync);
            subscriptionSyncFinished = messageBus.Subscribe<SyncFinishedMessage> (OnSync);
        }
        public AndroidNotificationManager ()
        {
            ctx = ServiceContainer.Resolve<Context> ();
            notificationManager = (NotificationManager)ctx.GetSystemService (Context.NotificationService);
            runningBuilder = CreateRunningNotificationBuilder (ctx);
            idleBuilder = CreateIdleNotificationBuilder (ctx);
            propertyTracker = new PropertyChangeTracker ();

            timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            timeEntryManager.PropertyChanged += OnActiveTimeEntryManagerPropertyChanged;

            var bus = ServiceContainer.Resolve<MessageBus> ();
            subscriptionSettingChanged = bus.Subscribe<SettingChangedMessage> (OnSettingChanged);

            SyncRunningModel ();
            SyncNotification ();
        }
 public void Dispose ()
 {
     var bus = ServiceContainer.Resolve<MessageBus> ();
     if (propertyTracker != null) {
         propertyTracker.Dispose ();
         propertyTracker = null;
     }
     if (subscriptionSettingChanged != null) {
         bus.Unsubscribe (subscriptionSettingChanged);
         subscriptionSettingChanged = null;
     }
     if (timeEntryManager != null) {
         timeEntryManager.PropertyChanged -= OnActiveTimeEntryManagerPropertyChanged;
         timeEntryManager = null;
     }
     if (propertyTracker != null) {
         propertyTracker.Dispose ();
         propertyTracker = null;
     }
 }
Exemplo n.º 10
0
        public void Stop ()
        {
            // Stop listening to timer changes
            isStarted = false;

            if (propertyTracker != null) {
                propertyTracker.Dispose ();
                propertyTracker = null;
            }

            if (timeEntryManager != null) {
                timeEntryManager.PropertyChanged -= OnTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }

            if (showRunning) {
                currentTimeEntry = null;
            }
        }
Exemplo n.º 11
0
        public void Start ()
        {
            propertyTracker = new PropertyChangeTracker ();

            // Start listening to timer changes
            if (showRunning) {
                timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
                timeEntryManager.PropertyChanged += OnTimeEntryManagerPropertyChanged;
                ResetModelToRunning ();
            }

            isStarted = true;
            Rebind ();
        }
Exemplo n.º 12
0
        protected override void ResetModel ()
        {
            useDraft = true;

            if (timeEntryManager == null) {
                timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
                timeEntryManager.PropertyChanged += OnTimeEntryManagerPropertyChanged;
            }

            if (timeEntryManager.Draft == null) {
                TimeEntry = null;
            } else {
                TimeEntry = new TimeEntryModel (timeEntryManager.Draft);
            }
        }
Exemplo n.º 13
0
        public void OnStop ()
        {
            canRebind = false;

            if (timeEntryManager != null) {
                timeEntryManager.PropertyChanged -= OnActiveTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }
        }
Exemplo n.º 14
0
        public void OnStart ()
        {
            // Hook up to time entry manager
            if (timeEntryManager == null) {
                timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
                timeEntryManager.PropertyChanged += OnActiveTimeEntryManagerPropertyChanged;
            }

            canRebind = true;
            SyncModel ();
            Rebind ();

            if (ActiveEntryChanged != null) {
                ActiveEntryChanged.Invoke (this, EventArgs.Empty); // Initial rendering
            }
        }
Exemplo n.º 15
0
            protected override void Dispose (bool disposing)
            {
                if (disposing) {
                    var bus = ServiceContainer.Resolve<MessageBus> ();
                    if (subscriptionSettingChanged != null) {
                        bus.Unsubscribe (subscriptionSettingChanged);
                        subscriptionSettingChanged = null;
                    }

                    if (timeEntryManager != null) {
                        timeEntryManager.PropertyChanged -= OnTimeEntryManagerPropertyChanged;
                        timeEntryManager = null;
                    }
                }

                base.Dispose (disposing);
            }
Exemplo n.º 16
0
            public MainPagerAdapter (Context ctx, FragmentManager fm) : base (fm)
            {
                this.ctx = ctx;

                timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
                timeEntryManager.PropertyChanged += OnTimeEntryManagerPropertyChanged;

                var bus = ServiceContainer.Resolve<MessageBus> ();
                subscriptionSettingChanged = bus.Subscribe<SettingChangedMessage> (OnSettingChanged);
            }