B4A Library Gestures (multi-touch) library

Informatix

Expert
Licensed User
Hello,
I loved this library, thank you.:sign0098:
I need a rotate method to rotate the views. Is it possible to implement via gestures>
I don't think you can rotate a view and still continue to use it. Otherwise, you can take a screenshot of the view and rotate the screenshot. To get it:
B4X:
Sub ViewToBmp(MyView As View) As Bitmap
    ' Returns a screenshot of the given view
    Dim bmp As Bitmap
    bmp.InitializeMutable(MyView.Width, MyView.Height)
    C.Initialize2(bmp)

    Dim r1 As Reflector
    r1.Target = C
    r1.Target = r1.GetField("canvas")

    Dim r2 As Reflector
    Dim args(1) As Object
    Dim types(1) As String
    args(0) = r1.Target
    types(0) = "android.graphics.Canvas"
    r2.Target = MyView
    r2.RunMethod4("draw", args, types) ' "Draw" renders a view and its children to the given Canvas

    Return C.Bitmap
End Sub
 

korshkov

Member
Licensed User
use library on widget

Hello!
How can use this library for detecting double tap in widget?
It's possible?
Thanks!
:sign0104:
 

korshkov

Member
Licensed User
...or this library: Gesture Detector.
Thanks Informatix for support, only then Initializing library need declare activity
B4X:
GD.SetOnGestureListener(Activity, "Gesture")
Widget is service module and not have activity...
Or i not understand your hint?
 

Informatix

Expert
Licensed User
Thanks Informatix for support, only then Initializing library need declare activity
B4X:
GD.SetOnGestureListener(Activity, "Gesture")
Widget is service module and not have activity...
Or i not understand your hint?
The first parameter is a view (panel, activity, edittext, label, button, etc.)
 

tecevit

Member
Licensed User
Hi,
Is there a way to release/reset/undo the listener ?

Each time i use one of the following routines, it slows down increasingly..


Sub CpuIle_Click
oyuncesidi = 3 ' CPUVSPLAYER
Gestures1.SetOnTouchListener(Panel1, "GtCPUVSPLAYER")
End Sub

Sub AyniMakina_Click
oyuncesidi = 2 ' PLAYERVSPLAYER
Gestures1.SetOnTouchListener(Panel1, "GtPLAYERVSPLAYER")
End Sub

Sub CpuCpu_Click
oyuncesidi = 1 ' cpuvscpu
Gestures1.SetOnTouchListener(Panel1, "GtCPUVSCPU")
End Sub

My guess is : a new listener is added each time..
 

Turbo3

Active Member
Licensed User
First time user. Trying to compile PinchZoomAndMove example. Getting the following complie error using Gestures v1.20 and PinchZoomAndMove v1.44. What am I doing wrong?

B4X:
Parsing code.                           0.04
Compiling code.                         0.10
Compiling layouts code.                 0.01
Generating R file.                      0.21
Compiling generated Java code.          1.85
Convert byte code - optimized dex.      Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Ldominex/example/pinchzoomandmove$_layoutdata;
   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
   at com.android.dx.command.dexer.Main.processClass(Main.java:490)
   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
   at com.android.dx.command.dexer.Main.processOne(Main.java:422)
   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
   at com.android.dx.command.dexer.Main.run(Main.java:209)
   at com.android.dx.command.dexer.Main.main(Main.java:174)
   at com.android.dx.command.Main.main(Main.java:91)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Ldominex/example/pinchzoomandmove$_touchdata;
   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
   at com.android.dx.command.dexer.Main.processClass(Main.java:490)
   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
   at com.android.dx.command.dexer.Main.processOne(Main.java:422)
   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
   at com.android.dx.command.dexer.Main.run(Main.java:209)
   at com.android.dx.command.dexer.Main.main(Main.java:174)
   at com.android.dx.command.Main.main(Main.java:91)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Ldominex/example/pinchzoomandmove;
   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
   at com.android.dx.command.dexer.Main.processClass(Main.java:490)
   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
   at com.android.dx.command.dexer.Main.processOne(Main.java:422)
   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
   at com.android.dx.command.dexer.Main.run(Main.java:209)
   at com.android.dx.command.dexer.Main.main(Main.java:174)
   at com.android.dx.command.Main.main(Main.java:91)
3 errors; aborting
   Optimized dexer failed. Switching to Standard dexer.
 

kiki78

Active Member
Licensed User
Hello,

I have class that simply get panel to draw when initializes from Activity.
I expect to add gesture management inside my class.
May I, and if yes how to, receive events inside my class ?

Regards
 

Rick Harris

Well-Known Member
Licensed User
Hi,
yes I did - I changed the gesture event handler code to

Sub pnl_gesture(o As Object, ptrID As Int, action As Int, x As Float, y As Float) As Boolean
Dim canv As Canvas
canv.Initialize(Activity)
Dim ix, iy As Int
canv.DrawColor(Colors.Black)
Dim xx, yy As Float : xx = -1
For i = 0 To g.GetPointerCount-1
id = g.GetPointerID(i)
ix = g.GetX(id)
iy = g.GetY(id)

canv.DrawCircle(ix, iy, 60, Colors.Red, False, 2)
If xx <> -1 Then canv.DrawLine(xx, yy, ix, iy, Colors.Blue, 1)
xx = ix
yy = iy
Next
If action = g.ACTION_UP Then canv.DrawColor(Colors.Black)
Return True ' need to return true otherwise we don't get any other events in the gesture
End Sub


So, there is no log being generated etc, only drawing (Also, i removed the panel and changed the listener code to g.SetOnTouchListener(Activity, "pnl_gesture")) ...

Any ideas - maybe my drawing code can do with some changes ;-)
Your example is working just fine! Just a small comment: The second line in this sub should be

canv.Initialize(pnl)
 

Turbo3

Active Member
Licensed User
I recently added the Gestures library to my app to support zoom on a couple of screens. However, my users are experiencing a dramatic slowdown in my app.

Is there a way to disconnect the listener when not needed so I can avoid this slowdown. It even affects my service routine performance which is handling the Bluetooth serial link.

What I need is a release or reset function to get the listener out of the picture when not needed.

Why does the Gestures library have this behavior? Are you constantly running code to sample for screen touches taking away a large number of cycles from my app's code?

======================================================
UPDATE:
Located source of app slowdown and it was NOT caused by the Gestures library.

A graph routine with many points was being refreshed at a rate faster than the Kyocera Event phone could handle while also handling the Service module handling the Bluetooth link.

This is good news as I really liked the gestures features available with this library.
 
Last edited:
Top