Exemple #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();
            }
        }
Exemple #2
0
        private void OnActionButtonTouchUpInside(object sender, EventArgs e)
        {
            if (currentTimeEntry == null)
            {
                currentTimeEntry = TimeEntryModel.GetDraft();
                currentTimeEntry.Start();

                var controllers = new List <UIViewController> (parentController.NavigationController.ViewControllers);
                controllers.Add(new EditTimeEntryViewController(currentTimeEntry));
                if (ServiceContainer.Resolve <SettingsStore> ().ChooseProjectForNew)
                {
                    controllers.Add(new ProjectSelectionViewController(currentTimeEntry));
                }
                parentController.NavigationController.SetViewControllers(controllers.ToArray(), true);
            }
            else
            {
                currentTimeEntry.Stop();
            }
        }