From 048ea2f4ce9d63d47db3d2b7359cb25db5dbe929 Mon Sep 17 00:00:00 2001 From: Steve McKay Date: Tue, 19 Jul 2016 13:24:23 -0700 Subject: [PATCH] Remove unused "isTouchEvent" methods. Update BandController to use InputEvent not contrete MotionInputEvent. Change-Id: I47a7558d8dcebfa6c44dc9a62741487422bf0ff7 --- .../src/com/android/documentsui/Events.java | 29 +--------------------- .../documentsui/dirlist/BandController.java | 8 +++--- .../com/android/documentsui/TestInputEvent.java | 5 ---- 3 files changed, 5 insertions(+), 37 deletions(-) diff --git a/packages/DocumentsUI/src/com/android/documentsui/Events.java b/packages/DocumentsUI/src/com/android/documentsui/Events.java index 2d0dbe8ce321..95934c3fb5cc 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/Events.java +++ b/packages/DocumentsUI/src/com/android/documentsui/Events.java @@ -35,34 +35,13 @@ public final class Events { * Returns true if event was triggered by a mouse. */ public static boolean isMouseEvent(MotionEvent e) { - return isMouseType(e.getToolType(0)); - } - - /** - * Returns true if event was triggered by a finger or stylus touch. - */ - public static boolean isTouchEvent(MotionEvent e) { - return isTouchType(e.getToolType(0)); - } - - /** - * Returns true if event was triggered by a mouse. - */ - public static boolean isMouseType(int toolType) { + int toolType = e.getToolType(0); return toolType == MotionEvent.TOOL_TYPE_MOUSE; } /** * Returns true if event was triggered by a finger or stylus touch. */ - public static boolean isTouchType(int toolType) { - return toolType == MotionEvent.TOOL_TYPE_FINGER - || toolType == MotionEvent.TOOL_TYPE_STYLUS; - } - - /** - * Returns true if event was triggered by a finger or stylus touch. - */ public static boolean isActionDown(MotionEvent e) { return e.getActionMasked() == MotionEvent.ACTION_DOWN; } @@ -116,7 +95,6 @@ public final class Events { * of related code. */ public interface InputEvent extends AutoCloseable { - boolean isTouchEvent(); boolean isMouseEvent(); boolean isPrimaryButtonPressed(); boolean isSecondaryButtonPressed(); @@ -212,11 +190,6 @@ public final class Events { } @Override - public boolean isTouchEvent() { - return Events.isTouchEvent(mEvent); - } - - @Override public boolean isMouseEvent() { return Events.isMouseEvent(mEvent); } diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/BandController.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/BandController.java index 8f520367e602..eb53ec1a4ad6 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/BandController.java +++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/BandController.java @@ -85,14 +85,14 @@ public class BandController extends RecyclerView.OnScrollListener { new RecyclerView.OnItemTouchListener() { @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { - try (MotionInputEvent event = MotionInputEvent.obtain(e, view)) { + try (InputEvent event = MotionInputEvent.obtain(e, view)) { return handleEvent(event); } } @Override public void onTouchEvent(RecyclerView rv, MotionEvent e) { if (Events.isMouseEvent(e)) { - try (MotionInputEvent event = MotionInputEvent.obtain(e, view)) { + try (InputEvent event = MotionInputEvent.obtain(e, view)) { processInputEvent(event); } } @@ -177,7 +177,7 @@ public class BandController extends RecyclerView.OnScrollListener { mSelection = selection; } - private boolean handleEvent(MotionInputEvent e) { + private boolean handleEvent(InputEvent e) { // Don't start, or extend bands on right click. if (e.isSecondaryButtonPressed()) { return false; @@ -230,7 +230,7 @@ public class BandController extends RecyclerView.OnScrollListener { } } - boolean shouldStart(MotionInputEvent e) { + boolean shouldStart(InputEvent e) { return !isActive() && e.isActionDown() // the initial button press && mAdapter.getItemCount() > 0 diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/TestInputEvent.java b/packages/DocumentsUI/tests/src/com/android/documentsui/TestInputEvent.java index 36e7c1bf7010..e6936d68ebd6 100644 --- a/packages/DocumentsUI/tests/src/com/android/documentsui/TestInputEvent.java +++ b/packages/DocumentsUI/tests/src/com/android/documentsui/TestInputEvent.java @@ -22,11 +22,6 @@ public class TestInputEvent implements Events.InputEvent { } @Override - public boolean isTouchEvent() { - return !mouseEvent; - } - - @Override public boolean isMouseEvent() { return mouseEvent; } -- 2.11.0