public async Task GetFiles()
        {
            try
            {
                await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    _storageItems.Clear();
                    IsFolderEmpty = false;
                });

                IReadOnlyList <IStorageItem> items = null;
#if WINDOWS_APP
                var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, VLCFileExtensions.Supported);
                var fileQuery    = BackStack.Last().CreateItemQueryWithOptions(queryOptions);
                items = await fileQuery.GetItemsAsync();
#else
                items = await BackStack.Last().GetItemsAsync();
#endif
                await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    StorageItems = new ObservableCollection <IStorageItem>(items);
                    OnPropertyChanged("StorageItems");
                });
            }
            catch (Exception exception)
            {
                LogHelper.Log("Failed to index folders and files in " + BackStack.Last().DisplayName + "\n" + exception.ToString());
            }
            await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                OnPropertyChanged("CanGoBack");
                IsFolderEmpty = !StorageItems.Any();
            });
        }
示例#2
0
        public override async Task GetFiles()
        {
            try
            {
                await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () =>
                {
                    StorageItems.Clear();
                    IsFolderEmpty  = false;
                    IsLoadingFiles = true;
                });

                var currentMedia = BackStack.Last().Media;
                if (currentMedia == null)
                {
                    return;
                }
                var mediaList = await Locator.MediaLibrary.DiscoverMediaList(currentMedia);

                for (int i = 0; i < mediaList.count(); i++)
                {
                    var             media       = mediaList.itemAtIndex(i);
                    IVLCStorageItem storageItem = null;
                    if (media.type() == MediaType.Directory)
                    {
                        storageItem = new VLCStorageFolder(media);
                    }
                    else if (media.type() == MediaType.File)
                    {
                        storageItem = new VLCStorageFile(media);
                    }
                    if (storageItem == null)
                    {
                        return;
                    }
                    await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () => StorageItems.Add(storageItem));
                }
                await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Low, () =>
                {
                    OnPropertyChanged(nameof(StorageItems));
                    IsFolderEmpty  = !StorageItems.Any();
                    IsLoadingFiles = false;
                });
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Exception when getting network files {e.ToString()}");
            }
        }
        public override async Task GetFiles()
        {
            try
            {
                await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Normal, () =>
                {
                    StorageItems.Clear();
                    IsFolderEmpty  = false;
                    IsLoadingFiles = true;
                });

                IReadOnlyList <IStorageItem> items = null;
                var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, VLCFileExtensions.Supported);
                var fileQuery    = (BackStack.Last().StorageItem as StorageFolder).CreateItemQueryWithOptions(queryOptions);
                items = await fileQuery.GetItemsAsync();

                var vlcItems = new ObservableCollection <IVLCStorageItem>();
                foreach (var storageItem in items)
                {
                    if (storageItem.IsOfType(StorageItemTypes.File))
                    {
                        var file = new VLCStorageFile(storageItem as StorageFile);
                        vlcItems.Add(file);
                    }
                    else if (storageItem.IsOfType(StorageItemTypes.Folder))
                    {
                        var folder = new VLCStorageFolder(storageItem as StorageFolder);
                        vlcItems.Add(folder);
                    }
                }
                await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () =>
                {
                    StorageItems = new ObservableCollection <IVLCStorageItem>(vlcItems);
                    OnPropertyChanged(nameof(StorageItems));
                    IsFolderEmpty  = !StorageItems.Any();
                    IsLoadingFiles = false;
                });
            }
            catch (Exception exception)
            {
                LogHelper.Log("Failed to index folders and files in " + BackStack.Last().Name + "\n" + exception.ToString());
                await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () =>
                {
                    IsFolderEmpty  = !StorageItems.Any();
                    IsLoadingFiles = false;
                });
            }
        }