FreeformGestureDetector

General

Category
Free
Tag
Gestures
License
MIT License
Min SDK
19 (Android 4.4 KitKat)
Registered
May 15, 2018
Favorites
1
Link
https://github.com/Kalabasa/FreeformGestureDetector/
See also
Flick
Gesture
PeekAndPop
Hauler
NewHandwave

Additional

Language
Java
Version
1.0.0 (Feb 6, 2018)
Created
Feb 5, 2018
Updated
Oct 26, 2020 (Retired)
Owner
Lean Rada (Kalabasa)
Contributor
Lean Rada (Kalabasa)
1
Activity
Badge
Generate
Download
Source code

FreeformGestureDetector

Multi-touch transform gesture detector for Android.

Sample

sample repo

Usage

The FreeformGestureDetector class acts like a regular gesture detector. It receives a stream of MotionEvents and outputs a stream of transformation matrices.

Create an instance for your View. The callback implements FreeformGestureDetector.OnGestureListener.

FreeformGestureDetector freeformGestureDetector = new FreeformGestureDetector(getContext(), callback);

In the View's touch event handler, unconditionally call freeformGestureDetector.onTouchEvent(MotionEvent).

@Override
public boolean onTouch(View v, MotionEvent e) {
 freeformGestureDetector.onTouchEvent(e);
 // ...
}

The callback will be executed for each resulting transform event. The transformation is based on touch movements.

The transform parameter contains the accumulated transformation since the last call that the callback has returned true (Similar behavior as ScaleGestureDetector).

@Override
public boolean onTransform(MotionEvent ev, Matrix transform) {
 // Handle transform events here
 myMatrix.postConcat(transform);
 return true;
}

Installation

Add JitPack to your root build.gradle's repositories.

allprojects {
 repositories {
  ...
  maven { url 'https://jitpack.io' }
 }
}

In your app's build.gradle dependencies:

dependencies {
 implementation 'com.github.Kalabasa:FreeformGestureDetector:1.0.0'
}

You can check the latest version in the Releases tab.

License

MIT.

See LICENSE file