use of com.onedrive.sdk.extensions.IItemCollectionPage in project keepass2android by PhilippC.
the class OneDriveStorage method listFiles.
@Override
public List<FileEntry> listFiles(String parentPath) throws Exception {
try {
ArrayList<FileEntry> result = new ArrayList<FileEntry>();
parentPath = removeProtocol(parentPath);
IItemCollectionPage itemsPage = oneDriveClient.getDrive().getRoot().getItemWithPath(parentPath).getChildren().buildRequest().get();
if (parentPath.endsWith("/"))
parentPath = parentPath.substring(0, parentPath.length() - 1);
while (true) {
List<Item> items = itemsPage.getCurrentPage();
if (items.isEmpty())
return result;
for (Item i : items) {
FileEntry e = getFileEntry(parentPath + "/" + i.name, i);
Log.d("KP2AJ", e.path);
result.add(e);
}
IItemCollectionRequestBuilder nextPageReqBuilder = itemsPage.getNextPage();
if (nextPageReqBuilder == null)
return result;
itemsPage = nextPageReqBuilder.buildRequest().get();
}
} catch (OneDriveServiceException e) {
throw convertException(e);
}
}
Aggregations