I have added some manually icons to drawable
which for some manually data it have to take the drawable
and if a icon is not in drawable
then take it from the Glide
.
I tried something like till now but only it is getting the icons from drawable
.
I want to check if icon exists at drawable
take from there and if for an url the icon is not in drawable then go at another statement and take it from Glide
.
Below is my code.
The resID is always 0
String imageUrl = BASE_URL + arrayList.get(position).getSearchUrl() + "&size=32";
int resID = context.getResources().getIdentifier("icon", "drawable",context.getPackageName());
if (resID == 0) {
Log.d("TAG", "onBindViewHolder: " + resID);
viewHolder.tvIcon.setImageResource(arrayList.get(position).getIcon());
} else {
Log.d("TAG", "onBindViewHolder: Glide" + resID);
Glide.with(context)
.load(imageUrl)
.apply(requestOptions
.placeholder(R.drawable.default_favicon)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.fitCenter())
.into(viewHolder.tvIcon);
}
from Getting icon from url and icon from drawable it is taking only from drawable
No comments:
Post a Comment