Git Product home page Git Product logo

android-gesture-detectors's People

Contributors

alexvasilkov avatar almeros avatar bgardella avatar matteblair avatar rharter avatar robpvn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-gesture-detectors's Issues

FloatMath.sqrt has been removed from Android SDK 23

The deprecated class has been removed.

"Historically these methods were faster than the equivalent double-based Math methods. On versions of Android with a JIT they became slower and have since been re-implemented to wrap calls to Math. Math should be used in preference.
All methods were removed from the public API in version 23."

http://developer.android.com/reference/android/util/FloatMath.html

The library now needs to use eg. (float) Math.sqrt(pvx_pvx + pvy_pvy);

Rotation Gesture Detector Only works with Single ImageView.

If I created Two ImageView instances in Single Activity and Attach Separate Instances of Rotation Gesture Detector to them the Only Rotation Listener for First ImageView Is Working Second Image's Rotation Gestures are not being able to detect .Please provide some solution to that its been 8 hours I am searching for solution.

Thanks.

TextView GestureListener

I'm struggling a bit to get this to work as expected with a dynamically created TextView (or any View other than the ImageView). For the 'move' detector, the TextView appears to be 'lagging' behind my finger. Two finger gestures cause the view to 'split' in two until I let go of one of the fingers.

Any help on figuring this out would be much appreciated. (I've also tried using Matrix transformations with the TextView by overriding OnDraw, but had little luck with that as well).

Here's the modification from the Sample (View instantiation not shown):

public boolean onTouch(View v, MotionEvent event)
    {
        mScaleDetector.onTouchEvent(event);
        mRotateDetector.onTouchEvent(event);
        mMoveDetector.onTouchEvent(event);
        mShoveDetector.onTouchEvent(event);

        float scaledViewCenterX = (_originalWidth * mScaleFactor)/2;
        float scaledViewCenterY = (_originalHeight * mScaleFactor) /2;

        // also attempted to translate with the difference to no avail
        //float diffX = mFocusX - scaledViewCenterX;
        //float diffY = mFocusY - scaledViewCenterY;
        //v.setTranslationX(diffX*mScaleFactor);
        //v.setTranslationY(diffY*mScaleFactor);

        // Scale : Splits view in two. Jitters
        v.setScaleX(mScaleFactor);
        v.setScaleY(mScaleFactor);

        // Translate : Lags behind finger. Jitters
        v.setX(mFocusX);
        v.setY(mFocusY);

        // Set pivot joint
        v.setPivotX(scaledViewCenterX);
        v.setPivotY(scaledViewCenterY);

        // Rotate : Splits view in two. Jitters
        v.setRotation(mRotationDegrees);
}

RotateGestureDetector getRotationDegreesDelta returns values close to 360 on small angle change

Performing minuscule rotations while having rotation line between fingers horizontal causes to getRotationDegreesDelta to output values close to 360, e.g. -359.4 or 359.2.

This is caused by Math.atan2 used to calculate diff angle having ambiguity around +-180*. All is fine and well when performed rotation is shown 1:1 on screen, but I'm scaling it to get more precise moment with small values, so when the received values are 0.015, 0.020, 0.017, -359.4, 0.021... it causes a sudden jerk.

IMO it's a bug because nobody expects sudden 360 for minuscule finger motion when calling getRotationDegreesDelta. The real change of angle is certainly NOT a 360 degree.

My workaround was:

val raw = detector.rotationDegreesDelta
val diffRotation = if (abs(raw) > 300) {   // or some other arbitrary value above 180*
    if (raw < 0) {
        360 + raw
    } else {
        raw - 360
    }
} else raw

I think better fix (without arbitrary 300* value) can be done on library side by checking if one angle falls close to 180* and other close to -180*, so it's passing through discontinous part of Math.atan2 and can be accounted for.

Two-finger pinch-zoom about the center of the two pointers

This gesture detector example is very helpful, but it appears to always zoom relative to the center of the image, which may be well outside the currently displayed area. Would it be possible to zoom about the center of the two touch positions instead? If so, how? Thanks.

TwoFingerGestureDetector : IllegalArgumentException: pointerIndex out of range

We are getting this crash in the TwoFingerGestureDetector.

Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
       at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
       at android.view.MotionEvent.getX(MotionEvent.java:2379)
       at com.almeros.android.multitouch.TwoFingerGestureDetector.updateStateByEvent(TwoFingerGestureDetector.java:77)
       at com.almeros.android.multitouch.RotateGestureDetector.handleInProgressEvent(RotateGestureDetector.java:136)
       at com.almeros.android.multitouch.BaseGestureDetector.onTouchEvent(BaseGestureDetector.java:66)

BSD 2-clause license?

I'm not sure what it means. Can anyone please help with this?
I've found this one:
https://tldrlegal.com/license/bsd-2-clause-license-(freebsd)

As English isn't my main language, I couldn't understand its meaning, even though I've read in multiple websites (including Wikipedia).

  1. What does "Hold Liable" mean? that the original creator of the library won't be charged for damages?
  2. What does " Include Copyright" mean? that the app must show the description of the license somewhere within (like the "about" screen or something) ? or just the code should have it ?
    If just the code, what's the difference between it and Apache2 license ?

3.What about derivatives? What if I wish to fork the library? should it also be BSD 2-clause licensed ?

What should and what shouldn't I do?

Handle imageView without matrix technic

Hello,

I would like to use this library and handle and resize, rotate, and scale multiple imageviews but without matrix technic. Instead, I would like to user setX, setY, setRotation for example.
Problem is that I'm unable to combine the gestures together.
Do you have an example for this case ?
Thanks

David

RotateGestureDetector does not provide focus X/Y as ScaleGestureDetector

As title says, I cannot detect rotation focus point (the point between the two finger) while rotating. This can be useful to set rotation pivot when user should rotate some object on the screen.

The Android SDK's ScaleGestureDetector gives that focus point, so I can use it to set the "center" of zoom in/out actions.

inability to delete entity

deletedSelectedEntity() removes the entity from the List entities and even recycles the bitmap but the layer of the entity (to be deleted) still retains on the MotionView and we keep on getting a warning Called getWidth() on a recycle()'d bitmap! This is undefined behaviour!
2019-03-07 02-21-36

Bug: very rare crash

Not sure what I've done to do it, other than playing with it.

This is what I got in the logs:

java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(Native Method)
at android.view.MotionEvent.getX(MotionEvent.java:1983)
at com.almeros.android.multitouch.TwoFingerGestureDetector.updateStateByEvent(TwoFingerGestureDetector.java:77)
at com.almeros.android.multitouch.RotateGestureDetector.handleInProgressEvent(RotateGestureDetector.java:136)
at com.almeros.android.multitouch.BaseGestureDetector.onTouchEvent(BaseGestureDetector.java:66)

Mistake in detecting sloppy gestures

It seems there is a mistake in calculating raw coordinates of motion events, please see TwoFingerGestureDetector.getRawX(MotionEvent, int) (line 122) and TwoFingerGestureDetector.getRawY(MotionEvent, int) (line 136).

You should actually calculate offset like
float offset = event.getRawX() - event.getX();
and
float offset = event.getRawY() - event.getY();

cant compile with gradle

Hello,

I use: compile 'com.almeros.android-gesture-detectors:library:1.0' in gradle and get "failed to resolve"

can you please help me fix that?

Thank you

Added Code

hi Almeros, I wondered if i could contact you about working on a project related to your code here, is that possible, i dont see any contact info for you on github. Regards David

BaseGestureDetector crashes after "double tap to zoom" gesture.

After double tap to zoom it throws NullPointerException.

java.lang.NullPointerException
            at com.almeros.android.multitouch.BaseGestureDetector.updateStateByEvent(BaseGestureDetector.java:102)
            at com.almeros.android.multitouch.MoveGestureDetector.updateStateByEvent(MoveGestureDetector.java:122)
            at com.almeros.android.multitouch.MoveGestureDetector.handleInProgressEvent(MoveGestureDetector.java:105)
            at com.almeros.android.multitouch.BaseGestureDetector.onTouchEvent(BaseGestureDetector.java:66)

In the following method final MotionEvent prev variable is null.

protected void updateStateByEvent(MotionEvent curr){
        final MotionEvent prev = mPrevEvent;

        // Reset mCurrEvent
        if (mCurrEvent != null) {
            mCurrEvent.recycle();
            mCurrEvent = null;
        }
        mCurrEvent = MotionEvent.obtain(curr);


        // Delta time
        mTimeDelta = curr.getEventTime() - prev.getEventTime();

        // Pressure
        mCurrPressure = curr.getPressure(curr.getActionIndex());
        mPrevPressure = prev.getPressure(prev.getActionIndex());
}

Still : Pointer Index out of range

Rare but often bug which is crash app

Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
at android.view.MotionEvent.getX(MotionEvent.java:2136)
at com.rahul.mystickers.multitouch.TwoFingerGestureDetector.updateStateByEvent(TwoFingerGestureDetector.java:76)
at com.rahul.mystickers.multitouch.RotateGestureDetector.handleInProgressEvent(RotateGestureDetector.java:138)
at com.rahul.mystickers.multitouch.BaseGestureDetector.handleInProgressEvent(BaseGestureDetector.java:4)
at com.rahul.mystickers.multitouch.BaseGestureDetector.onTouchEvent(BaseGestureDetector.java:66)

View shake when touch

when use in a view which not fixed in Screen, it always tremble.

I use this:
imageView.setRotation(deltaDegree);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.