B4A Library Gestures (multi-touch) library

This library allows a View to detect multi-touch gestures. Note that the demo does nothing on the device but logs the multiple touches to LogCat so you will need to be connected to the IDE and viewing filtered LogCat output to see the results of the demo.

The quality of multi-touch support appears variable across devices. Erel reports that this library works fine on his Nexus but my Orange San Francisco (ZTE Blade) is pretty rubbish at tracking pointers as you can see from the comments in the library. You get what you pay for I guess!

EDIT :- Version 1.1 posted. See post #18 for details.

EDIT :- Version 1.2 posted. See post #26 for details.
 

Attachments

  • Gestures1.2.zip
    10.4 KB · Views: 5,373
Last edited:

Informatix

Expert
Licensed User
Longtime 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
Longtime 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
Longtime 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?
 

tecevit

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

Turbo3

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