【问题标题】:How to get the images from cache when the app is offline by using image loader concept?当应用离线时如何使用图像加载器概念从缓存中获取图像?
【发布时间】:2014-11-17 05:58:32
【问题描述】:

我正在使用通用图像加载器概念从远程服务器加载图像并更新到 imageview。第一次我的应用程序具有互联网连接并将所有图像保存在应用程序缓存(“//data//cache/”)内存和更新到 imageview。一旦图像在缓存中可用,我想离线从缓存中获取图像,而不是从远程服务器。

为了获得我按照通用延迟加载概念实现的图像:

    imageLoader.displayImage(url,imageView, options, animateListener);

我想从缓存中离线获取相同的图像。 请给我更好的解决方案来获取离线加载的图像。

【问题讨论】:

标签: android image caching offline universal-image-loader


【解决方案1】:

我得到的解决方案如下:

 if(isConnectingToInternet()){
    imageLoader.displayImage(image_url, imageView, options);
    }
    else{
        File file = imageLoader.getDiscCache().get(image_url);
        Log.v(TAG,"file_ path :"+file.getPath());
        Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
        imageView.setImageBitmap(myBitmap);
    }

【讨论】:

    【解决方案2】:

    您可以通过高效使用 Memory 和 FileChache 找到正在离线处理的图像,您可以查看代码为 Album Sample 这基本上是一个无限列表表示。

    【讨论】:

      猜你喜欢
      • 2014-11-16
      • 2014-06-16
      • 2023-03-16
      • 2016-10-06
      • 1970-01-01
      • 2019-01-16
      • 2012-07-11
      • 2017-09-20
      • 2013-05-02
      相关资源
      最近更新 更多