【发布时间】:2015-07-07 21:10:45
【问题描述】:
我正在尝试使用ownCloud 在Android 中下载RemoteFiles 列表。我可以很好地下载文件,但我想在文件完成时通知用户。我正在下载整个目录:
@Override
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
if (operation instanceof ReadRemoteFolderOperation) {
if (result.isSuccess()) {
Toast.makeText(this, "Finished reading folder", Toast.LENGTH_SHORT).show();
for (Object o : result.getData()) {
RemoteFile remoteFile = (RemoteFile) o;
String remotePath = remoteFile.getRemotePath();
File targetDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +
"/owncloud_download");
downloadHelper.downloadFile(remoteFile, targetDirectory);
}
}
}
if (operation instanceof DownloadRemoteFileOperation) {
if (result.isSuccess()) {
// Notify the user here that the file finished
}
}
}
我查看了 ownCloud 库源,但除了指示成功的布尔值和 HTTP 状态代码之外,似乎找不到 DownloadRemoteFileOperation 返回的结果。我认为它可能在 result.getLogMessage() 中,但这只是给了我一个 HTTP 200 状态。如何获取已完成文件的名称?
编辑:我还查看了result.getData(),但在 DownloadRemoteFileOperation 中这是空的。
【问题讨论】: