Exemplo n.º 1
0
            // Registers the time zone broadcast receiver (defined at the end of
            // this file) to handle time zone change events:

            private void RegisterTimezoneReceiver()
            {
                if (registeredTimezoneReceiver)
                {
                }
                else
                {
                    if (timeZoneReceiver == null)
                    {
                        timeZoneReceiver = new TimeZoneReceiver
                        {
                            Receive = intent =>
                            {
                                _calendar.Clear(CalendarField.ZoneOffset);
                                _calendar.TimeZone = TimeZone.Default;
                                _calendar          = Calendar.GetInstance(Locale.Default);
                            }
                        }
                    }
                    ;
                    registeredTimezoneReceiver = true;
                    var filter = new IntentFilter(Intent.ActionTimezoneChanged);
                    Application.Context.RegisterReceiver(timeZoneReceiver, filter);
                }
            }
Exemplo n.º 2
0
            /// <summary>
            ///   Use this to instantiate the Handler for _mUpdateTimeHandler and
            ///   use this to instantiate the _timeZoneReciever
            /// </summary>
            /// <param name="self"></param>
            private static void Init(AnalogEngine self)
            {
                _dateTimeAdapter    = new DateTimeAdapter();
                _mUpdateTimeHandler = new Handler(message =>
                {
                    switch (message.What)
                    {
                    case MSG_UPDATE_TIME:
                        self.Invalidate();
                        if (self.ShouldTimerBeRunning())
                        {
                            var timeMs  = _dateTimeAdapter.UnixNow;
                            var delayMs = INTERACTIVE_UPDATE_RATE_MS - timeMs % INTERACTIVE_UPDATE_RATE_MS;
                            _mUpdateTimeHandler.SendEmptyMessageDelayed(MSG_UPDATE_TIME, delayMs);
                        }

                        break;
                    }
                });

                if (_registeredTimezoneReceiver)
                {
                }
                else
                {
                    if (_timeZoneReceiver == null)
                    {
                        _timeZoneReceiver = new TimeZoneReceiver
                        {
                            Receive = intent =>
                            {
                                self._calendar.TimeZone = TimeZone.Default;
                                self.Invalidate();
                            }
                        }
                    }
                    ;
                    _registeredTimezoneReceiver = true;
                    var filter = new IntentFilter(Intent.ActionTimezoneChanged);
                    Application.Context.RegisterReceiver(_timeZoneReceiver, filter);
                }
            }
Exemplo n.º 3
0
            // Registers the time zone broadcast receiver (defined at the end of
            // this file) to handle time zone change events:

            void RegisterTimezoneReceiver()
            {
                if (registeredTimezoneReceiver)
                {
                    return;
                }
                else
                {
                    if (timeZoneReceiver == null)
                    {
                        timeZoneReceiver         = new TimeZoneReceiver();
                        timeZoneReceiver.Receive = (intent) => {
                            time.Clear(intent.GetStringExtra("time-zone"));
                            time.SetToNow();
                        };
                    }
                    registeredTimezoneReceiver = true;
                    IntentFilter filter = new IntentFilter(Intent.ActionTimezoneChanged);
                    Application.Context.RegisterReceiver(timeZoneReceiver, filter);
                }
            }