예제 #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 ());
            });
        }
예제 #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 ();
        }
예제 #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 ();
        }
예제 #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);
        }
예제 #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;
     }
 }
예제 #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;
            }
        }
예제 #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 ();
        }
예제 #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);
            }
        }
예제 #13
0
        public void OnStop ()
        {
            canRebind = false;

            if (timeEntryManager != null) {
                timeEntryManager.PropertyChanged -= OnActiveTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }
        }
예제 #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
            }
        }
예제 #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);
            }
예제 #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);
            }