Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim wb As WebView, wx As WebViewXtender, wbx As WebViewExtras
Dim GD As GestureDetector
End Sub
Sub Activity_Create(FirstTime As Boolean)
GD.SetOnGestureListener(wb,"Gesture")
GD.EnableLongPress(False)
End Sub
Sub Gesture_onScroll(distanceX As Float, distanceY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
If Abs(distanceY)>Abs(distanceX) Then
Dim newpos, wlength As Int
newpos=wx.getScrolly(wb)+distanceY
If newpos<0 Then
newpos=0
Else
wlength=wbx.GetContentHeight(wb) * wbx.GetScale(wb)
If newpos>wlength Then newpos=wlength
End If
wx.scrollTo(wb,0,newpos)
End If
End Sub
Sub Gesture_onFling(velocityX As Float, velocityY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
Dim x1,y1,x2,y2 As Float
Dim xd,yd As Double
x1=GD.getX(MotionEvent1)
y1=GD.getY(MotionEvent1)
x2=GD.getX(MotionEvent2)
y2=GD.getY(MotionEvent2)
xd=Abs(x2-x1)
yd=Abs(y2-y1)
If xd>yd AND Abs(velocityX)>Abs(velocityY) Then
Activity.Finish
Else
wbx.flingScroll(wb,-velocityX,-velocityY)
End If
End Sub
Sub Gesture_onScroll(distanceX As Float, distanceY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
If Abs(distanceY)>Abs(distanceX) Then
Dim newpos, wlength As Int
newpos=wx.getScrolly(wb)+distanceY
If newpos<0 Then
newpos=0
Else
wlength=wbx.GetContentHeight(wb) * wbx.GetScale(wb)
If newpos>wlength Then newpos=wlength
End If
wx.scrollTo(wb,0,newpos)
End If
End Sub