Beispiel #1
0
        public override void OnReceive(Context context, Intent intent)
        {
            TimeEntryModel timeEntry = TimeEntryModel.FindRunning();

            if (timeEntry != null)
            {
                timeEntry.Stop();
            }

            // Force commit of data (in case Android kills us right after this function returns)
            var modelStore = ServiceContainer.Resolve <IModelStore> ();

            try {
                modelStore.Commit();
            } catch (Exception ex) {
                var log = ServiceContainer.Resolve <Logger> ();
                log.Warning(LogTag, ex, "Manual commit failed.");
            }

            // Try initialising components
            var app = context.ApplicationContext as AndroidApp;

            if (app != null)
            {
                app.InitializeComponents();
            }
        }
            public MainPagerAdapter(Context ctx, FragmentManager fm) : base(fm)
            {
                this.ctx = ctx;

                currentTimeEntry = TimeEntryModel.FindRunning() ?? TimeEntryModel.GetDraft();

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

                subscriptionModelChanged   = bus.Subscribe <ModelChangedMessage> (OnModelChanged);
                subscriptionSettingChanged = bus.Subscribe <SettingChangedMessage> (OnSettingChanged);
            }
Beispiel #3
0
        public void OnStart()
        {
            currentEntry = TimeEntryModel.FindRunning() ?? TimeEntryModel.GetDraft();

            // Start listening for changes model changes
            var bus = ServiceContainer.Resolve <MessageBus> ();

            subscriptionModelChanged = bus.Subscribe <ModelChangedMessage> (OnModelChanged);

            canRebind = true;
            Rebind();
        }
Beispiel #4
0
        public AndroidNotificationManager()
        {
            ctx = ServiceContainer.Resolve <Context> ();
            notificationManager = (NotificationManager)ctx.GetSystemService(Context.NotificationService);
            runningBuilder      = CreateRunningNotificationBuilder(ctx);
            idleBuilder         = CreateIdleNotificationBuilder(ctx);

            currentTimeEntry = TimeEntryModel.FindRunning();
            SyncNotification();

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

            subscriptionModelChanged   = bus.Subscribe <ModelChangedMessage> (OnModelChanged);
            subscriptionSettingChanged = bus.Subscribe <SettingChangedMessage> (OnSettingChanged);
            subscriptionAuthChanged    = bus.Subscribe <AuthChangedMessage> (OnAuthChanged);
        }
Beispiel #5
0
        public void Start()
        {
            // Start listening to timer changes
            if (showRunning)
            {
                currentTimeEntry = TimeEntryModel.FindRunning();
            }

            if (subscriptionModelChanged == null)
            {
                var bus = ServiceContainer.Resolve <MessageBus> ();
                subscriptionModelChanged = bus.Subscribe <ModelChangedMessage> (OnModelChanged);
            }

            isStarted = true;
            Rebind();
        }
Beispiel #6
0
        public override void OnStart()
        {
            TimeEntry = TimeEntryModel.FindRunning() ?? TimeEntryModel.GetDraft();

            base.OnStart();
        }