Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Console.WriteLine("XamFace: OnCreate Called");

            displayManager = (DisplayManager)GetSystemService(Context.DisplayService);
            displayManager.RegisterDisplayListener(this, null);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);


            time         = FindViewById <TextView> (Resource.Id.textTime);
            date         = FindViewById <TextView> (Resource.Id.textDate);
            day          = FindViewById <TextView> (Resource.Id.textDay);
            xamarinLogo  = FindViewById <ImageView> (Resource.Id.xamarinLogo);
            wheelSeconds = FindViewById <ProgressWheel> (Resource.Id.wheelSeconds);
            wheelMinutes = FindViewById <ProgressWheel> (Resource.Id.wheelMinutes);
            wheelHours   = FindViewById <ProgressWheel> (Resource.Id.wheelHours);

            wheelMinutes.Alpha     = 0.6f;
            wheelHours.Alpha       = 0.3f;
            wheelHours.ProgressMax = 24;

            wheelSeconds.RimColor = Android.Graphics.Color.Transparent;
            wheelHours.RimColor   = Android.Graphics.Color.Transparent;
            wheelMinutes.RimColor = Android.Graphics.Color.Transparent;

            RunOnUiThread(UpdateUI);

            var filter = new IntentFilter();

            filter.AddAction(Intent.ActionTimeTick);
            filter.AddAction(Intent.ActionTimeChanged);
            filter.AddAction(Intent.ActionTimezoneChanged);

            timeBroadcastReceiver         = new SimpleBroadcastReceiver();
            timeBroadcastReceiver.Receive = () => {
                Console.WriteLine("Time Changed");
                RunOnUiThread(UpdateUI);
            };

            RegisterReceiver(timeBroadcastReceiver, filter);

            batteryBroadcastReceiver         = new SimpleBroadcastReceiver();
            batteryBroadcastReceiver.Receive = () => {
                Console.WriteLine("Battery Changed");
                RunOnUiThread(UpdateUI);
            };

            RegisterReceiver(batteryBroadcastReceiver, new IntentFilter(Intent.ActionBatteryChanged));

            timerSeconds = new Timer(new TimerCallback(state => {
                RunOnUiThread(() => UpdateUITime(null));
            }), null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
        }
Пример #2
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			Console.WriteLine ("XamFace: OnCreate Called");

			displayManager = (DisplayManager)GetSystemService (Context.DisplayService);
			displayManager.RegisterDisplayListener (this, null);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);


			time = FindViewById<TextView> (Resource.Id.textTime);
			date = FindViewById<TextView> (Resource.Id.textDate);
			day = FindViewById<TextView> (Resource.Id.textDay);
			xamarinLogo = FindViewById<ImageView> (Resource.Id.xamarinLogo);
			wheelSeconds = FindViewById<ProgressWheel> (Resource.Id.wheelSeconds);
			wheelMinutes = FindViewById<ProgressWheel> (Resource.Id.wheelMinutes);
			wheelHours = FindViewById<ProgressWheel> (Resource.Id.wheelHours);

			wheelMinutes.Alpha = 0.6f;
			wheelHours.Alpha = 0.3f;
			wheelHours.ProgressMax = 24;

			wheelSeconds.RimColor = Android.Graphics.Color.Transparent;
			wheelHours.RimColor = Android.Graphics.Color.Transparent;
			wheelMinutes.RimColor = Android.Graphics.Color.Transparent;

			RunOnUiThread (UpdateUI);

			var filter = new IntentFilter ();
			filter.AddAction (Intent.ActionTimeTick);
			filter.AddAction (Intent.ActionTimeChanged);
			filter.AddAction (Intent.ActionTimezoneChanged);

			timeBroadcastReceiver = new SimpleBroadcastReceiver ();
			timeBroadcastReceiver.Receive = () => {
				Console.WriteLine ("Time Changed");
				RunOnUiThread (UpdateUI);
			};

			RegisterReceiver (timeBroadcastReceiver, filter);

			batteryBroadcastReceiver = new SimpleBroadcastReceiver ();
			batteryBroadcastReceiver.Receive = () => {
				Console.WriteLine ("Battery Changed");
				RunOnUiThread (UpdateUI);
			};

			RegisterReceiver (batteryBroadcastReceiver, new IntentFilter (Intent.ActionBatteryChanged));

			timerSeconds = new Timer (new TimerCallback (state => {
				RunOnUiThread (() => UpdateUITime (null));
			}), null, TimeSpan.FromSeconds (1), TimeSpan.FromSeconds (1));
		}