B4A Library [Lib, Chargeable] Amir_RecyclerView

New b4a library! :)

RecyclerView, an important part of the sdk and android for making a custom list with better Layout , animation , and fixed for large data set.


Amir_RecyclerView released new version that we call it AX_RecyclerView.

version 1.0.8 is last update for Amir_RecyclerView and we will work on AX_RecyclerView only in future.


RecyclerView Android X : https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView

"RecyclerView is part of the v7 support library which means you can use it on anything that has api 7 and up"

543434345345.jpg



Advantages of using recyclerview instead listview:
  • ViewHolder Pattern
In a ListView, it was recommended to use the ViewHolder pattern but it was never a compulsion. In case of RecyclerView, this is mandatory using the RecyclerView.ViewHolder class. This is one of the major differences between the ListView and the RecyclerView.​

  • LayoutManager
This is another massive enhancement brought to the RecyclerView. In a ListView, the only type of view available is the vertical ListView. There is no official way to even implement a horizontal ListView.​
Now using a RecyclerView, we can have a:​
i) LinearLayoutManager - which supports both vertical and horizontal lists,​
ii) StaggeredLayoutManager - which supports Pinterest like staggered lists,​
iii) GridLayoutManager - which supports displaying grids as seen in Gallery apps.​
And the best thing is that we can do all these dynamically as we want.​

  • Item Animator
ListViews are lacking in support of good animations, but the RecyclerView brings a whole new dimension to it. Using the RecyclerView.ItemAnimator class, animating the views becomes so much easy and intuitive.​

  • Item Decoration
In case of ListViews, dynamically decorating items like adding borders or dividers was never easy. But in case of RecyclerView, the RecyclerView.ItemDecorator class gives huge control to the developers but makes things a bit more time consuming and complex.​

  • OnItemTouchListener
Intercepting item clicks on a ListView was simple, thanks to its AdapterView.OnItemClickListener interface. But the RecyclerView gives much more power and control to its developers by the RecyclerView. OnItemTouchListener but it complicates things a bit for the developer.​


For more info:
https://developer.android.com/reference/android/support/v7/widget/RecyclerView

You can add plugins as library and connect it to Amir_RecyclerView using a line of code

Current Plugins :
  • Amir_RVHeaderFooter
  • Amir_RVToolbarParallax
  • Amir_RVEmptyView
  • Amir_RVCardSlider
  • Amir_RVCarousel
  • Amir_RVDiscrete
  • Amir_RVExpandable
  • Amir_RVFanLayout
  • Amir_RVFeature
  • Amir_RVItemPicker ( deprecated )
  • Amir_RVLayoutAnimation
  • Amir_RVMultiSelection
  • Amir_RVParallax
  • Amir_RVRefreshLayout
  • Amir_RVShimmer
  • Amir_RVSkidRight
  • Amir_RVSwipeCards
  • Amir_RVVegaLayout
  • Amir_RVEchelon
  • Amir_WearableRecyclerView
  • Amir_RVDragItem
  • Amir_RVStickyHeader
  • AX_RecyclerViewPager ( deprecated )
  • Amir_RVAnimators
  • AX_RVSelection
  • AX_RVItemPicker
  • AX_RVPageIndicator
  • Amir_RVChipsLayoutManager
  • AX_RVSwipeLayout 1.00
  • AX_RVHeaderParallax
  • Amir_RVCardViewAdapter
  • Amir_RVExpandableStickyHeader
  • Amir_RVOverScroll
  • AX_RVFastScroller
  • AX_RVHeightStaggeredGrid
  • Amir_RVDragAndSwipe ( NEW )

Demo and samples how to use :

Download the DEMO.apk ( updated in 28th of July 2019 )
Download Demo Source Code

Extra Samples are here


Current version of Amir_RecyclerView : 1.2.0

Be sure to check the apk sample before purchasing.


You can have this fantastic library just with $25 ( only Amir_RecyclerView )
Full packages include all plugins only $35

Short documentations attached , special thanks to fredo

After your purchase please send me an email with your purchase detail ( alimanam@gmail.com )

 

Attachments

  • Amir_RecyclerView_FullPackage_1.0.2.LIBDOC.zip
    61.1 KB · Views: 908
Last edited:

Ashaz

Member
Licensed User

How to Use Amir_RecyclerViewPager in Designer.



i used in designer but no events calling.
like _onCreateViewHolder
_onBindViewHolder

plz. guide.
 

Ashaz

Member
Licensed User
How to Use Amir_RecyclerViewPager in Designer.


i used in designer but no events calling.
like _onCreateViewHolder
_onBindViewHolder

plz. guide.
Example attached. Not working in Design View. pls. guide.
 

Attachments

  • Amir_RecyclerView_Pager.zip
    3.2 KB · Views: 143

alimanam3386

Active Member
Licensed User
Example attached. Not working in Design View. pls. guide.

Why you didn't change name of RecyclerViewPager to Recycler like in your code? ( see your designer layout , the view name and event name should be exactly same like your code ) Recycler as view name and Amir as event name like your code. also you forgot to change color of recycler view page to black to see the lable you added in oncreate.
 

Attachments

  • Amir_RecyclerView2.zip
    9.4 KB · Views: 139

Ashaz

Member
Licensed User
Why you didn't change name of RecyclerViewPager to Recycler like in your code? ( see your designer layout , the view name and event name should be exactly same like your code ) Recycler as view name and Amir as event name like your code. also you forgot to change color of recycler view page to black to see the lable you added in oncreate.


Hellow, Alimanam,

in attached above exaple of Amir_RecyclerViewPager
how can i change page using timer.
not by slide (user).

Plz guide.

Txs.
 

alimanam3386

Active Member
Licensed User
Hellow, Alimanam,

in attached above exaple of Amir_RecyclerViewPager
how can i change page using timer.
not by slide (user).

Plz guide.

Txs.

B4X:
Private Sub timer_Tick
  If Recycler.CurrentPage = 4 Then Recycler.GoToPosition(0) Else Recycler.GoToNext(True)
End Sub
 

alimanam3386

Active Member
Licensed User
I am happy to say four new plugins of Amir_RecyclerView (AX_RecyclerView) have been released.

  1. Amir_RVExpandableStickyHeader
  2. Amir_RVOverScroll
  3. AX_RVFastScroller
  4. AX_RVHeightStaggeredGrid
Amir_RVExpandableStickyHeader :
this is a new plugin which let you use StickyHeader and ExpandableList together

Amir_RVOverScroll :
Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.

AX_RVFastScroller :
ReyclerView with fast scrolling and scroll popup.

AX_RVHeightStaggeredGrid :
A drop-in custom layout manager for Android RecyclerView to make a grid layout of photos while keep their aspect ratios.
just need to return the aspect ratio of your image at the given position (ImageWidth/ImageHeight)

If you set a negative aspect ratio, consider it As span the entire row view. It will force a line break And add the view To its own line ( Example: Return -(100%x/ViewHeight) )

rv2.jpg


You can create any view in the adapter. just need to build a RVBasicAdapter just like the sample
and you can add SpaceItemDecoration simply (Example: Layout.AddItemSpacing(4dip,RV) )
 
Last edited:

skaliwag

Member
Licensed User
There seem to be problems with the AX_RVFastScroll.
Both the Fast Scrollbar and the Scroll Popup are being drawn behind the items in the list.
For anything except a simple list they do not work correctly
 

Attachments

  • FastScroll_Problems.zip
    10 KB · Views: 90

Almora

Active Member
Licensed User
hi
I am using this code.
I have a picture source that is renewed every day.
The picture from the application is not renewed every day. shows when I first installed the application. not showing the new picture the next day. not renewed. still showing the old picture. keeps pictures in memory. not renewed.
what can I do..



B4X:
Sub Globals
    Dim Recycler As AX_RecyclerView
    Dim Text As Label
       
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("1")
   


    Recycler.Initializer("Amir").ListView.Build  
    Activity.AddView(Recycler,0,23%y,100%x,67%y)

    Dim Adapter As AX_RVAdapter
    Adapter.Initialize("Amir",Adapter.LOOP_NEVER)
   
    Recycler.Adapter=Adapter




End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Private Sub Amir_onCreateViewHolder (Parent As Panel,ViewType As Int)
    Dim Panel As Panel
    Panel.Initialize("")
    Parent.AddView(Panel,10dip,10dip,Parent.Width-20dip,135dip)

   
    Dim img As ImageView
   
    img.Initialize("")
    Panel.AddView(img,8dip,6dip,Panel.Width/3,Panel.Height - 10dip)

    Text.Initialize("")
    Panel.AddView(Text,Panel.Width/2 +10dip ,Panel.Height/2 - 10dip,(Panel.Width - (Panel.Width/3))-20dip,Panel.Height/2)
End Sub

Private Sub Amir_onBindViewHolder (Parent As Panel,Position As Int)
    Dim Panel As Panel = Parent.GetView(0)
    Dim ViewManager As Amir_ViewManager
    ViewManager.Initialize(Panel)
    ViewManager.BackgroundColor=Colors.RGB(211,211,211)
    ViewManager.BackgroundEnabledColor=Colors.RGB(211,211,211)
    ViewManager.Radius=0dip
    ViewManager.Start
    Panel.Elevation=2dip
    setClipToOutline(Panel)
   
    Dim img As ImageView = Panel.GetView(0)
    Dim  Text = Panel.GetView(1) As Label

    LoadImage(img,Position)
   

    Parent.Height=145dip
    'Parent.Width=100%x
End Sub

Private Sub Amir_GetItemCount As Int
    Return 2
End Sub

Public Sub setClipToOutline (Panel As Panel)
    Dim P As Phone
    If P.SdkVersion >= 21 Then
        Dim jo As JavaObject = Panel
        jo.RunMethod("setClipToOutline",Array(True))
    End If
End Sub


Private Sub LoadImage (Img As ImageView,Position As Int)
    Dim Glide As Amir_Glide
    Dim color2 As ColorDrawable
    color2.Initialize(Colors.DarkGray,0)
    Glide.RequestManager.SetDefaultRequestOptions(Glide.RO.ErrorDrawable(color2).Placeholder(color2).CenterCrop)
    Glide.Initializer.Default
   
   
    Select Case Position
        Case 0
            Glide.Load("https://xxxx-thumb1.jpg").Apply(Glide.RO.FitCenter).Into(Img)
        Case 1
            Glide.Load("https://yyyy-thumb2.jpg").Apply(Glide.RO.FitCenter).Into(Img)

    End Select
       
  
End Sub



  Private Sub Amir_onItemClick (Parent As Panel,Position As Int)
               
   End Sub
 
Last edited:

alimanam3386

Active Member
Licensed User
hi
I am using this code.
I have a picture source that is renewed every day.
The picture from the application is not renewed every day. shows when I first installed the application. not showing the new picture the next day. not renewed. still showing the old picture. keeps pictures in memory. not renewed.
what can I do..

Your question is NOT related to this lib. Please start a new thread and ask your question there.
 

alimanam3386

Active Member
Licensed User
There seem to be problems with the AX_RVFastScroll.
Both the Fast Scrollbar and the Scroll Popup are being drawn behind the items in the list.
For anything except a simple list they do not work correctly

It is NOT behind the items I try to fix alpha property.
 

Almora

Active Member
Licensed User
Your question is NOT related to this lib. Please start a new thread and ask your question there.

How do I clear the cache with Amir_Glide

how can i apply it.

###### I started a new topic.
 
Last edited:

alimanam3386

Active Member
Licensed User
Is it possible to drag items with pressing any part of view?

react-drag-listview.gif

Yes , please have a look at RVDragItem plugin sample in Main-RecyclerView---> Default Plugins samples

APK Sample

Source code :
B4X:
Sub Globals
    Dim Recycler As Amir_RecyclerView
    Dim Data As List
    Dim Drag As Amir_RVDragItem
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Recycler.Initializer("Amir").ListView.Build
    Activity.AddView(Recycler,0,0,100%x,100%y)


    Data.Initialize
    For i = 1 To 10
        Data.Add("Item : "&i)
    Next

    Drag.Initialize("Amir",Recycler)
    Drag.SetDataList(Data)
    Drag.SetNotifiMoveAdapter(True)

    Dim Adapter As Amir_RVAdapter
    Adapter.Initialize("Amir",Adapter.LOOP_NEVER)
    Adapter.Ripple.Color(Colors.LightGray).Build
    Recycler.Adapter=Adapter
    Recycler.Color=Colors.White
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub Amir_onCreateViewHolder (Parent As Panel,ViewType As Int)
    Dim Label As Label
    Label.Initialize("")
    Parent.AddView(Label,20dip,0,100%x-50dip,40dip)
End Sub

Private Sub Amir_onBindViewHolder (Parent As Panel,Position As Int)
    Dim Label As Label=Parent.GetView(0)
    Label.TextColor=Colors.Black
    Label.TextSize=20
    Label.Gravity=Bit.Or(Gravity.LEFT,Gravity.CENTER_VERTICAL)
    Label.Text=Data.Get(Position)
    Parent.Height=40dip
End Sub

Private Sub Amir_GetItemCount As Int
    Return Data.Size
End Sub

Private Sub Amir_onItemSelectedChanged (Item As Object,Position As Int,ActionState As Int)
    If Item<>Null Then
        Dim Parent As Panel = Recycler.Utils.GetParentFromItemObject(Recycler,Item)
        Dim Label As Label = Parent.GetView(0)
        If ActionState = Drag.ACTION_STATE_DRAG Then
            Label.TextColor=Colors.Red
        Else
            Label.TextColor=Colors.Black
        End If
    End If
End Sub
 

alimanam3386

Active Member
Licensed User
It not possible to replace Amir_onItemSelectedChanged to Label_LongClick like in gif?

No because RVDragItem plugin effect whole the content of item ( parent panel )

RVDragAndSwipe ( new plugin )

Demo

You can StartDrag with View clicks and disable default long press drag.
Based on this plugin RVDragItem and RVSwipeItem are deprecated
 

Attachments

  • RVDragAndSwipe.zip
    23.1 KB · Views: 80
Last edited:

sigster

Active Member
Licensed User
ok will start new new thread about Amir_RecyclerView and JdbcSQL
but I thought this was the right please to ask about Amir_RecyclerView :)
 
Top