【问题标题】:Android Picaso - How to not cache images that are not downloaded through it?Android Picasso - 如何不缓存未通过它下载的图像?
【发布时间】:2014-09-02 18:10:20
【问题描述】:

所以我正在使用 Picaso 加载一些图像并像这样缓存它们:

    ImageView logo = (ImageView)findViewById(R.id.image_logo);
    Picasso.with(VenueDetailsActivity.this).load(url).into(logo);

但是,我还有其他不应缓存的图像。但是,似乎只要 Picaso 在应用程序的任何位置运行,它就会开始缓存所有图像,无论我是否使用 Picaso 加载它们。

如何不使用 Picasso 缓存某些图像?

** 无论是否使用 Picasso,Picasso 是否会设置您的应用以缓存任何图像加载?**

我用来下载图片的方法是:

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
    }
}

【问题讨论】:

    标签: java android image caching picasso


    【解决方案1】:

    如果您不希望 Picasso 缓存图像,您可以像这样使用 .skipMemoryCache():

    Picasso.with(VenueDetailsActivity.this).load(url).skipMemoryCache().into(logo);
    

    更多信息可以查看文档here

    【讨论】:

    • 就像我说的,我什至没有将毕加索用于不需要缓存的图像。我正在使用下载图像的正常方式。但是,我什至使用 .skipMemoryCache() 方法对 Picasso 进行了尝试,但这也不起作用。
    猜你喜欢
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 2023-01-29
    • 2014-01-14
    • 1970-01-01
    • 2014-06-10
    • 1970-01-01
    • 2017-05-05
    相关资源
    最近更新 更多