【发布时间】:2016-05-24 03:01:19
【问题描述】:
当我想从 Dropbox 中获取我的照片并将其加载到 GridView 并且我也想在适配器中使用 Picasso 时遇到问题。 方法 load() 将采用可下载的 URL,
PS:我使用的是 Dropbox Android SDK 1.6.1
如果我使用方法 media() 并像这样从 Dropbox 获取 url:
// Get the metadata for a directory , | request |
DropboxAPI.Entry dirent = Log_in.mApi.metadata(Log_in.APP_DIR + "/images/", 1000, null, true, null);
if (!dirent.isDir || dirent.contents == null) {
// It's not a directory, or there's nothing in it
mErrorMsg = "File or empty directory";
//return false;
}
// Make a list of everything in it that we can get a thumbnail for
thumbs = new ArrayList<>();
imagePath = new ArrayList<>();
for (DropboxAPI.Entry ent : dirent.contents) {
if (ent.thumbExists) {
// Add it to the list of thumbs we can choose from
thumbs.add(ent);
// do another requests (many requests to dropbox to get the urls , and this is terrible it takes request time for each image !
imagePath.add(Log_in.mApi.media(ent.path,true).url);
}
}
这根本不切实际,因为获取每个 url 需要很长时间,这就是场景:
- 在“照片”文件夹中搜索图片(1 个请求)
- 使用 [media][1] 获取直接 URL(1 *(图像)请求)
- 在适配器中使用毕加索(1 *(图像)请求) 我将有 count(images) * 2 + 1 个请求计数
太糟糕了,需要更好的解决方案。
PS:我试过这个https://medium.com/@jpardogo/requesthandler-api-for-picasso-library-c3ee7c4bec25#.wpmea1eci
但代码不完整,有些类未解析/存在,有些变量未定义。
所以任何人都知道如何使用 picasso 处理 Dropbox 图像 api。
【问题讨论】:
-
您可能想直接下载缩略图而不是使用媒体链接:dropboxstatic.com/static/developers/…
-
@Greg method load of picasso can't download input stream and drobpox download依赖于输入流。
标签: android dropbox-api picasso