简体   繁体   English

离子库什图书馆

[英]Ion koush library

I'm trying to save image from url to a new File with ion library. 我正在尝试将图像从url保存到带有离子库的新文件中。 But nothing happens. 但是什么也没发生。 Can anybody help me with it? 有人可以帮我吗?

Ion.with(mContext)
                .load("someUrl")
                .write(new File(mContext.getCacheDir(), "123.jpg"));

Use Universal Image Loader 使用通用图像加载器

You can do it by 你可以做到

ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance

// Load image, decode it to Bitmap and return Bitmap to callback
imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() {
    @Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage){
    // Do whatever you want with Bitmap
}
});

Ion is asynchronous. 离子是异步的。 Use .setCallback to get a callback when it completes. 使用.setCallback获取完成时的回调。

Ion.with(mContext)
                .load("someUrl")
                .write(new File(mContext.getCacheDir(), "123.jpg"));
                .setCallback(....)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM