Skip to content

ImageView.setTag cannot be used for ViewHolder when root of layout #370

@TWiStErRob

Description

@TWiStErRob

Glide Version/Integration library (if any): 3.5.2
Device/Android Version: S4/4.4
Issue details/Repro steps:
Consider a ListView containing a dead simple layout:

<?xml version="1.0" encoding="utf-8"?>
<ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />

and an Adapter which is using the usual ViewHolder pattern, i.e. inflating the view from resource (above) and setTag(vh);, now Glide wants to do the same when loading the image. There could easily be a way to prevent conflicts, by allowing the ViewTarget users to set an ID to use with setTag(int, Object), even if it's just a static method on ViewTarget (default beingView.NO_ID -> setTag(Object)).

Glide load line:

Glide.with(context).load(...).into(vh.image);

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()
            ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions