我使用picasso
插件来加载图像。保存图像在SD卡后毕加索加载图像
Picasso.with(context).load(BackendConfig.media_url+folder+holder.media_name).resize(150, 150).into(holder.imageView);
它工作正常。但是,我想通过从URL
加载一次将该图像保存在SD卡中。
我该怎么做?
我使用picasso
插件来加载图像。保存图像在SD卡后毕加索加载图像
Picasso.with(context).load(BackendConfig.media_url+folder+holder.media_name).resize(150, 150).into(holder.imageView);
它工作正常。但是,我想通过从URL
加载一次将该图像保存在SD卡中。
我该怎么做?
毕加索使用LRU磁盘缓存,无需担心从URL加载一次。如果您需要加载并保存实际图像作为文件,请将其加载为位图资源,并使用Bitmap.compress和FileOutputStream保存到文件(PNG/JPEG/WEBP)中。
你可以使用(对于我自己刨光本)这个轻量级的Android库VINCI它做你想做
LruCache
files/bitmaps
阅读此WIKI part更多访问我的github repo。
Storage store = Vinci.base(context).process().load(uri).file();
Log.e("Created", Boolean.toString(store.isCreated()));
Log.e("FileObject", store.FileObject().toString());
Log.e("FullPath", store.getfullPath().getPath());
Log.e("LocalPath", store.LocalPath());
Log.e("Get Bitmap File", String.valueOf(store.getBitmap()));