How to resolve Glide setTag() issue
The setTag() is common method for storing data for temporary purpose and utilize it later on.
but if you are using Glide lib for image processing purpose then you might not able to use the setTag() function.
This is the stack trace..
This is the common use case of the Glide..
but if you are using Glide lib for image processing purpose then you might not able to use the setTag() function.
This is the stack trace..
java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
at com.bumptech.glide.request.target.ViewTarget.getRequest(ViewTarget.java:105)
at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:605)
at net.twisterrob.app.android.view.Adapter.bindView()
...
This is the common use case of the Glide..
Glide.with(mCon).load(model.getStrImagePath()).
placeholder(R.drawable.loading).
error(R.drawable.dish_placeholder)
.fitCenter()
.into(mholder.ivDishImg);
Problem arises when u write..
mholder.ivDishImg.setTag(position);
we can use setTag(ViewTarget,data) a constant id and data while adding tag to the ViewTarget.
and retrive the same by using getTag(ViewTarget)
ImageView ivDishImg = (ImageView) itemView.findViewById(R.id.ivMyHoodDish);
mholder.ivDishImg.setTag(R.id.ivMyHoodDish,position);
mHolder.ivDishImg.setOnClickListener(this);
public void onClick(View v) { int position = 0; try { position = (Integer) v.getTag(R.id.ivMyHoodDish); } catch (Exception e) { e.printStackTrace(); } }
0 comments: