How set custom downloader in Universal Image Loade

2019-04-06 23:07发布

问题:

how to set my custom downloader? I cannot see a Builder method to change the downloader class.

I want use Google HTTP Client library and I have a subclass ready, like this:

import com.nostra13.universalimageloader.core.download.BaseImageDownloader;

public class GoogleHttpDownloader extends BaseImageDownloader {

    //constructors, etc...
    @Override
    protected InputStream getStreamFromNetwork(String imageUri, Object extra)
        throws IOException {
        //new instancce of client, connect, return stream
    }
}

But, how to make UIL to use?

Thanks.

回答1:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
        ...
        .imageDownloader(new GoogleHttpDownloader())
        ...
        .build();
ImageLoader.getInstance().init(config);