【问题标题】:How to pin images for offline use with Glide?如何使用 Glide 固定图像以供离线使用?
【发布时间】:2016-02-18 18:20:25
【问题描述】:

我有一个想要显示的照片列表,所以我使用RecyclerViewRecyclerView.Adapter。所以当我在onBindViewHolder() 中绑定视图时,我会这样做:

// photo is a Object that contains a url
// photoViewHolder.photo is the imageview
Glide.with(photoViewHolder.photo.getContext()) //use the imageview context
                .load(photo.getPhotoScaledURL())//load the photo using an url
                .into(photoViewHolder.photo); //into the imageview

但在这里我总是依赖 URL。我能以某种方式始终缓存此图像吗?或者有更好的方法吗?

【问题讨论】:

    标签: android image-loading android-glide


    【解决方案1】:

    要离线显示一些图片,首先下载您的图片并将路径存储在数据库中。现在每当您离线显示下载的图片时。在线时只需检查图片是否已经下载,如果下载则显示下载的图片否则使用滑行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      • 2011-08-31
      • 2016-11-23
      • 1970-01-01
      相关资源
      最近更新 更多