public async Task GetFolderItems(string id, string folderName = null) { await _itemsLock.WaitAsync(); FolderName = folderName; try { Items.Clear(); FolderName = folderName; int itemCount = 0; IsLoading = true; BoxFolder folder; do { folder = await _client.FoldersManager.GetItemsAsync(id, _numItems, itemCount, new List<string>() { BoxItem.FieldName, BoxItem.FieldModifiedAt, BoxItem.FieldSize, BoxFolder.FieldItemCollection, BoxFolder.FieldPathCollection, BoxCollection.FieldTotalCount }); IsLoading = false; if (folder == null) { string message = "Unable to get folder items. Please try again later"; break; } // Is first time in loop if (itemCount == 0) { CurrentFolder = folder; if (folder.PathCollection != null && folder.PathCollection.TotalCount > 0) { var parent = folder.PathCollection.Entries.LastOrDefault(); if (parent != null && parent.Id != await PeekParentFolder()) await PushParentFolder(parent.Id); } } foreach (var i in folder.ItemCollection.Entries) { BoxItemViewModel biVM = new BoxItemViewModel(i, _client); if (i.Type == "folder") { #if WINDOWS_PHONE biVM.Image = new BitmapImage(new Uri("/Assets/PrivateFolder.png", UriKind.RelativeOrAbsolute)); #else var uri = new System.Uri("ms-appx:///Box.V2.Controls.W8/Assets/PrivateFolder.png"); var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri); var stream = await file.OpenReadAsync(); biVM.Image = new BitmapImage(); await biVM.Image.SetSourceAsync(stream); #endif } Items.Add(biVM); } itemCount += _numItems; } while (itemCount < folder.ItemCollection.TotalCount); } finally { _itemsLock.Release(); } }
public async Task GetFolderItems(string id, string folderName = null) { await _itemsLock.WaitAsync(); FolderName = folderName; try { Items.Clear(); FolderName = folderName; int itemCount = 0; IsLoading = true; BoxFolder folder; do { folder = await _client.FoldersManager.GetItemsAsync(id, _numItems, itemCount, new List <string>() { BoxItem.FieldName, BoxItem.FieldModifiedAt, BoxItem.FieldSize, BoxFolder.FieldItemCollection, BoxFolder.FieldPathCollection, BoxCollection.FieldTotalCount }); IsLoading = false; if (folder == null) { string message = "Unable to get folder items. Please try again later"; break; } // Is first time in loop if (itemCount == 0) { CurrentFolder = folder; if (folder.PathCollection != null && folder.PathCollection.TotalCount > 0) { var parent = folder.PathCollection.Entries.LastOrDefault(); if (parent != null && parent.Id != await PeekParentFolder()) { await PushParentFolder(parent.Id); } } } foreach (var i in folder.ItemCollection.Entries) { BoxItemViewModel biVM = new BoxItemViewModel(i, _client); if (i.Type == "folder") { #if WINDOWS_PHONE biVM.Image = new BitmapImage(new Uri("/Assets/PrivateFolder.png", UriKind.RelativeOrAbsolute)); #else var uri = new System.Uri("ms-appx:///Box.V2.Controls.W8/Assets/PrivateFolder.png"); var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri); var stream = await file.OpenReadAsync(); biVM.Image = new BitmapImage(); await biVM.Image.SetSourceAsync(stream); #endif } Items.Add(biVM); } itemCount += _numItems; } while (itemCount < folder.ItemCollection.TotalCount); } finally { _itemsLock.Release(); } }