Hi all,
I'm implementing a sort using B4XOrderedMap By @Erel (https://www.b4x.com/android/forum/threads/b4x-b4xcollections-more-collections.101071/) and I trying to sort my ordered map using the .SortType method but I got an error:
Error occurred on line: 61 (B4XOrderedMap)
java.lang.NoSuchFieldException: No field created in class Lanywheresoftware/b4a/objects/collections/Map$MyMap; (declaration of 'anywheresoftware.b4a.objects.collections.Map$MyMap' appears in base.apk)
Note: "created" is a field that a putted within the ordered map values before call it.
Is it probably my mistake?
See the relevant code:
I'm implementing a sort using B4XOrderedMap By @Erel (https://www.b4x.com/android/forum/threads/b4x-b4xcollections-more-collections.101071/) and I trying to sort my ordered map using the .SortType method but I got an error:
Error occurred on line: 61 (B4XOrderedMap)
java.lang.NoSuchFieldException: No field created in class Lanywheresoftware/b4a/objects/collections/Map$MyMap; (declaration of 'anywheresoftware.b4a.objects.collections.Map$MyMap' appears in base.apk)
Note: "created" is a field that a putted within the ordered map values before call it.
Is it probably my mistake?
See the relevant code:
B4X:
'Class clsGlobals
Sub Class_Globals
Public FIELD_ART_CDATE As String = "created"
'......
end sub
Sub GetArtContent (nid As Int, aUser As String, aPsw As String) As ResumableSub
Try
'I got the putted values from a json parsing and all the values are putted and populated correctly
Dim field_image As List = JRoot.Get("field_image") '>>> img attachment is madatory so is always available
For Each colfield_image As Map In field_image
Private mapContent As Map
mapContent.Initialize
Dim target_id As Int = colfield_image.Get("target_id")
Dim alt As String = colfield_image.Get("alt")
Dim ArtImgtitle As String = colfield_image.Get("title")
Dim imgURL As String = colfield_image.Get("url")
Dim artNID As Int = nid
mapContent.Put (FIELD_ART_NID, artNID)
mapContent.Put (FIELD_ART_TITLE, ArtTitle)
mapContent.Put (FIELD_ART_BODY, ArtBody)
mapContent.Put (FIELD_ART_IMG_ID, target_id)
mapContent.Put (FIELD_ART_IMG_ALT, alt)
mapContent.Put(FIELD_ART_IMG_TITLE, ArtImgtitle)
mapContent.Put(FIELD_ART_IMAGE_URL, imgURL)
'download image
Wait For (DownloadImage(imgURL)) Complete (Image As Bitmap)
mapContent.Put (FIELD_ART_IMAGE, Image)
mapContent.Put (FIELD_ART_CDATE, CDate) 'creation date
mapArtIMGs.Put(target_id, mapContent)
Next
Log("")
Catch
'Log ...
End Try
Return mapArtIMGs
end sub
Sub imgNews_Click
Wait For (AppGlobals.GetArtsNIDs (AppGlobals.user, AppGlobals.psw)) Complete (ArtsNIDs As B4XOrderedMap)
For Each nid As Int In ArtsNIDs.Keys
Wait For (AppGlobals.GetArtContent (nid, AppGlobals.user, AppGlobals.psw)) Complete (ArtContent As B4XOrderedMap)
Next
ArtContent.Values.SortType (AppGlobals.FIELD_ART_CDATE, True)
end sub