Beispiel #1
0
        private void Rebind()
        {
            if (!isStarted)
            {
                return;
            }

            ResetTrackedObservables();

            rebindCounter++;

            if (currentTimeEntry == null)
            {
                durationButton.SetTitle(DefaultDurationText, UIControlState.Normal);
                actionButton.Apply(Style.NavTimer.StartButton);
                actionButton.Hidden = false;
            }
            else
            {
                var duration = new TimeEntryModel(currentTimeEntry).GetDuration();

                durationButton.SetTitle(duration.ToString(@"hh\:mm\:ss"), UIControlState.Normal);
                actionButton.Apply(Style.NavTimer.StopButton);
                actionButton.Hidden = currentTimeEntry.State != TimeEntryState.Running;

                var counter = rebindCounter;
                DispatchQueue.MainQueue.DispatchAfter(
                    TimeSpan.FromMilliseconds(1000 - duration.Milliseconds),
                    delegate {
                    if (counter == rebindCounter)
                    {
                        Rebind();
                    }
                });
            }
        }
        private void Rebind ()
        {
            if (!isStarted) {
                return;
            }

            ResetTrackedObservables ();

            rebindCounter++;

            if (currentTimeEntry == null) {
                durationButton.SetTitle (DefaultDurationText, UIControlState.Normal);
                actionButton.Apply (Style.NavTimer.StartButton);
                actionButton.Hidden = false;
            } else {
                var duration = new TimeEntryModel (currentTimeEntry).GetDuration ();

                durationButton.SetTitle (duration.ToString (@"hh\:mm\:ss"), UIControlState.Normal);
                actionButton.Apply (Style.NavTimer.StopButton);
                actionButton.Hidden = currentTimeEntry.State != TimeEntryState.Running;

                var counter = rebindCounter;
                DispatchQueue.MainQueue.DispatchAfter (
                    TimeSpan.FromMilliseconds (1000 - duration.Milliseconds),
                delegate {
                    if (counter == rebindCounter) {
                        Rebind ();
                    }
                });
            }
        }