Exemplo n.º 1
0
        public async void Download(TransferQueue transferQueue)
        {
            // User must be online to perform this operation
            if ((this.Parent?.Type != ContainerType.FolderLink) && !await IsUserOnlineAsync())
            {
                return;
            }
            if (transferQueue == null)
            {
                return;
            }

            var downloadFolder = await FolderService.SelectFolder();

            if (downloadFolder == null)
            {
                return;
            }
            if (!await TransferService.CheckExternalDownloadPathAsync(downloadFolder.Path))
            {
                return;
            }

            this.Transfer.ExternalDownloadPath = downloadFolder.Path;
            transferQueue.Add(this.Transfer);
            this.Transfer.StartTransfer();

            // If is a file or folder link, navigate to the Cloud Drive page
            if (this.ParentContainerType == ContainerType.FileLink ||
                this.ParentContainerType == ContainerType.FolderLink)
            {
                OnUiThread(() =>
                {
                    NavigateService.Instance.Navigate(typeof(CloudDrivePage), false,
                                                      NavigationObject.Create(this.GetType()));
                });
            }
        }