From d8a08000dd62b9d8fdc29bc8651a7fcd93de7812 Mon Sep 17 00:00:00 2001 From: Aracem Date: Fri, 6 Mar 2015 13:24:10 +0100 Subject: [PATCH] Fix the TouchEvent.MOVE error that causes wrong feedback when click and move out of the ActionButton --- fab/src/main/java/com/software/shell/fab/ActionButton.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fab/src/main/java/com/software/shell/fab/ActionButton.java b/fab/src/main/java/com/software/shell/fab/ActionButton.java index 49c8f26..0f8ff15 100644 --- a/fab/src/main/java/com/software/shell/fab/ActionButton.java +++ b/fab/src/main/java/com/software/shell/fab/ActionButton.java @@ -1013,9 +1013,16 @@ public boolean onTouchEvent(MotionEvent event) { setState(State.PRESSED); return true; case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: Log.v(LOG_TAG, "Motion event action up detected"); setState(State.NORMAL); return true; + case MotionEvent.ACTION_MOVE: + if (event.getX() < 0 || event.getX() > getWidth() + || event.getY() < 0 ||event.getY() > getHeight()){ + setState(State.NORMAL); + } + return true; default: Log.v(LOG_TAG, "Unrecognized motion event detected"); return false;