B4A Library [Lib, Chargeable] Amir_RecyclerView

wimpie3

Well-Known Member
Licensed User
Longtime User
Thank you for correcting the bugs! There is now a big need for a decent manual I guess. Several properties are not documented. Like the "Adjusted" property. And what is the difference between DoScroll and ScrollToPosition...? I know we can follow the examples but I'd like to know what I'm doing
 

itgirl

Active Member
Licensed User
Longtime User
There is a strange bug try to change the locale to any RTL locale like Hebrew or Arabic and enable LinearSnapHelper2 the snapper will keep scrolling till the beginning of the list
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Is it possible to use the Amir_animation library to animate TO a certain x,y location? That seems to be missing currently.
 

alimanam3386

Active Member
Licensed User
Longtime User
There is a strange bug try to change the locale to any RTL locale like Hebrew or Arabic and enable LinearSnapHelper2 the snapper will keep scrolling till the beginning of the list

It's not bug , use LinearSnapHelper instead of LinearSnapHelper2 for RTL layouts.
 

alimanam3386

Active Member
Licensed User
Longtime User

the main difference between doScroll and ScrollToPosition is when you use doScroll to navigate between pages you should declare the Adjusted property.
 

itgirl

Active Member
Licensed User
Longtime User
It's not bug , use LinearSnapHelper instead of LinearSnapHelper2 for RTL layouts.
Yeah i kinda figure that out , because first i used LinearSnapHelper2 with gravity but didn't work so i went back to LinearSnapHelper and it worked, Thanks for your replies for the bugs and also for you effort
 

wimpie3

Well-Known Member
Licensed User
Longtime User
In the Amir_RecycleView example you show a horizontal pageviewer. This works fine. However, I'd like to detect when someone is moving their finger UP or DOWN over the control (while keeping the LEFT/RIGHT slide for the pageviewer). I'm not able to do that using for instance GestureDetector. Any idea where I should be looking?
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Also: is it possible to expose onGetChildDrawingOrder? When I want to change the z-order of views inside the RecycleView using bringtofront/sendtoback, the RecycleView gets messed up. This can be solved by using onGetChildDrawingOrder but that function is not available.
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Another bug. Run the following program. At the start the recycleviewer scrolls to Item 2. When you push the red button the recycler scrolls to Item 1 (perfect). But the debug log shows that the view on the first visible position is Item 0, and not Item 1. I suspect some problem with "measuring" which panel is visible, since when you modify the source code below and put Parent.Width=100%x+1 instead of Parent.Width=100%x, it works as expected.

B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName: 
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
End Sub

Sub Globals
    Dim recycler As Amir_RecyclerView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    recycler.Initializer("Amir").ListView.Horizontal.Build
    Activity.AddView(recycler,0,0,100%x,100%y)
    recycler.ScrollingTouchSlop=recycler.TOUCH_SLOP_PAGING
    recycler.LinearSnapHelper
    recycler.Adapter=recycler.DefaultAdapter
    Dim b As Button
    b.Initialize("b")
    b.Color=Colors.red
    Activity.AddView(b,0,100dip,300dip,100dip)
    recycler.ScrollToPosition(2)
End Sub

Sub b_Click
    recycler.SmoothScrollToPosition(1)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub Amir_onCreateViewHolder (Parent As Panel,ViewType As Int)
    Dim panel As Panel
    panel.Initialize("")
    Parent.AddView(panel,0,0,Parent.Width,50dip)
    Dim label As Label
    label.Initialize("")
    panel.AddView(label,0,0,panel.Width,panel.Height)
End Sub

Sub Amir_onBindViewHolder (Parent As Panel,Position As Int)
    Dim panel As Panel=Parent.GetView(0)
    Dim label As Label=panel.GetView(0)
    label.Text="Item " & Position
    label.Color=Colors.black
    Parent.Width=100%x
    Parent.Height=70dip
End Sub

Sub Amir_onScrollStateChanged (NewState As Int)
    If NewState = 0 Then
        Dim p As Panel=recycler.Utils.ViewIndexToItemObject(recycler,0)
        Dim p2 As Panel=p.GetView(0)
        Dim l As Label=p2.GetView(0)
        Log(l.text)
    End If
End Sub

Sub Amir_GetItemCount As Int
    Return 200
End Sub
 

evbedp

Member
Licensed User
Longtime User
it's possible change from GRID to ListView in same time?

as you know ecommerce application have menu to change product display from grid to listview.
 

Carlos marin

Active Member
Licensed User
Longtime User
hi dear I have a concern, I use VisibleRangeChanged erel
since in the app I have a very heavy load images from a server in some cases the custom is loaded with more than 100 to 500 items with images, Can this library support this load? you can call images of the internet to load the items is something like that.
 

Attachments

  • WhatsApp Image 2019-03-04 at 1.30.38 PM.jpg
    146 KB · Views: 242

itgirl

Active Member
Licensed User
Longtime User
You should NEVER load 100-500 images at the same time, from a memory consumption view RecyclerView will definitely help having 100-500 items even much much more but that's only for Views and views life cycle. of course for downloading images you can always rely on glide which this lib use and it will 100% be much more easier to handle all the memory and cache problems, to sum it up your problem is not about the kind of lib you use it's about the way you do it and downloading 500 images is never a good way
Try to show only 20 items [lazy loading] no need to wait for the end of scroll maybe when user scroll reach 10 load another 20 and so on, this way even the user will not notice the download happening.
 
Last edited:

evbedp

Member
Licensed User
Longtime User
It's already implemented.
Look into his example code in ".\Extra Samples\ARV_Demo_Source_Code\RVA_RefreshLayout.bas"

"Pull to refresh"
View attachment 78041
or

"Click to refresh"
View attachment 78040

not this feature,

i want to show progress bar at bottom Recycler View, like load more data not for refresh screen.
when bottom progress bar show it will request to generate more other products.
 

itgirl

Active Member
Licensed User
Longtime User
not this feature,

i want to show progress bar at bottom Recycler View, like load more data not for refresh screen.
when bottom progress bar show it will request to generate more other products.
Also the refresh from bottom is implemented
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Anyone else getting the following error when using RVItemPicker?
B4X:
java.lang.IndexOutOfBoundsException: Invalid item position 0(0). Item count:0 com.aghajari.rv.RecyclerView{34a816ce VFED.... ......I. 0,0-0,0}, adapter:com.aghajari.rvplugins.Amir_RVItemPicker$Amir_RVItemPickerAdapter@13d8a9ef, layout:com.aghajari.rvplugins.PickerLayoutManager@14e15cfc, context:android.app.Application@35318f85
 

itgirl

Active Member
Licensed User
Longtime User
From the example?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…