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); }
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(); }
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); }
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(); }
public override void OnStart() { TimeEntry = TimeEntryModel.FindRunning() ?? TimeEntryModel.GetDraft(); base.OnStart(); }