I'm Using Android Universal Image loader in my news app i'm currently working on. I'm using NewsAPI to fetch news. After parsing the JSON from the website. I populate a list view using a custom adapter and universal image loader is used to get the images in background. But for some pictures UIL doesn't support scheme(protocol) by default [null].You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
exception is displayed.
I think in some images the URI is not in the format of Library expecting.
So my question is how do i fill the image's position which gave me the error from a picture that i have in the Drawable Folder. (404 picture indicating the image could not be downloaded)
i found where i should put the code.
protected InputStream getStreamFromOtherSource(String imageUri, Object extra) throws IOException {
throw new UnsupportedOperationException(String.format("UIL doesn't support scheme(protocol) by default [%s]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))", new Object[]{imageUri}));
}
I need to know what kind of code i should put here to put a 404 image from my drawable file if the image is not downloadable.
Bro.. you can use Piccasso image library for android. It can solve your issue.
Sample code:
if(!image.equals("default")){
Picasso.with(Profile.this).load(image).networkPolicy(NetworkPolicy.OFFLINE)
.placeholder(R.drawable.default).into(mDisplayImage, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError() {
Picasso.with(Profile.this).load(image).placeholder(R.drawable.default).into(mDisplayImage);
}
});
}
Here it can replace the default (i.e) 404 found image while Error condition
And small suggesstion that, you can use Easy News Library for simple retrieval of news from NewsAPI. Here we don't need to parse the JSON. It gives the data by single method call