B4A Library [Lib, Chargeable] Amir_RecyclerView

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: 418

alimanam3386

Active Member
Licensed User
Longtime 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: 394

Ashaz

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.
 

alimanam3386

Active Member
Licensed User
Longtime 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
Longtime 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) )



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
Longtime 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: 324

Almora

Well-Known Member
Licensed User
Longtime 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
Longtime User

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

alimanam3386

Active Member
Licensed User
Longtime 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

Well-Known Member
Licensed User
Longtime 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
Longtime User
Is it possible to drag items with pressing any part of view?


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
 

Ilya G.

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

alimanam3386

Active Member
Licensed User
Longtime 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: 299
Last edited:

sigster

Active Member
Licensed User
Longtime 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
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…