public HomePage()
        {
            BLEProfileManager = App.BLEProfileManager;
            InitializeComponent();

            longRunningTask.Clicked += (s, e) => {
                if (BLEProfileManager.bleprofile.Devices.Count != 0)
                {
                    string status = BLEProfileManager.bleprofile.Devices.FirstOrDefault().Device.State.ToString();
                    if (status.Equals("Disconnected"))
                    {
                        DisplayAlert("No BlueTooth ", "You need to connect to SmartBand Alert first", "Ok");
                    }
                    else
                    {
                        var message = new StartLongRunningTaskMessage();
                        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
                    }
                }
                else
                {
                    DisplayAlert("No BlueTooth ", "You need to connect to SmartBand Alert first", "Ok");
                }
            };

            stopLongRunningTask.Clicked += (s, e) => {
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, "StopLongRunningTaskMessage");
            };

            BindingContext = this;
        }
 void HandleSendedMessages()
 {
     Device.BeginInvokeOnMainThread(() => {
         var message = new StartLongRunningTaskMessage();
         MessagingCenter.Send(message, "StartLongRunningTaskMessage");
     });
 }
Example #3
0
        void ButtonStart_Clicked(object sender, EventArgs e)
        {
            var player = ((MainPageViewModel)BindingContext).MediaPlayer;

            player.TimeChanged -= TimeChanged;
            player.TimeChanged += TimeChanged;

            var playerData = new MediaPlayerData
            {
                //VideoTrackDescription = player.VideoTrackDescription,
                //VideoTrackCount = player.VideoTrackCount,
                //VideoTrack = player.VideoTrack,
                State = player.State,
                //Spu = player.Spu,
                //Position = player.Position,
                //AudioTrack = player.AudioTrack,
                //AudioTrackCount = player.AudioTrackCount,
                //AudioTrackDescription = player.AudioTrackDescription,
                //Channel = player.Channel,
                //Media = player.Media,
                Time = player.Time
            };
            var message = new StartLongRunningTaskMessage <MediaPlayerData> {
                TaskData = playerData
            };

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");
        }
Example #4
0
        private void StartService()
        {
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            timer.Stop();
        }
Example #5
0
        public async Task Start(StartLongRunningTaskMessage startLongRunningTaskMessage)
        {
            _cts = new CancellationTokenSource();

            _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LongRunningTask", OnExpiration);

            try
            {
                //INVOKE THE SHARED CODE
                var counter = new TaskCounter();
                await counter.RunCounter(_cts.Token, startLongRunningTaskMessage.Barcode, startLongRunningTaskMessage.PageName);
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                if (_cts.IsCancellationRequested)
                {
                    var message = new CancelledMessage();
                    Device.BeginInvokeOnMainThread(
                        () => MessagingCenter.Send(message, "CancelledMessage")
                        );
                }
            }

            UIApplication.SharedApplication.EndBackgroundTask(_taskId);
        }
Example #6
0
        private void BtnIniciar_OnClicked(object sender, EventArgs e)
        {
            // Enviamos un mensaje con la intencion de invocar el inicio del Servicio.
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, nameof(StartLongRunningTaskMessage));
        }
Example #7
0
        public LongRunningPage()
        {
            InitializeComponent();

            startLongRunningTask.Clicked += (s, e) =>
            {
                var message = new StartLongRunningTaskMessage();
                MessagingCenter.Send(message, nameof(StartLongRunningTaskMessage));
            };

            stopLongRunningTask.Clicked += (s, e) =>
            {
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, nameof(StopLongRunningTaskMessage));
            };

            notificationTest.Clicked += (s, e) =>
            {
                _notificationNumber++;
                string title   = $"Local Notification #{_notificationNumber}";
                string message = $"You have now receive {_notificationNumber} nogirications";
                _notificationManager.ScheduleNotification(title, message);
            };

            HandleReceiveMessages();

            InitializeNotificationManager();
        }
Example #8
0
        protected override void OnSleep()
        {
            // Handle when your app sleeps
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");
        }
        protected override bool OnBackButtonPressed()
        {
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StopLongRunningTaskMessage");
            return(base.OnBackButtonPressed());
        }
        protected override void OnAppearing()
        {
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");

            base.OnAppearing();
        }
Example #11
0
        protected override void OnSleep()
        {
            IsSleep = true;
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            //Task onsleep = SleepTimerStart();
        }
Example #12
0
        protected override void OnSleep()
        {
            // Handle when your app sleeps

            //Iniciamos el servicio al salir de la App
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");
        }
Example #13
0
        public Hem()
        {
            BLEProfileManager = App.BLEProfileManager;

            InitializeComponent();


            theBTunits.IsPullToRefreshEnabled = true;

            stopDanger.BindingContext  = new { w1 = App.ScreenWidth * 160 / (App.ScreenDPI), bgc2 = Color.White };
            startDanger.BindingContext = new { w0 = App.ScreenWidth * 160 / (App.ScreenDPI), bgc1 = Color.FromHex("#ededed") };

            //Battery
            progBar.BindingContext         = new { w4 = App.ScreenWidth * 160 / (App.ScreenDPI * 3), theprog = 0.5 };
            progBar.Scale                  = 1;
            batterystack.HorizontalOptions = LayoutOptions.CenterAndExpand;
            progBarText.BindingContext     = new { theprogtext = "50%" };
            checkBattery.BindingContext    = new { bgc3 = Color.White };



            startDanger.Clicked += (s, e) => {
                if (BLEProfileManager.bleprofile.Devices.Count != 0)
                {
                    var    device = BLEProfileManager.bleprofile.Devices.FirstOrDefault().Device;
                    string status = device.State.ToString();
                    if (status.Equals("Disconnected"))
                    {
                        DisplayAlert("No BlueTooth ", "You need to connect to SmartBand Alert first", "Ok");
                    }
                    else
                    {
                        //switchconnectbutton = 0;
                        //App.isConnectedBLE = false;
                        //need to be implement
                        //BLEProfileManager.bleprofile.Adapter.DisconnectDeviceAsync(device);
                        //BLEProfileManager.bleprofile.Devices.Clear();
                        //BLEProfileManager.init();
                        BLEProfileManager.newBLEprofile();
                        Task.Delay(1000);
                        BLEProfileManager.bleprofile.Adapter.ConnectToDeviceAsync(device);
                        Task.Delay(1000);
                        var message = new StartLongRunningTaskMessage();
                        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
                    }
                }
                else
                {
                    DisplayAlert("No BlueTooth ", "You need to connect to SmartBand Alert first", "Ok");
                }
            };

            stopDanger.Clicked += (s, e) => {
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, "StopLongRunningTaskMessage");
            };
        }
Example #14
0
        public async Task StartLocationAsync()
        {
            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");

            var toastMessage = new ToastMessage("Location tracking activated");

            toastMessage.ShowToast();
            mainViewModel.StrLocationOnOff = "Location tracking is on";
        }
Example #15
0
        public HemPage()
        {
            InitializeComponent();

            bleACRProfileManager = App.BLEAcrProfileManager;
            //theBTunits.IsPullToRefreshEnabled = true;

            stopDanger.BindingContext  = new { w1 = App.ScreenWidth * 160 / (App.ScreenDPI), bgc2 = Color.White };
            startDanger.BindingContext = new { w0 = App.ScreenWidth * 160 / (App.ScreenDPI), bgc1 = Color.FromHex("#ededed") };

            //Battery
            progBar.BindingContext = new { w4 = App.ScreenWidth * 160 / (App.ScreenDPI * 3), theprog = 0.5 };
            progBar.Scale          = 1;
            progBar.IsVisible      = false;
            progBarText.IsVisible  = false;
            progBarFirst.IsVisible = false;
            checkBattery.IsVisible = false;
            //btWarning.widthRequest = App.ScreenWidth * 160 / (App.ScreenDPI);
            batterystack.HorizontalOptions = LayoutOptions.CenterAndExpand;
            progBarText.BindingContext     = new { theprogtext = "........." };
            checkBattery.BindingContext    = new { bgc3 = Color.White };

            startDanger.Clicked += async(s, e) =>
            {
                if (App.isConnectedBLE && !App.dangerModeOn)
                {
                    //subNoTIFY.Dispose();
                    App.dangerModeOn = true;


                    var message = new StartLongRunningTaskMessage();
                    MessagingCenter.Send(message, "StartLongRunningTaskMessage");

                    connectToBackend(true);
                }
                else
                {
                    await DisplayAlert("Fel ", App.dangerModeOn? "FarligtlƤge Ƥr redan aktiverad." : "Anslut till en enhet fƶrst.", "Ok");
                }
                Task.Delay(500);     //Ska vi ta bort den ?
            };

            stopDanger.Clicked += (s, e) => {
                if (App.dangerModeOn)
                {
                    App.dangerModeOn = false;
                    connectToBackend(false);
                    App.ct.Cancel();
                    var message = new StopLongRunningTaskMessage();
                    MessagingCenter.Send(message, "StopLongRunningTaskMessage");
                }
            };
        }
        public void Notify(Intent intent)
        {
            var    rand              = new Random();
            var    randomNum         = rand.Next();
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutInt("topicId", randomNum);

            Global.SetNotifTopic(intent.Extras.GetString("push_type"));
            Global.SetListTopic(randomNum, intent.Extras.GetString("push_type"));


            Intent resultIntent = new Intent(this, typeof(MainActivity));

            resultIntent.PutExtras(valuesForActivity);

            Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            var fullmessage = intent.Extras.GetString("message") + "\n" + intent.Extras.GetString("article_data");
            var imageBitmap = GetImageBitmapFromUrl(intent.Extras.GetString("image_url"));

            NotificationCompat.BigPictureStyle picstyle = new NotificationCompat.BigPictureStyle();
            picstyle.BigPicture(imageBitmap);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle(intent.Extras.GetString("title"))
                                                 .SetNumber(Global.GetNotifCount())
                                                 .SetStyle(picstyle)
                                                 .SetSmallIcon(Resource.Drawable.UmbrellaArmyFavicon)
                                                 .SetContentText(String.Format(fullmessage));

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(ButtonClickNotificationId, builder.Build());

            if (Global.GetNotifTopic() != "general" || Global.GetNotifTopic() != "general_android")
            {
                var message = new StartLongRunningTaskMessage();
                MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            }
        }
        private void BarcodeManualCommandRecieverAsync()
        {
            try
            {
                bool isNew = BarcodeCollection.ToList().Any(x => x.Barcode == ManaulBarcode);

                BarcodeModel model = null;
                    if(!isNew)
                {
                    try
                    {
                        model = new BarcodeModel
                        {
                            Barcode = ManaulBarcode,
                            TagsStr = TagsStr,
                            Icon = Cloud,
                            Page = ViewTypeEnum.FillScanView.ToString(),
                            Contents = Tags.Count > 2 ? Tags?[2]?.Name??string.Empty : string.Empty
                        };
                        if (ConstantManager.Tags != null)
                        {
                            foreach (var item in ConstantManager.Tags)
                                model.Tags.Add(item);
                        }
                        BarcodeCollection.Add(model);
                    }
                   
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                    }

                    var current = Connectivity.NetworkAccess;
                    if (current == NetworkAccess.Internet)
                    {
                        var message = new StartLongRunningTaskMessage
                        {
                            Barcode = new List<string>() { ManaulBarcode },
                            PageName = ViewTypeEnum.FillScanView.ToString()
                        };
                        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
                    }

                    ManaulBarcode = string.Empty;
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
        private void BarcodeManualCommandRecieverAsync()
        {
            try
            {
                var isNew = BarcodeCollection.ToList().Any(x => x?.Kegs?.Partners?.FirstOrDefault()?.Kegs?.FirstOrDefault()?.Barcode == ManaulBarcode);
                if (!isNew)
                {
                    UpdateTagsStr();
                    BarcodeModel model = new BarcodeModel()
                    {
                        Barcode  = ManaulBarcode,
                        TagsStr  = TagsStr,
                        Icon     = _getIconByPlatform.GetIcon(Cloud),
                        Page     = ViewTypeEnum.ScanKegsView.ToString(),
                        Contents = SelectedBrand?.BrandName
                    };

                    if (ConstantManager.Tags != null)
                    {
                        foreach (var item in ConstantManager.Tags)
                        {
                            model.Tags.Add(item);
                        }
                    }

                    BarcodeCollection.Add(model);

                    var current = Connectivity.NetworkAccess;
                    if (current == NetworkAccess.Internet)
                    {
                        var message = new StartLongRunningTaskMessage
                        {
                            Barcode = new List <string>()
                            {
                                ManaulBarcode
                            },
                            PageName = ViewTypeEnum.ScanKegsView.ToString()
                        };
                        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
                    }

                    ManaulBarcode = string.Empty;
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Example #19
0
 public void StartJourneyCommandExecute()
 {
     if (!JourneyOngoing)
     {
         var message = new StartLongRunningTaskMessage();
         MessagingCenter.Send(message, "StartLongRunningTaskMessage");
         JourneyOngoing = true;
     }
     else
     {
         var message = new StopLongRunningTaskMessage();
         MessagingCenter.Send(message, "StopLongRunningTaskMessage");
         JourneyOngoing = false;
     }
 }
 private void BtnStartCollection_Clicked(object sender, EventArgs e)
 {
     if (StaticObjects.IsCollecting == false)
     {
         var message = new StartLongRunningTaskMessage();
         MessagingCenter.Send(message, "StartLongRunningTaskMessage");
         //DataCollection = true;
         DisplayAlert("Notice", "Data collection enabled. Storing in database.", "OK");
         //CollectionStat = "Collecting Data";
     }
     else
     {
         DisplayAlert("Notice", "Data already enabled.", "OK");
     }
 }
Example #21
0
        //    public void onTaskRemoved(Intent rootIntent)
        //    {
        //        base.OnTaskRemoved(rootIntent);
        //        PendingIntent service = PendingIntent.GetService(
        //                ApplicationContext,
        //                1001,
        //                new Intent(ApplicationContext, typeof(DatabaseInsertions)),
        //        Android.App.PendingIntent.FLAG_ONE_SHOT);

        //    AlarmManager alarmManager = (AlarmManager)GetSystemService(Context.AlarmService);
        //    alarmManager.Set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 1000, service);
        //}

        public override void OnDestroy()
        {
            //Log.Debug(logTag, "Service has been terminated");
            //StopSelf();
            var _message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(_message, "StartLongRunningTaskMessage");
            if (_cts != null)
            {
                _cts.Token.ThrowIfCancellationRequested();

                _cts.Cancel();
            }

            base.OnDestroy();
        }
		public LongRunningPage ()
		{
			InitializeComponent ();

			//Wire up XAML buttons
			longRunningTask.Clicked += (s, e) => {
				var message = new StartLongRunningTaskMessage ();
				MessagingCenter.Send (message, "StartLongRunningTaskMessage");
			};

			stopLongRunningTask.Clicked += (s, e) => {
				var message = new StopLongRunningTaskMessage ();
				MessagingCenter.Send (message, "StopLongRunningTaskMessage");
			};
				
			HandleReceivedMessages ();
		}
        private async void OnDidStopAsync(DidStopReason reason)
        {
            var message = new StartLongRunningTaskMessage
            {
                Barcode  = models.Select(x => x.Barcode).ToList(),
                PageName = PageName
            };

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");

            await _navigationService.GoBackAsync(new NavigationParameters
            {
                { "models", models }
            }, animated : false);

            await _navigationService.GoBackAsync(animated : false);
        }
        public LongRunningPage()
        {
            InitializeComponent();

            //Wire up XAML buttons
            longRunningTask.Clicked += (s, e) => {
                var message = new StartLongRunningTaskMessage();
                MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            };

            stopLongRunningTask.Clicked += (s, e) => {
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, "StopLongRunningTaskMessage");
            };

            HandleReceivedMessages();
        }
Example #25
0
        public HemPage()
        {
            InitializeComponent();

            bleACRProfileManager = App.BLEAcrProfileManager;

            //theBTunits.IsPullToRefreshEnabled = true;

            stopDanger.BindingContext  = new { w1 = App.ScreenWidth * 160 / (App.ScreenDPI), bgc2 = Color.White };
            startDanger.BindingContext = new { w0 = App.ScreenWidth * 160 / (App.ScreenDPI), bgc1 = Color.FromHex("#ededed") };

            //Battery
            progBar.BindingContext         = new { w4 = App.ScreenWidth * 160 / (App.ScreenDPI * 3), theprog = 0.5 };
            progBar.Scale                  = 1;
            batterystack.HorizontalOptions = LayoutOptions.CenterAndExpand;
            progBarText.BindingContext     = new { theprogtext = "50%" };
            checkBattery.BindingContext    = new { bgc3 = Color.White };

            startDanger.Clicked += async(s, e) =>
            {
                if (App.isConnectedBLE)
                {
                    //subNoTIFY.Dispose();
                    dangerModeOn = true;
                    var message = new StartLongRunningTaskMessage();
                    MessagingCenter.Send(message, "StartLongRunningTaskMessage");
                }
                else
                {
                    await DisplayAlert("Wrong ", "Conect to a device first", "Ok");
                }
            };

            stopDanger.Clicked += (s, e) => {
                dangerModeOn = false;
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, "StopLongRunningTaskMessage");
            };
        }
        public LongRunningPage()
        {
            InitializeComponent();

            //Wire up XAML buttons
            longRunningTask.Clicked += (s, e) => {
                var message = new StartLongRunningTaskMessage();
                MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            };

            stopLongRunningTask.Clicked += (s, e) => {
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, "StopLongRunningTaskMessage");
            };


            customMap.RouteCoordinates.Add(new Position(37.797534, -122.401827));
            customMap.RouteCoordinates.Add(new Position(37.797510, -122.402060));
            customMap.RouteCoordinates.Add(new Position(37.790269, -122.400589));
            customMap.RouteCoordinates.Add(new Position(37.790265, -122.400474));
            customMap.RouteCoordinates.Add(new Position(37.790228, -122.400391));
            customMap.RouteCoordinates.Add(new Position(37.790126, -122.400360));
            customMap.RouteCoordinates.Add(new Position(37.789250, -122.401451));
            customMap.RouteCoordinates.Add(new Position(37.788440, -122.400396));
            customMap.RouteCoordinates.Add(new Position(37.787999, -122.399780));
            customMap.RouteCoordinates.Add(new Position(37.786736, -122.398202));
            customMap.RouteCoordinates.Add(new Position(37.786345, -122.397722));
            customMap.RouteCoordinates.Add(new Position(37.785983, -122.397295));
            customMap.RouteCoordinates.Add(new Position(37.785559, -122.396728));
            customMap.RouteCoordinates.Add(new Position(37.780624, -122.390541));
            customMap.RouteCoordinates.Add(new Position(37.777113, -122.394983));
            customMap.RouteCoordinates.Add(new Position(37.776831, -122.394627));

            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(37.79752, -122.40183), Distance.FromMiles(1.0)));


            HandleReceivedMessages();
        }
        public SlowVehicleView(Vehicle veh)
        {
            //var attributesWindow = new WindowManagerLayoutParams();

            InitializeComponent();

            this.Title = "Emitiendo posiciĆ³n: " + veh;

            var message = new StartLongRunningTaskMessage();

            MessagingCenter.Send(message, "StartLongRunningTaskMessage");

            var locator = CrossGeolocator.Current;

            if (!locator.IsGeolocationAvailable || !locator.IsGeolocationEnabled)
            {
                DisplayAlert("Aviso", "Por favor, habilita el GPS", "OK");
            }
            else
            {
                BindingContext = new SlowVehicleViewModel(veh, MyMap);
            }
        }
Example #28
0
        public void ExecuteTimerTap(object nothing)
        {
            SetGameInProgress();
            switch (_timerState)
            {
            case TimerState.NotStarted:
                _timerState = TimerState.Active;
                var startMessage = new StartLongRunningTaskMessage();
                MessagingCenter.Send(startMessage, "StartLongRunningTaskMessage");
                break;

            case TimerState.Active:
                _timerState = TimerState.Paused;
                break;

            case TimerState.Paused:
                _timerState = TimerState.Active;
                break;

            default:
                break;
            }
        }
Example #29
0
        public LongRunningPage(DtoResultLogin user)
        {
            InitializeComponent();

            lblCronometro.Text = "00:00:00";


            //Wire up XAML buttons
            longRunningTask.Clicked += (s, e) => {
                var message = new StartLongRunningTaskMessage();
                MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            };

            stopLongRunningTask.Clicked += (s, e) => {
                var message = new StopLongRunningTaskMessage();
                MessagingCenter.Send(message, "StopLongRunningTaskMessage");
                //stopwatch.Stop();
                //lblCronometro.Text = "00:00:00";
                //stopwatch.Reset();
            };

            HandleReceivedMessages();
        }
        private void BarcodeManualCommandRecieverAsync()
        {
            try
            {
                var isNew = BarcodeCollection.ToList().Any(x => x.Barcode == ManaulBarcode);
                if (!isNew)
                {
                    BarcodeModel model = new BarcodeModel
                    {
                        Barcode = ManaulBarcode,
                        TagsStr = string.Empty,
                        Icon    = Cloud
                    };

                    BarcodeCollection.Add(model);
                    var current = Connectivity.NetworkAccess;
                    if (current == NetworkAccess.Internet)
                    {
                        var message = new StartLongRunningTaskMessage
                        {
                            Barcode = new List <string>()
                            {
                                ManaulBarcode
                            },
                            PageName = ViewTypeEnum.MaintainScanView.ToString()
                        };
                        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
                    }

                    ManaulBarcode = string.Empty;
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Example #31
0
        private async Task StartDownloadAsync()
        {
            if (_downloadStatus == DownloadStatus.NotStarted && _downloadQueue.Count > 0)
            {
                _downloadStatus = DownloadStatus.IsDownloading;
                try
                {
                    var queueItem = _downloadQueue.Dequeue();
                    //download the file to storage
                    var startMessage = new StartLongRunningTaskMessage();              //goes to Android project Service, returns thru DownloadFinishedMessage
                    MessagingCenter.Send(startMessage, "StartLongRunningTaskMessage"); //start background downloads
                    switch (queueItem.ItemType)
                    {
                    case QueueType.PodcastFile:
                        var rssEpisode = (RssEpisode)queueItem.QueueDataObject;
                        await DownloadPodcastFileAsync(rssEpisode);

                        break;

                    case QueueType.ImageFile:
                        var fileEpisode = (RssEpisode)queueItem.QueueDataObject;
                        DownloadImageFile(fileEpisode);
                        break;

                    case QueueType.RssFeed:
                        var feedEpisode = (RssEpisode)queueItem.QueueDataObject;
                        DownloadFeedFile(feedEpisode);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("DownloadService.StartDownload Could not Start Downloader " + ex.Message);
                }
            }
        }