Android Question How to implement image in Grid by Amir_RecyclerView and Amir_Glid

Schakalaka

Active Member
Licensed User
Longtime User
Hello, again.
I tried every possible way for for display images in grid view ((start from Amir_RVLayoutAnimation grid layout) with no luck.
In another sample you use sub load image and a "Secect case". but this is not for me because i load images from json job, and the number of images for loading change.


B4X:
    Dim j As HttpJob
    j.Initialize("",Me)
    j.Download( http://eliteandroidapp.netsons.org/php_web_services/api.php?cat_list  )
    ProgressDialogShow2("Downloading...:", False)
    Wait for (j) jobdone (j As HttpJob)
    If j.Success Then
        Log(j.GetString)
        Dim parser As JSONParser
        parser.Initialize(j.Getstring)
        Dim root As Map = parser.NextObject
        Dim HD_WALLPAPER As List = root.Get("HD_WALLPAPER")
        For Each colHD_WALLPAPER As Map In HD_WALLPAPER
            Dim category_total_wall As String = colHD_WALLPAPER.Get("category_total_wall")
            Dim category_image As String = colHD_WALLPAPER.Get("category_image")
            Dim category_name As String = colHD_WALLPAPER.Get("category_name")
            Dim category_image_thumb As String = colHD_WALLPAPER.Get("category_image_thumb")
            Dim cid As String = colHD_WALLPAPER.Get("cid")

        Next

    Else
        Log("Error: " & j.ErrorMessage)
   
    End If
    j.Release
    ProgressDialogHide

i have try to create a imageview in the front of panel, and load here the image

in Amir_onCreateViewHolder
B4X:
    Dim img As ImageView
    img.Initialize("")
    pnl.AddView(img,4dip,4dip,pnl.Width,pnl.Height)
    Parent.Height=(100%x/Recycler.LayoutSpanCount)+8dip

in Amir_onBindViewHolder

B4X:
        Dim pnl As Panel = Parent.GetView(0)
    Dim img As ImageView = pnl.GetView(0)
Parent.Height=(100%x/Recycler.LayoutSpanCount)+8dip

Transformation _
        .FitCenter _
    .CircleCrop _

    Dim Link As String = "placeholder_cat.png" 'Don't Forgot to Add Link that should be like "category_name" or"category_image_thumb"
    Glide.Load(link,(100%x/Recycler.LayoutSpanCount)-8dip,100%x/Recycler.LayoutSpanCount,True)).Apply(Glide.RO.Transform(Transformation)).Into(img)

Aspected result (there aren' t simple bottoms) img1;
sample example without lib:
B4X:
https://drive.google.com/file/d/11Vv0NUzggNP4WavX1c_sqsRtIlA8hl2W/view?usp=sharing

somebody that have buy it, explain me how to do it
Thanks you
 

Attachments

  • 58662305_2818830961466130_8228769555128778752_n.jpg
    58662305_2818830961466130_8228769555128778752_n.jpg
    58 KB · Views: 486
Last edited:

Schakalaka

Active Member
Licensed User
Longtime User
yes, it is perfect.
now, i have try to add a local image, if there are no internet connection, for example.

B4X:
glid.As.Bitmap.LoadURL(itm.link).Apply(glid.RO.ErrorDrawable(LoadBitmap(File.DirAssets,"appMobi_icon_live_update.png")).Apply(glid.RO.CircleCrop)).Into(img)

o_O

Other Step:
i have try to add load more, if items are more that 12.
i have add the timer :
B4X:
Dim loadmoreTimer As Timer

and
B4X:
Private Sub Amir_onScrolledToEnd
   
    If loadmoreTimer.IsInitialized=False Then _
    loadmoreTimer.Initialize("loadmoreTimer",1000)
    If loadmoreTimer.Enabled=False Then _
        loadmoreTimer.Enabled=True
End Sub
Private Sub loadmoreTimer_Tick
    loadmoreTimer.Enabled=False
   
    ItemCount=ItemCount+1
    RV.Adapter2.NotifyItemInserted(ItemCount-11)
    If ItemCount = Addapter.Size Then _
        RV.ScrollToEndListener(False)
End Sub

removin the sub load footer and header..
But it haven 't the load more effect..
Help?
 
Last edited:
Upvote 0
Top