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
        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);
        }
        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();

                foreach (var file in downloads)
                {
                    var query = new Android.App.DownloadManager.Query();
                    query.SetFilterById(file.Id);

                    try {
                        using (var cursor = _downloadManager.InvokeQuery(query)) {
                            if (cursor != null && cursor.MoveToNext())
                            {
                                UpdateFileProperties(cursor, file);
                            }
                            else
                            {
                                // This file is not listed in the native download manager anymore. Let's mark it as canceled.
                                Abort(file);
                            }
                            cursor?.Close();
                        }
                    } catch (Android.Database.Sqlite.SQLiteException) {
                        // I lately got an exception that the database was unaccessible ...
                    }
                }

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

            // Start this playing handler immediately
            _downloadWatcherHandler.PostDelayed(_downloadWatcherHandlerRunnable, 0);
        }
Example #4
0
        private List <GestureDescription.StrokeDescription> GenerateContinuous(MotionDescription motion)
        {
            Log.Info(TAG, "GenerateContinuous(" + motion.beginX.ToString() + ", " + motion.beginY.ToString() + ")");
            var output = new List <GestureDescription.StrokeDescription>();

            Path swipePath = new Path();

            swipePath.MoveTo(motion.beginX, motion.beginY);
            swipePath.LineTo(motion.endX, motion.endY);

            var stroke = new GestureDescription.StrokeDescription(swipePath, GESTURE_START_DELAY_MS, CONTINUOUS_STROKE_DURATION_MS, false);

            output.Add(stroke);

            // Add a callback to add more strokes for "continuous" behavior
            extendedMotionHandler.PostDelayed(extendedMotionCallback, CONTINUOUS_STROKE_DURATION_MS);
            return(output);
        }