Example #1
0
        void StartDownloadWatcher()
        {
            // Create an instance for a runnable-handler
            _downloadWatcherHandler = new Android.OS.Handler();

            // Create a runnable, restarting itself to update every file in the queue
            _downloadWatcherHandlerRunnable = new Java.Lang.Runnable(() => {
                var downloads = Queue.Cast <DownloadFileImplementation>().ToList();
                LoopOnDownloads(cursor => {
                    int id           = cursor.GetInt(cursor.GetColumnIndex(Android.App.DownloadManager.ColumnId));
                    var downloadFile = downloads.FirstOrDefault(f => f.Id == id);

                    if (downloadFile != null)
                    {
                        downloads.Remove(downloadFile);
                        UpdateFileProperties(cursor, downloadFile);
                    }
                });

                // All downloads still in this list are not listed in the native donload-manager of Android. Mark them as canceled.
                foreach (var file in downloads)
                {
                    Abort(file);
                }

                _downloadWatcherHandler.PostDelayed(_downloadWatcherHandlerRunnable, 1000);
            });

            // Start this playing handler immediately
            _downloadWatcherHandler.PostDelayed(_downloadWatcherHandlerRunnable, 0);
        }
Example #2
0
        public MediaPlayerService()
        {
            // Create an instance for a runnable-handler
            PlayingHandler = new Handler();

            // Create a runnable, restarting itself if the status still is "playing"
            PlayingHandlerRunnable = new Java.Lang.Runnable(() =>
            {
                this.OnPlaying(EventArgs.Empty);

                if (this.MediaPlayerState == PlaybackStateCompat.StatePlaying)
                {
                    PlayingHandler.PostDelayed(PlayingHandlerRunnable, 250);
                }
            });

            // On Status changed to PLAYING, start raising the Playing event
            StatusChanged += (object sender, EventArgs e) =>
            {
                if (this.MediaPlayerState == PlaybackStateCompat.StatePlaying)
                {
                    PlayingHandler.PostDelayed(PlayingHandlerRunnable, 0);
                }
            };
        }
Example #3
0
        public void OnActivityPaused(Activity activity)
        {
            paused = true;

            if (check != null)
            {
                handler.RemoveCallbacks(check);
            }

            check = new Java.Lang.Runnable(() =>
            {
                if (foreground && paused)
                {
                    foreground = false;
                    Log.Info(Tag, "went background");
                    foreach (var l in listeners)
                    {
                        try
                        {
                            l.OnBecameBackground();
                        }
                        catch (Exception ex)
                        {
                            Log.Error(Tag, "Listener threw exception!", ex);
                        }
                    }
                }
                else
                {
                    Log.Info(Tag, "still foreground");
                }
            });

            handler.PostDelayed(check, CheckDelay);
        }
Example #4
0
        void LoadMoreItems(uint count, int baseIndex)
        {
            BackgroundWorker worker = new BackgroundWorker();

            //worker.RunWorkerAsync ();
            worker.DoWork += (o, ae) =>
            {
                DataServiceQuery <Order> query = northwindEntity.Orders.Expand("Customer");
                query = query.Skip <Order>(baseIndex).Take <Order>(50) as DataServiceQuery <Order>;
                IAsyncResult ar    = query.BeginExecute(null, null);
                var          items = query.EndExecute(ar);
                var          list  = items.ToList();

                Android.OS.Handler mainHandler = new Android.OS.Handler(Android.OS.Looper.MainLooper);
                Java.Lang.Runnable myRunnable  = new Java.Lang.Runnable(() =>
                {
                    GridSource.LoadItems(list);
                });
                mainHandler.Post(myRunnable);
            };

            worker.RunWorkerCompleted += (o, ae) =>
            {
                IsBusy = false;
            };

            IsBusy = true;
            worker.RunWorkerAsync();
        }
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            context = this;

            var prefs = context.GetSharedPreferences("Wifiautoconnect", FileCreationMode.Private);

            if (!prefs.GetBoolean("hideToasts", false))
            {
                Toast.MakeText(this, "Service created!", ToastLength.Long).Show();
            }

            runnable = new Java.Lang.Runnable(() =>
            {
                running = true;

                prefs = context.GetSharedPreferences("Wifiautoconnect", FileCreationMode.Private);
                if (!prefs.GetBoolean("hideToasts", false))
                {
                    Toast.MakeText(context, "Service is still running", ToastLength.Long).Show();
                }

                MainActivity.SetAlarm(context);

                running = false;
                handler.PostDelayed(runnable, 10000);
            });

            handler.PostDelayed(runnable, 1000);

            return(StartCommandResult.Sticky);
        }
Example #6
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();
            LinearLayout layout   = new LinearLayout(context);
            TextView     textView = new TextView(context);

            textView.TextSize = 16;
            textView.SetPadding(10, 20, 0, 0);
            textView.SetHeight(90);

            textView.Text = "Primary Agricultural Activity of USA";
            layout.AddView(textView);
            textView.Gravity = Android.Views.GravityFlags.Top;

            layout.Orientation = Orientation.Vertical;
            maps = new SfMaps(context);

            ShapeFileLayer layer = new ShapeFileLayer();

            layer.Uri = "usa_state.shp";

            layer.ShapeIdTableField = "STATE_NAME";
            layer.ShapeIdPath       = "Name";
            layer.DataSource        = GetDataSource();
            layer.ShapeSettings.ShapeColorValuePath = "Type";
            layer.ShapeSettings.ShapeFill           = Color.ParseColor("#A9D9F7");
            SetColorMapping(layer.ShapeSettings);

            LayerCustomTooltipSetting layerCustomTooltip = new LayerCustomTooltipSetting(context);

            layerCustomTooltip.ShowTooltip = true;
            layer.TooltipSettings          = layerCustomTooltip;

            layer.LegendSetting = new LegendSetting()
            {
                ShowLegend = true, ItemMargin = 0
            };

            maps.Layers.Add(layer);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");

            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });
            handler.PostDelayed(run, 100);

            return(layout);
        }
Example #7
0
 public void ManagedJavaManaged_JavaCatches()
 {
     using (var t = new Bxc7634()) {
         using (var r = new Java.Lang.Runnable(() => { throw new InvalidOperationException(); })) {
             t.RunCatchBlock(r);
         }
         Assert.IsNotNull(t.ThrowableCaught);
         Assert.AreEqual("Android.Runtime.JavaProxyThrowable", t.ThrowableCaught.GetType().FullName);
     }
 }
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();
            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            maps         = new SfMaps(context);
            currentToast = new Toast(context);
            ShapeFileLayer layer = new ShapeFileLayer();

            layer.Uri            = "usa_state.shp";
            layer.ShapeSelected += (object sender, ShapeFileLayer.ShapeSelectedEventArgs e) => {
                JSONObject data = (JSONObject)e.P0;
                if (data != null)
                {
                    if (currentToast != null)
                    {
                        currentToast.Cancel();
                    }
                    currentToast = Toast.MakeText(context, data.Get("Name") + "\n" + data.Get("Type"), ToastLength.Short);
                    currentToast.Show();
                }
            };
            layer.EnableSelection   = true;
            layer.ShapeIdTableField = "STATE_NAME";
            layer.ShapeIdPath       = "Name";
            layer.DataSource        = GetDataSource();
            layer.LegendSetting     = new LegendSetting()
            {
                ShowLegend = true
            };
            layer.ShapeSettings.ShapeStrokeThickess = 2;
            SetColorMapping(layer.ShapeSettings);
            layer.ShapeSettings.ShapeColorValuePath = "Type";
            maps.Layers.Add(layer);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");
            //sfBusyIndicator.SetBackgroundColor(Color.ParseColor("#779772"));

            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });
            handler.PostDelayed(run, 100);

            return(layout);
        }
Example #9
0
        public static void ToastItFromBack(Context ctx, string message, bool isLong = true)
        {
            Handler mainHandler = new Handler(Looper.MainLooper);

            Java.Lang.Runnable runnableToast = new Java.Lang.Runnable(() =>
            {
                Toast.MakeText(ctx, message, isLong ? ToastLength.Long : ToastLength.Short).Show();
            });

            mainHandler.Post(runnableToast);
        }
        public static void ShowToast(this Context context, string text, ToastLength length = ToastLength.Long)
        {
            Handler mainHandler = new Handler(Looper.MainLooper);

            Java.Lang.Runnable runnableToast = new Java.Lang.Runnable(() =>
            {
                Toast.MakeText(context, text, length).Show();
            });

            mainHandler.Post(runnableToast);
        }
Example #11
0
 public void ShowProcessing()
 {
     action = new Java.Lang.Runnable(() => RepeatAnimation());
     //if (avdProgress == null)
     //{
     avdProgress           = Android.Support.Graphics.Drawable.AnimatedVectorDrawableCompat.Create(this, Resource.Drawable.avd_line);
     loadingBar.Background = avdProgress;
     //}
     loadingBar.Visibility = ViewStates.Visible;
     RepeatAnimation();
 }
        public static Thread performOnBackgroundThread(Java.Lang.Runnable runnable)
        {
            Thread t = new Thread(new ThreadStart(delegate
            {
                runnable.Run();
            }));

            t.Start();

            return(t);
        }
 public static void AnimateViewIn(View view, Java.Lang.Runnable continueAction)
 {
     view.Animate()
     .Alpha(255)
     .SetDuration(300)
     .WithStartAction(new Java.Lang.Runnable(() => {
         view.Visibility = ViewStates.Visible;
     }))
     .WithEndAction(continueAction)
     .Start();
 }
Example #14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.splashscreen);
            Java.Lang.Runnable runnable = new Java.Lang.Runnable(() =>
            {
                Intent i = new Intent(this, typeof(MainActivity));
                StartActivity(i);
            });

            new Handler().PostDelayed(runnable, 1500);
        }
Example #15
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_main);
     elapsedTime = 60;            // default value
     myHandler   = new Handler(); //initializing handler
     r           = new Java.Lang.Runnable(Run);
     timer       = FindViewById <EditText>(Resource.Id.timertxt);
     btn         = FindViewById <Button>(Resource.Id.btn1);
     btn.Click  += Btn_Click;
     Counter();
 }
Example #16
0
        public void ShowToast(string text, bool IsLengthShort = false)
        {
            Handler mainHandler = new Handler(Looper.MainLooper);

            Java.Lang.Runnable runnableToast = new Java.Lang.Runnable(() =>
            {
                var duration = IsLengthShort ? ToastLength.Short : ToastLength.Long;
                Toast.MakeText(this, text, duration).Show();
            });

            mainHandler.Post(runnableToast);
        }
Example #17
0
        public void ShowNotification(string text = "", int durationInMilliSeconds = 2000)
        {
            var mainHandler   = new Handler(Looper.MainLooper);
            var runnableToast = new Java.Lang.Runnable(() =>
            {
                var toast = Toast.MakeText(this, text, ToastLength.Long);
                toast.Show();
                var handler = new Handler();
                handler.PostDelayed(() => toast.Cancel(), durationInMilliSeconds);
            });

            mainHandler.Post(runnableToast);
        }
Example #18
0
        private async Task <int> Procesar()
        {
            int ret = 0;
            await Task.Run(async() =>
            {
                string titulo = string.Empty, cuerpo = string.Empty;
                try
                {
                    foreach (Entities.NamedAction accionConNombre in _actions)
                    {
                        Handler mainHandler         = new Handler(Looper.MainLooper);
                        Java.Lang.Runnable runnable = new Java.Lang.Runnable(() =>
                        {
                            bannerTxv.Text = accionConNombre.ProcessName;
                        });
                        mainHandler.Post(runnable);
                        accionConNombre.Action.Invoke();
                        mainHandler = new Handler(Looper.MainLooper);
                        runnable    = new Java.Lang.Runnable(() =>
                        {
                            progressBar.IncrementProgressBy(1 / _actions.Count);
                        });
                        mainHandler.Post(runnable);
                    }
                    titulo = string.Format("{0} - Proceso Finalizado", _nombreProceso);
                    cuerpo = "El proceso ha finalizado éxitosamente";
                    ret    = 1;
                }
                catch (System.OperationCanceledException)
                {
                    titulo = "Descarga cancelada";
                    cuerpo = "La descarga de datos fue cancelada.";
                }
                catch (Exception)
                {
                    titulo = "Descarga interrumpida";
                    cuerpo = "La descarga de datos ha fallado. Reintente la operación. En caso de persistir el error comuniquese con el administrador del sistema.";
                }
                finally
                {
                    Handler mainHandler         = new Handler(Looper.MainLooper);
                    Java.Lang.Runnable runnable = new Java.Lang.Runnable(() =>
                    {
                        Utiles.MostrarMensaje(Application.Context, titulo, cuerpo);
                    });
                    mainHandler.Post(runnable);
                }
            });

            return(ret);
        }
Example #19
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();
            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            TextView textView = new TextView(context);

            textView.TextSize = 16;
            textView.SetPadding(10, 20, 0, 0);
            textView.SetHeight(90);

            textView.Text = "Top Population Countries With Bubbles";
            layout.AddView(textView);
            textView.Gravity = Android.Views.GravityFlags.Top;
            maps             = new SfMaps(context);
            ShapeFileLayer layer = new ShapeFileLayer();

            layer.ShowItems                    = true;
            layer.Uri                          = "world1.shp";
            layer.DataSource                   = GetDataSource();
            layer.ShapeIdPath                  = "Country";
            layer.ShapeIdTableField            = "NAME";
            layer.ShapeSettings                = new ShapeSetting();
            layer.ShapeSettings.ShapeValuePath = "ShortName";
            layer.ShapeSettings.ShapeFill      = Color.ParseColor("#A9D9F7");
            BubbleMarkerSetting marker = new BubbleMarkerSetting()
            {
                FillColor = Color.ParseColor("#ffa500"), MinSize = 15, MaxSize = 25, ValuePath = "Population"
            };

            layer.BubbleMarkerSetting = marker;
            maps.Layers.Add(layer);
            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");
            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });
            handler.PostDelayed(run, 100);

            return(layout);
        }
Example #20
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            LinearLayout layout = new LinearLayout(context);

            density                 = context.Resources.DisplayMetrics.Density;
            sampleContext           = context;
            layout.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent);
            layout.Orientation      = Orientation.Vertical;
            layout.LayoutChange    += Layout_LayoutChange1;
            handler                 = new Handler();
            AddGridView();
            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = Com.Syncfusion.Sfbusyindicator.Enums.AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");
            layout.AddView(sfBusyIndicator);
            TextView textView = new TextView(context);

            textView.TextSize = 16;
            textView.SetPadding(10, 20, 10, 0);

            handler                   = new Handler();
            textView.Text             = "Since this application requires network connection, Please check your network connection.";
            textView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent);

            if (IsOnline())
            {
                Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
                {
                    layout.RemoveView(sfBusyIndicator);
                    layout.AddView(mainGrid);
                });
                handler.PostDelayed(run, 100);
            }
            else
            {
                Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
                {
                    layout.RemoveView(sfBusyIndicator);
                    layout.AddView(textView);
                });
                handler.PostDelayed(run, 100);
            }


            return(layout);
        }
Example #21
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();
            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            TextView textView = new TextView(context);

            textView.TextSize = 16;
            textView.SetPadding(10, 20, 0, 0);
            textView.SetHeight(90);

            textView.Text = "Rivers in Australia";
            layout.AddView(textView);
            textView.Gravity = Android.Views.GravityFlags.Top;
            maps             = new SfMaps(context);

            ShapeFileLayer layer = new ShapeFileLayer();

            layer.Uri = "australia.shp";
            layer.ShapeSettings.ShapeFill           = Color.ParseColor("#ACF9F7");
            layer.ShapeSettings.ShapeStrokeThickess = 1;
            maps.Layers.Add(layer);

            SubShapeFileLayer subLayer = new SubShapeFileLayer();

            subLayer.Uri = "river.shp";
            subLayer.ShapeSettings.ShapeFill           = Color.ParseColor("#00A8CC");
            subLayer.ShapeSettings.ShapeStrokeThickess = 2;
            layer.SubShapeFileLayers.Add(subLayer);
            maps.Layers.Add(layer);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");
            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });

            handler.PostDelayed(run, 100);

            return(layout);
        }
Example #22
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();
            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;

            maps                                    = new SfMaps(context);
            layer                                   = new ShapeFileLayer();
            layer.Uri                               = "usa_state.shp";
            layer.ShowItems                         = true;
            layer.EnableSelection                   = false;
            layer.ShapeIdTableField                 = "STATE_NAME";
            layer.ShapeIdPath                       = "Name";
            layer.ShapeSettings.ShapeFill           = Color.ParseColor("#A9D9F7");
            layer.ShapeSettings.ShapeValuePath      = "Name";
            layer.ShapeSettings.ShapeColorValuePath = "Type";

            layer.DataSource = GetDataSource();

            SetColorMapping(layer.ShapeSettings);

            layer.DataLabelSettings.IntersectionAction = IntersectAction.None;
            layer.DataLabelSettings.SmartLabelMode     = IntersectAction.Trim;

            layer.TooltipSettings.ShowTooltip = true;
            layer.TooltipSettings.ValuePath   = "Name";

            maps.Layers.Add(layer);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");

            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });

            handler.PostDelayed(run, 100);

            return(layout);
        }
 public Camera2BasicFragment()
 {
     periodicClassify =
         new Java.Lang.Runnable(() =>
     {
         lock (@lock)
         {
             //if (runClassifier)
             //{
             //    classifyFrame();
             //}
         }
         backgroundHandler.Post(periodicClassify);
     });
 }
        public override void OnCreate()
        {
            base.OnCreate();
            LoadServices();
            var settingsTask = LoadSettingsAsync();

            _broadcasterService.Subscribe(nameof(AccessibilityService), (message) =>
            {
                if (message.Command == "OnAutofillTileClick")
                {
                    var runnable = new Java.Lang.Runnable(OnAutofillTileClick);
                    _handler.PostDelayed(runnable, 250);
                }
            });
            AccessibilityHelpers.IsAccessibilityBroadcastReady = true;
        }
Example #25
0
        public override bool OnStopJob(JobParameters jobParameters)
        {
            Log.Info(TAG, "Stopping job");
            Intent broadcastIntent = new Intent(Globals.RESTART_INTENT);

            SendBroadcast(broadcastIntent);

            Java.Lang.Runnable r = new Java.Lang.Runnable(() =>
            {
                UnregisterReceiver(restartSensorServiceReceiver);
            });

            new Handler().PostDelayed(r, 1000);

            return(false);
        }
 public void ManagedJavaManaged_FinallyExecuted()
 {
     using (var t = new Bxc7634()) {
         using (var r = new Java.Lang.Runnable(() => { throw new InvalidOperationException(); })) {
             Assert.IsFalse(t.FinallyBlockRun);
             bool ioeThrown = false;
             try {
                 t.RunFinallyBlock(r);
             } catch (InvalidOperationException) {
                 ioeThrown = true;
             }
             Assert.IsTrue(ioeThrown);
         }
         Assert.IsTrue(t.FinallyBlockRun);
     }
 }
Example #27
0
        void StartDownloadWatcher()
        {
            // Create an instance for a runnable-handler
            _downloadWatcherHandler = new Android.OS.Handler();

            // Create a runnable, restarting itself to update every file in the queue
            _downloadWatcherHandlerRunnable = new Java.Lang.Runnable(() => {
                // Loop throught all files in the system-queue and update the data in the local queue
                LoopOnDownloads(cursor => UpdateFileProperties(cursor));

                _downloadWatcherHandler.PostDelayed(_downloadWatcherHandlerRunnable, 1000);
            });

            // Start this playing handler immediately
            _downloadWatcherHandler.PostDelayed(_downloadWatcherHandlerRunnable, 0);
        }
Example #28
0
        private Java.Lang.IRunnable CreateSettleRunnable(View view, int targetState)
        {
            Java.Lang.IRunnable settleRunnable = null;
            settleRunnable = new Java.Lang.Runnable(() =>
            {
                if (mViewDragHelper != null && mViewDragHelper.ContinueSettling(true))
                {
                    ViewCompat.PostOnAnimation(view, settleRunnable);
                }
                else
                {
                    setStateInternal(targetState);
                }
            });

            return(settleRunnable);
        }
Example #29
0
        /// <summary>
        /// 视频播放进度跟踪
        /// </summary>
        public void PlayVdieo()
        {
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                while (continuePlay)
                {
                    Java.Lang.Thread.Sleep(1000);

                    Message message = new Message();
                    message.What    = 1;

                    //发送信息给handler
                    handler.SendMessage(message);
                }
            });
            new Java.Lang.Thread(run).Start();
        }
Example #30
0
        private void registerRestarterReceiver()
        {
            // the context can be null if app just installed and this is called from restartsensorservice
            // https://stackoverflow.com/questions/24934260/intentreceiver-components-are-not-allowed-to-register-to-receive-intents-when
            // Final decision: in case it is called from installation of new version (i.e. from manifest, the application is
            // null. So we must use context.registerReceiver. Otherwise this will crash and we try with context.getApplicationContext
            if (restartSensorServiceReceiver == null)
            {
                restartSensorServiceReceiver = new RestartServiceBroadcastReceiver();
            }
            else
            {
                try
                {
                    UnregisterReceiver(restartSensorServiceReceiver);
                }
                catch (Exception e)
                {
                    // not registered
                }
            }

            Java.Lang.Runnable r = new Java.Lang.Runnable(() =>
            {
                // we register the  receiver that will restart the background service if it is killed
                // see onDestroy of Service
                IntentFilter filter = new IntentFilter();
                filter.AddAction(Globals.RESTART_INTENT);
                try
                {
                    RegisterReceiver(restartSensorServiceReceiver, filter);
                }
                catch (Exception e)
                {
                    try
                    {
                        Android.App.Application.Context.RegisterReceiver(restartSensorServiceReceiver, filter);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            });

            new Handler().PostDelayed(r, 1000);
        }
        public MediaPlayerService ()
        {
            // Create an instance for a runnable-handler
            PlayingHandler = new Handler ();

            // Create a runnable, restarting itself if the status still is "playing"
            PlayingHandlerRunnable = new Java.Lang.Runnable (() => {
                OnPlaying (EventArgs.Empty);

                if (MediaPlayerState == PlaybackStateCompat.StatePlaying) {
                    PlayingHandler.PostDelayed (PlayingHandlerRunnable, 250);
                }
            });

            // On Status changed to PLAYING, start raising the Playing event
            StatusChanged += (object sender, EventArgs e) => {
                if(MediaPlayerState == PlaybackStateCompat.StatePlaying){
                    PlayingHandler.PostDelayed (PlayingHandlerRunnable, 0);
                }
            };
        }
		void LoadMoreItems (uint count, int baseIndex)
		{
			BackgroundWorker worker = new BackgroundWorker ();
			//worker.RunWorkerAsync ();
			worker.DoWork += (o, ae) => {
				DataServiceQuery<Order> query = northwindEntity.Orders.Expand ("Customer");
				query = query.Skip<Order> (baseIndex).Take<Order> (50) as DataServiceQuery<Order>;
				IAsyncResult ar = query.BeginExecute (null, null);
				var items = query.EndExecute (ar);
				var list = items.ToList ();

				Android.OS.Handler mainHandler = new Android.OS.Handler (Android.OS.Looper.MainLooper);
				Java.Lang.Runnable myRunnable = new Java.Lang.Runnable (() => {
					GridSource.LoadItems (list);
				});
				mainHandler.Post (myRunnable);
			};

			worker.RunWorkerCompleted += (o, ae) => {
				IsBusy = false;
			};

			IsBusy = true;
			worker.RunWorkerAsync ();
		}