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());
            });
        }
        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;
            }
        }
Ejemplo n.º 3
0
        public LogTimeEntriesViewModel()
        {
            ServiceContainer.Resolve <ITracker> ().CurrentScreen = "TimeEntryList Screen";
            timeEntryManager = ServiceContainer.Resolve <ActiveTimeEntryManager> ();
            timeEntryManager.PropertyChanged += OnActiveTimeEntryManagerPropertyChanged;

            var bus = ServiceContainer.Resolve <MessageBus> ();

            subscriptionSettingChanged = bus.Subscribe <SettingChangedMessage> (OnSettingChanged);
        }
Ejemplo n.º 4
0
        public override void OnDestroy()
        {
            if (timeEntryManager != null)
            {
                timeEntryManager.PropertyChanged -= OnTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }

            base.OnDestroy();
        }
Ejemplo n.º 5
0
        public void OnStop()
        {
            canRebind = false;

            if (timeEntryManager != null)
            {
                timeEntryManager.PropertyChanged -= OnActiveTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }
        }
Ejemplo n.º 6
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);
            }
Ejemplo n.º 7
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

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

            canRebind = true;
            SyncModel();
            Rebind();
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        private void OnPropertyChange(object sender, EventArgs e)
        {
            if (Model.Id == Guid.Empty)
            {
                Dispose();
            }

            if (timeEntryManager != null)
            {
                timeEntryManager.PropertyChanged -= OnTimeEntryManagerPropertyChanged;
                timeEntryManager = null;
            }
        }
Ejemplo n.º 11
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);
        }
        LogTimeEntriesViewModel ()
        {
            // durationTimer will update the Duration value if ActiveTimeEntry is running
            durationTimer = new Timer ();
            durationTimer.Elapsed += DurationTimerCallback;

            ServiceContainer.Resolve<ITracker> ().CurrentScreen = "TimeEntryList Screen";
            timeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            timeEntryManager.PropertyChanged += OnActiveTimeEntryManagerPropertyChanged;

            var bus = ServiceContainer.Resolve<MessageBus> ();
            subscriptionSettingChanged = bus.Subscribe<SettingChangedMessage> (OnSettingChanged);
            subscriptionSyncFinished = bus.Subscribe<SyncFinishedMessage> (OnSyncFinished);
            subscriptionUpdateFinished = bus.Subscribe<UpdateFinishedMessage> (OnUpdateItemsFinished);
        }
        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);
        }
Ejemplo n.º 14
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();
        }
        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();
        }
Ejemplo n.º 16
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
            }
        }
Ejemplo n.º 17
0
        LogTimeEntriesViewModel()
        {
            // durationTimer will update the Duration value if ActiveTimeEntry is running
            durationTimer          = new Timer();
            durationTimer.Elapsed += DurationTimerCallback;

            ServiceContainer.Resolve <ITracker> ().CurrentScreen = "TimeEntryList Screen";
            activeTimeEntryManager = ServiceContainer.Resolve <ActiveTimeEntryManager> ();
            activeTimeEntryManager.PropertyChanged += OnActiveTimeEntryChanged;

            var bus = ServiceContainer.Resolve <MessageBus> ();

            subscriptionSettingChanged = bus.Subscribe <SettingChangedMessage> (OnSettingChanged);
            subscriptionSyncFinished   = bus.Subscribe <SyncFinishedMessage> (OnSyncFinished);
            subscriptionUpdateFinished = bus.Subscribe <UpdateFinishedMessage> (OnUpdateItemsFinished);

            UpdateView(activeTimeEntryManager.ActiveTimeEntry);
            SyncCollectionView();
        }
Ejemplo n.º 18
0
        public void ResetModel()
        {
            isDraft = true;

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

            if (timeEntryManager.Draft == null)
            {
                Model = null;
            }
            else
            {
                Model = new TimeEntryModel(timeEntryManager.Draft);
            }
        }
Ejemplo n.º 19
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);
            }
        }
Ejemplo n.º 20
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);
            }
Ejemplo n.º 21
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;
            }
        }
        public void Dispose ()
        {
            var bus = ServiceContainer.Resolve<MessageBus> ();
            if (subscriptionSettingChanged != null) {
                bus.Unsubscribe (subscriptionSettingChanged);
                subscriptionSettingChanged = null;
            }
            if (subscriptionSyncFinished != null) {
                bus.Unsubscribe (subscriptionSyncFinished);
                subscriptionSyncFinished = null;
            }
            if (subscriptionUpdateFinished != null) {
                bus.Unsubscribe (subscriptionUpdateFinished);
                subscriptionUpdateFinished = null;
            }

            DisposeCollection ();

            timeEntryManager.PropertyChanged -= OnActiveTimeEntryManagerPropertyChanged;
            timeEntryManager = null;
            model = null;
        }
Ejemplo n.º 23
0
        LogTimeEntriesViewModel ()
        {
            // durationTimer will update the Duration value if ActiveTimeEntry is running
            durationTimer = new Timer ();
            durationTimer.Elapsed += DurationTimerCallback;

            ServiceContainer.Resolve<ITracker> ().CurrentScreen = "TimeEntryList Screen";
            activeTimeEntryManager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            activeTimeEntryManager.PropertyChanged += OnActiveTimeEntryChanged;

            var bus = ServiceContainer.Resolve<MessageBus> ();
            subscriptionSettingChanged = bus.Subscribe<SettingChangedMessage> (OnSettingChanged);
            subscriptionSyncFinished = bus.Subscribe<SyncFinishedMessage> (OnSyncFinished);
            subscriptionUpdateFinished = bus.Subscribe<UpdateFinishedMessage> (OnUpdateItemsFinished);

            HasMoreItems = true;
            HasLoadErrors = false;
            HasItems = CollectionState.NotReady;

            UpdateView (activeTimeEntryManager.ActiveTimeEntry);
            SyncCollectionView ();
        }