Example #1
0
		internal static void SendMessage (Handler handler, Message msg, long at)
		{
			long now = SystemClock.uptimeMillis ();
			int age = current_age;
			Action dispatch = () => {
				mutex.WaitOne ();
				if (age == current_age)
					handler.dispatchMessage (msg);
				mutex.ReleaseMutex ();
			};
			if (now >= at) {
				ThreadPool.QueueUserWorkItem ((state) => control.Invoke (dispatch));
			} else {
				SWF.Timer timer = new SWF.Timer ();
				timer.Interval = (int)(at - now);
				timer.Tick += (sender, e) => {
					timer.Stop ();
					control.Invoke (dispatch);
				};
				timer.Start ();
			}
		}
Example #2
0
		/// <summary>
		/// Use the provided queue instead of the default one and take a callback
		/// interface in which to handle messages.
		/// </summary>
		/// <remarks>
		/// Use the provided queue instead of the default one and take a callback
		/// interface in which to handle messages.
		/// </remarks>
		public Handler (Looper looper, Handler.Callback callback)
		{
			throw new NotSupportedException ();
		}
        protected override void onCreate(Bundle savedInstanceState)
        {
            // https://forums.oculus.com/viewtopic.php?f=67&t=22766

            var activity = this;
            // http://stackoverflow.com/questions/11425020/actionbar-in-a-dialogfragment
            //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
            //activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_DIM_BEHIND, WindowManager_LayoutParams.FLAG_DIM_BEHIND);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //var @params = activity.getWindow().getAttributes();
            ////@params.height = WindowManager_LayoutParams.FILL_PARENT;
            ////@params.width = 850; //fixed width
            ////@params.height = 450; //fixed width
            //@params.alpha = 1.0f;
            //@params.dimAmount = 0.5f;
            //activity.getWindow().setAttributes(@params);
            //activity.getWindow().setLayout(850, 850);
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


            AtPrepareOptions +=
                value =>
                {
                    value.clear();

                    var item1 = value.add(
                         (java.lang.CharSequence)(object)"http://abstractatech.com"
                    );



                    item1.setIcon(android.R.drawable.ic_menu_view);

                    var item2 = value.add(
                        (java.lang.CharSequence)(object)"http://jsc-solutions.net"
                    );

                    //item2.setIcon(android.R.drawable.ic_menu_edit);
                    item2.setIcon(android.R.drawable.ic_menu_view);

                    var i = new Intent(Intent.ACTION_VIEW,
                        android.net.Uri.parse("http://jsc-solutions.net")
                    );

                    // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                    var ic = Intent.createChooser(i, "http://jsc-solutions.net");


                    item2.setIntent(
                        ic
                    );
                };

            AtOption +=
                item =>
                {

                    //b.WithText("menu was clicked!" + (string)(object)item.getTitle());
                    b.WithText("menu was clicked!" + new { item });
                };

            var b2 = new Button(this);

            var sw = System.Diagnostics.Stopwatch.StartNew();

            // SystemService
            Action update = delegate
            {
                // newer SDKS hide it

                // X:\opensource\ovr_mobile_sdk_0.5.1\VRLib\jni\VrApi\VrApi.cpp
                int cpuCore = 0;


                var online =
                    System.IO.File.ReadAllText("/sys/devices/system/cpu/cpu4/online").Trim();

                if (online == "1")
                    cpuCore = 4;

                var cpuFreq =
                    System.IO.File.ReadAllText("/sys/devices/system/cpu/cpu" + cpuCore + "/cpufreq/scaling_cur_freq").Trim();

                var cpuFrezMhz =
                    long.Parse(cpuFreq) / 1000;

                // 0 if gpu is not used?
                var gpuFreq =
                  System.IO.File.ReadAllText("/sys/devices/14ac0000.mali/clock").Trim();


                // const int64_t cpuFreq = ReadFreq( "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_cur_freq", cpuCore );

                b2.setText(
                    new { cpuCore, online, cpuFrezMhz, gpuFreq }.ToString()
                    + "\n " + sw.ElapsedMilliseconds
                    );
            };

            var h = new Handler();

            var next = default(Action);

            next = delegate
            {
                // await 1?

                update();

                h.postDelayed(
                    new xRunnable
                    {
                        yield = delegate
                        {
                            next();
                        }
                    },
                1);
            };

            next();


            ll.addView(b2);

            this.setContentView(sv);



            vConfigurationChanged = e =>
            {
                var orientation = getScreenOrientation();

                var SystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();

                //b2.setText(
                //    new
                //    {
                //        orientation,
                //        SystemUiVisibility
                //    }.ToString()
                //);


                if (orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    hideSystemUI();
                }
                else
                {
                    showSystemUI();
                }
            };

            vConfigurationChanged(null);
        }
Example #4
0
		/// <summary>
		/// Constructor associates this handler with the queue for the
		/// current thread and takes a callback interface in which you can handle
		/// messages.
		/// </summary>
		/// <remarks>
		/// Constructor associates this handler with the queue for the
		/// current thread and takes a callback interface in which you can handle
		/// messages.
		/// </remarks>
		public Handler (Handler.Callback callback)
		{
			mCallback = callback;
		}