Android Question [SOLVED] Amir_Glide throws Exception "You must not call setTag() ...". What is needed to do?

fredo

Well-Known Member
Licensed User
Longtime User
Amir_RecycleView is of great benefit in terms of a modern UI. To load images, the Amir_Glide lib is used in the rich sample projects.

During the attempt to use the Amir_Glide lib in a new project the following error occurs:
java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting



B4X:
Sub arv_onBindViewHolder (Parent As Panel, Position As Int)
    Log("#-Sub arv_onBindViewHolder, Position=" & Position)
    'Log("#-  x111, Parent.Tag=" & Parent.Tag)
    
    
    ' --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    ' This fills the item content from the Dataset
    ' corresponding to the position
    ' --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    Dim panBack As Panel = Parent.GetView(0)
    Dim Label1 As Label = panBack.GetView(0)
    Dim Label2 As Label = panBack.GetView(1)
    Dim ImageView1 As ImageView = panBack.GetView(2)

    Dim arvItemX As arvItem = DataSet.Get(Position)   
    Label1.Text = arvItemX.Title
    Label2.Text = arvItemX.Description

    Parent.Tag = arvItemX.ImagePath
    LoadImage(ImageView1, arvItemX.ImagePath)

    panBack.Height = Label1.Height +Label2.Height +(Label1.Top *2)     
    Parent.Height = panBack.Height +8dip
    
End Sub

Public Sub LoadImage (Img As ImageView, ImageName As String)
    Dim Glide As Amir_Glide
    Glide.Initializer.Default

    ' ###### ErrMsg: ~e:main_loadimage (java line: 614), java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting

    Glide.LoadWith.File(File.DirAssets, ImageName).Apply(Glide.RO.CenterCrop).Transition(Glide.TO.WithCrossFade).Into(Img)



End Sub

Has the lib possibly been used incorrectly?

A small testproject is attached below.
 

Attachments

  • testproject_glide_mustnotcallsettag.zip
    127.7 KB · Views: 306

fredo

Well-Known Member
Licensed User
Longtime User
I think ...
Thank you. That was the needed hint to overcome the error.​

... only a blank ...

This led to the realization that images of DirAsset can be accessed as follows:
B4X:
Glide.LoadWith.URI("file:///android_asset/" & ImageName)

B4X:
Sub arv_onBindViewHolder (Parent As Panel, Position As Int)
'    Log("#-Sub arv_onBindViewHolder, Position=" & Position)
    
    ' --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    ' This fills the item content from the Dataset
    ' corresponding to the position
    ' --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    Dim panBack As Panel = Parent.GetView(0)
    Dim Label1 As Label = panBack.GetView(0)
    Dim Label2 As Label = panBack.GetView(1)
    Dim ImageView1 As ImageView = panBack.GetView(2)
    
    Dim arvItemX As arvItem = DataSet.Get(Position)   
    Label1.Text = arvItemX.Title
    Label2.Text = arvItemX.Description

    ' Load image with Amir_Glide
    ImageView1.Tag = Null  ' needed!
    LoadImage(ImageView1, arvItemX.ImagePath)
    
    panBack.Height = Label1.Height +Label2.Height +(Label1.Top *2)     
    Parent.Height = panBack.Height +8dip
    
End Sub

Public Sub LoadImage (Img As ImageView, ImageName As String)
    Dim Glide As Amir_Glide
    Glide.Initializer.Default
    Glide.LoadWith.URI("file:///android_asset/" & ImageName).Apply(Glide.RO.CenterCrop).Into(Img)
End Sub

It now works as expected:


It is interesting to note that very fast scrolling has no bucking or delaying at all.

Nice Glide!​
 

Attachments

  • testproject_glide_simple.zip
    127.7 KB · Views: 353
Upvote 0

larprogramer

Member
Licensed User
why when i debug this it nothing?
 

Attachments

  • aaaasdd.PNG
    3.7 KB · Views: 308
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…