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 ( [email protected] )

 

Attachments

  • Amir_RecyclerView_FullPackage_1.0.2.LIBDOC.zip
    61.1 KB · Views: 1,500
Last edited:

wimpie3

Well-Known Member
Licensed User
Longtime User
I have discovered a bug in the parallax code example (Amir_RecyclerView HeaderParallax). Modify the following code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Recycler.Initializer("Amir").ListView.Build
Activity.AddView(Recycler,0,0,100%x,100%y)
Recycler.DividerHorizontal.Color(Colors.black).Size(0.5dip).Build
The last line causes an issue when you scroll... a strange line is floating around on the screen!
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Next issue:

B4X:
onItemLongClick

also causes onItemClick to fire. I think you should be able to return true/false in the long click sub, but it's not a function...
 

evbedp

Member
Licensed User
Longtime User
i had a problem, i'm use recycler view for image slide when recycler onBind, position always in index 2... item count is 3. please help me
 
Last edited:

evbedp

Member
Licensed User
Longtime User
i had a problem, i'm use recycler view for image slide when recycler onBind, position always in index 2... item count is 3. please help me
finally i got the solution, i must create fake or empty image first in the contentlist. when image got the new resources, i'm just need to clear the contentlist and insert new resources to the contentlist. add source code recyclerview.adapter2.NotifDataSetChanged to refresh the view.
 

alimanam3386

Active Member
Licensed User
Longtime User
Hey @Amir i am unable to filter the items in recyclerview actually i am binding recyclerview with Objects and i am trying to filer the list with the itemname provided in searchbar but the data is not updating in ui altough i am calling notifyadapteer.Here is attached code

B4X:
Sub modifydata(query As String)
    If rcyclrItems.Adapter=Null Then Return
    rvdata.Clear
    If query.Length=0 Then
        rvdata.AddAll(ItemList)
    Else
       
        'iDetails.rvdata.AddAll(iDetails.rcyclrItems.Utils.FilterSearchList("",iDetails.ItemList).Trim.SkipLowerCase.StartsWith(query))
        For i=0 To ItemList.Size-1
            Dim iData As ItemData
            iData.Initialize
            iData=ItemList1.Get(i)
            If iData.itemname.StartsWith(query) Then
                rvdata.Add(iData)
            End If
        Next
        rcyclrItems.Utils.FilterSearchList("CustomType",rvdata)
        Log("SAize is"&rvdata.Size)
       
   
    End If
        callnotifier
End Sub
public Sub callnotifier
    rcyclrItems.Adapter2.NotifyDataSetChanged
End Sub
Here idata is a custom type object like this
Type ItemData (itemno As String, itemname As String,qty As String,amount As String,Price As String)

As you can see in the Filter Sample "Main-RecyclerView\ARV-Main\Basic Sample\FilterSearch" you need to add items (which return in FilterSearchList method) to your recyclerView data list.
this code should works :

B4X:
Sub modifydata(query As String)
    If rcyclrItems.Adapter=Null Then Return
    rvdata.Clear
    If query.Length=0 Then
        rvdata.AddAll(ItemList)
    Else
      
        rvdata.AddAll(rcyclrItems.Utils.FilterSearchList("itemname",ItemList).Trim.SkipLowerCase.StartsWith(query))
        Log("SAize is"&rvdata.Size)
      
    End If
        callnotifier
End Sub
 

alimanam3386

Active Member
Licensed User
Longtime User
Next issue:

B4X:
onItemLongClick

also causes onItemClick to fire. I think you should be able to return true/false in the long click sub, but it's not a function...

You are right, you can use reflection to add listeners :

next update I will fix it.

B4X:
Private Sub RV_onBindViewHolder (Parent As Panel,Position As Int)
  Parent.Tag = Position
  Dim r As Reflector
  r.Target = Parent
  r.SetOnLongClickListener("RV_LongClick")
End Sub
Private Sub RV_LongClick (tag As Object) As Boolean
  Log(tag)
  Return False
End Sub
 
Last edited:

alimanam3386

Active Member
Licensed User
Longtime User
I have discovered a bug in the parallax code example (Amir_RecyclerView HeaderParallax). Modify the following code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Recycler.Initializer("Amir").ListView.Build
Activity.AddView(Recycler,0,0,100%x,100%y)
Recycler.DividerHorizontal.Color(Colors.black).Size(0.5dip).Build
The last line causes an issue when you scroll... a strange line is floating around on the screen!

It is Not a bug , use this code :

B4X:
Recycler.Initializer("Amir").ListView.Build
  Activity.AddView(Recycler,0,0,100%x,100%y)
  Recycler.DividerHorizontal.Color(Colors.black).Size(0.5dip).VisibilityProvider("RV").Build

Sub RV_DividerVisibility (Position As Int) As Boolean
  If Position=0 Then Return True Else Return False
End Sub
 

wimpie3

Well-Known Member
Licensed User
Longtime User
I want to disable a finger scroll, and only let the user scroll with two buttons: "previous page" and "next page".

I've implemented this with recyclerView.LayoutFrozen=True. This disables the finger swipe.

When someone clicks on one of the buttons, I set LayoutFrozen to False, go to the next/previous page and freeze the layout again in the Sub recyclerView_onScrollStateChanged using
B4X:
If NewState=0 Then
    ' page scroll finished
    recyclerView.LayoutFrozen=True: ' disable scroll
End If

However, from time to time I get this error:
B4X:
java.lang.IllegalStateException: Do not setLayoutFrozen in layout or scroll

So my question is: am I overlooking something or is there another way to disable the finger scroll?
 

alimanam3386

Active Member
Licensed User
Longtime User
I want to disable a finger scroll, and only let the user scroll with two buttons: "previous page" and "next page".

I've implemented this with recyclerView.LayoutFrozen=True. This disables the finger swipe.

When someone clicks on one of the buttons, I set LayoutFrozen to False, go to the next/previous page and freeze the layout again in the Sub recyclerView_onScrollStateChanged using
B4X:
If NewState=0 Then
    ' page scroll finished
    recyclerView.LayoutFrozen=True: ' disable scroll
End If

However, from time to time I get this error:
B4X:
java.lang.IllegalStateException: Do not setLayoutFrozen in layout or scroll

So my question is: am I overlooking something or is there another way to disable the finger scroll?


With this following code you can disable RV touch
B4X:
RV.Listeners.AddOnItemTouchListener("RV")

Sub RV_onInterceptTouchEvent (Action As Int,X As Float,Y As Float,MotionEvent As Object) As Boolean 'Return true if you want disable touch
  Return True
End Sub


And If you want to disable only RV scroll , use this code (ViewHolder views are touchable)
B4X:
Sub RV_onInterceptTouchEvent (Action As Int,X As Float,Y As Float,MotionEvent As Object) As Boolean
  Dim jo As JavaObject = RV 
  jo.RunMethod("requestDisallowInterceptTouchEvent",Array(True))
  Return False
End Sub
 

Ashaz

Member
Licensed User
Amir_RecyclerView_GooglePlay_Demo

Powered Just with Amir_RecyclerView and B4A ! :)

Download the Demo

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"

View attachment 72645


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 ( new )
  • 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_RVViewPager
  • Amir_RVEchelon ( NEW )
  • Amir_WearableRecyclerView ( NEW )
  • Amir_RVDragItem
  • Amir_RVStickyHeader ( NEW )
  • Amir_RVAnimators ( NEW )
  • AX_RVSelection ( AndroidX )
  • AX_RVItemPicker ( AndroidX )
  • AX_RVPageIndicator ( New AndroidX )
  • Amir_RVChipsLayoutManager ( New )
  • AX_RVSwipeLayout 1.00 ( New AndroidX )
  • AX_RVHeaderParallax
  • Amir_RVCardViewAdapter

Demo and samples how to use :

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


Current version of Amir_RecyclerView : 1.1

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


Pay

After your purchase please send me an email with your purchase detail ( [email protected] )


i purchased amir recycleview.
now android play store sample gives below error.


--------------------
B4A Version: 9.50
Java Version: 8
Parsing code. (0.03s)
Building folders structure. (0.16s)
Compiling code. (0.05s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(Android Support Library)
Generating R file. (1.39s)
Compiling generated Java code. Error
javac 1.8.0_191
src\com\recyclerview\googleplaysample\itemrecyclerview.java:725: error: package androidx.recyclerview.widget does not exist
_rv.setObject((androidx.recyclerview.widget.RecyclerView)(group2.Get(index2)));}
^
Note: src\com\recyclerview\googleplaysample\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

--------------------
 

alimanam3386

Active Member
Licensed User
Longtime User
i purchased amir recycleview.
now android play store sample gives below error.


--------------------
B4A Version: 9.50
Java Version: 8
Parsing code. (0.03s)
Building folders structure. (0.16s)
Compiling code. (0.05s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(Android Support Library)
Generating R file. (1.39s)
Compiling generated Java code. Error
javac 1.8.0_191
src\com\recyclerview\googleplaysample\itemrecyclerview.java:725: error: package androidx.recyclerview.widget does not exist
_rv.setObject((androidx.recyclerview.widget.RecyclerView)(group2.Get(index2)));}
^
Note: src\com\recyclerview\googleplaysample\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

--------------------

Please update your sdk to androidX ( by sdk manager )

 
Last edited:

Ashaz

Member
Licensed User
i updated , ,now getting below error .

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. Error
h:\mohib\setups\b4a\android sdk\android-sdk\tools\..\extras\b4a_remote\androidx\core\core\1.2.0\unpacked-core-1.2.0\res\values\values.xml:163: error: Attribute "fontVariationSettings" has already been defined

Plz. guide.
 

alimanam3386

Active Member
Licensed User
Longtime User
i updated , ,now getting below error .

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. Error
h:\mohib\setups\b4a\android sdk\android-sdk\tools\..\extras\b4a_remote\androidx\core\core\1.2.0\unpacked-core-1.2.0\res\values\values.xml:163: error: Attribute "fontVariationSettings" has already been defined

Plz. guide.

it looks like a problem with sdk file try to change targetSdkVersion to 28 and try again. if the problem still not solved try to search in forum.
 

asales

Expert
Licensed User
Longtime User
Error
h:\mohib\setups\b4a\android sdk\android-sdk\tools\..\extras\b4a_remote\androidx\core\core\1.2.0\unpacked-core-1.2.0\res\values\values.xml:163: error: Attribute "fontVariationSettings" has already been defined
You can see the same error here:
 

Ashaz

Member
Licensed User
You can see the same error here:


its solved. but now getting below error.

Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.00s)
Compiling generated Java code. Error
B4A line: 185
Activity.AddView(RecyclerView,0,0,100%x,100%y)
javac 1.8.0_191
src\com\recyclerview\googleplaysample\main.java:441: error: cannot access RecyclerView
mostCurrent._activity.AddView((android.view.View)(mostCurrent._vvvvvvvvvv5.getObject()),(int) (0),(int) (0),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (100),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (100),mostCurrent.activityBA));
^
class file for android.support.v7.widget.RecyclerView not found
 

asales

Expert
Licensed User
Longtime User
Did you jetified the library?
Search to "RecyclerView" in the forum to get similar thread and a possible answer to your issue.
 
Top