Android Question CLVSwipe + Horizontal ListView Problem

Luke3012

Member
Licensed User
Hi, I have a problem with the CLVSwipe library.
I decided to use it for the pull to refresh feature, but as long as i initialize it I can't swipe with a horizontal custom listview that is put inside the custom listview where CLVSwipe has been initialized.
Is possible to disable the horizontal swipe detection to make it work? I still want to use this Library for the useful Pull to Refresh feature.

Here is an Example. (In this case I'm using AHViewPager but it's also the same with a horizontal Custom Listview)

B4X:
ub Process_Globals
    Private xui As XUI
End Sub

Sub Globals
    Private CLV As CustomListView
    Private Swipe As CLVSwipe
    Private VP As AHViewPager
    Private PC As AHPageContainer
    Private Panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
   
    'Initialize CLVSwipe
    Swipe.Initialize(CLV, Me, "Swipe")
    Dim PullToRefreshPanel As B4XView = xui.CreatePanel("")
    PullToRefreshPanel.SetLayoutAnimated(0, 0, 0, 100%x, 70dip)
    PullToRefreshPanel.LoadLayout("PullToRefresh")
    Swipe.PullToRefreshPanel = PullToRefreshPanel
    'Comment this code to make panelx sliding work!
   
    'Add the Panel to CLV
    Panel1.RemoveView
    CLV.Add(Panel1, "")
   
    'Add some Panels to AHViewPager
    PC.Initialize
   
    Dim panelx(3) As Panel
    panelx(0).Initialize("")
    panelx(1).Initialize("")
    panelx(2).Initialize("")
    panelx(0).Color = Colors.Green
    panelx(1).Color = Colors.White
    panelx(2).Color = Colors.Red
   
    PC.AddPage(panelx(0), "Green")
    PC.AddPage(panelx(1), "White")
    PC.AddPage(panelx(2), "Red")
   
    VP.PageContainer = PC
   
    'Try to slide, it will not work
    'If you don't initialize CLVSwipe, works!
End Sub
Here I also upload a small project.
Thank you for any help.
 

Attachments

Luke3012

Member
Licensed User
OK... problem solved.
Here's the solution, just change HandlingEvent's value to False when dy < 20dip and dx > 10dip

This is the part of the code to look at

B4X:
Private Sub TouchPanel_OnInterceptTouchEvent (Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
    If HandlingSwipe Or WaitingForRefreshToComplete Then Return True
    Select Action
        Case Base.TOUCH_ACTION_DOWN
            TouchXStart = X
            TouchYStart = Y
            HandlingSwipe = False
        Case Base.TOUCH_ACTION_MOVE
            Dim dx As Float = Abs(x - TouchXStart)
            Dim dy As Float = Abs(y - TouchYStart)
            If mPullToRefreshPanel.IsInitialized And mCLV.sv.ScrollViewOffsetY = 0 And y - TouchYStart > 3dip Then
                HandlingSwipe = True
                PullToRefreshSwipe = True
                mPullToRefreshPanel.Visible = True
                CloseLastSwiped
            Else If dy < 20dip And dx > 10dip And mCLV.Size > 0 Then
                If HandlingSwipe = False Then
                    Dim NewSwipeItem As Int = mCLV.FindIndexFromOffset(TouchYStart + mCLV.sv.ScrollViewOffsetY)
                    If NewSwipeItem <> LastSwipedItem Then CloseLastSwiped
                    LastSwipedItem = NewSwipeItem
                End If
             
                'Here HandlingSwipe before was set to True
                HandlingSwipe = False
                PullToRefreshSwipe = False
            End If
    End Select
    Return HandlingSwipe
End Sub
 
Top