【问题标题】:Load Dropbox Photos With Picasso?用毕加索加载 Dropbox 照片?
【发布时间】: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. 在“照片”文件夹中搜索图片(1 个请求)
  2. 使用 [media][1] 获取直接 URL(1 *(图像)请求)
  3. 在适配器中使用毕加索(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


【解决方案1】:

我认为 Dropbox 中有一个关于此的示例,请尝试检查此链接 dropbox sample

有2个文件需要查看PicassoClient.java和FileThumbnailRequestHandler.java

【讨论】:

  • 如何运行示例?
  • 只需使用 git 克隆 repo 并从 Android Studio 将项目导入文件夹示例中。
猜你喜欢
  • 2013-08-12
  • 2015-11-16
  • 1970-01-01
  • 2020-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多