Merge "Remove unused "isTouchEvent" methods."

This commit is contained in:
TreeHugger Robot
2016-07-21 02:59:06 +00:00
committed by Android (Google) Code Review
3 changed files with 5 additions and 37 deletions

View File

@@ -35,31 +35,10 @@ 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.
*/
@@ -116,7 +95,6 @@ public final class Events {
* of related code.
*/
public interface InputEvent extends AutoCloseable {
boolean isTouchEvent();
boolean isMouseEvent();
boolean isPrimaryButtonPressed();
boolean isSecondaryButtonPressed();
@@ -211,11 +189,6 @@ public final class Events {
recycle();
}
@Override
public boolean isTouchEvent() {
return Events.isTouchEvent(mEvent);
}
@Override
public boolean isMouseEvent() {
return Events.isMouseEvent(mEvent);

View File

@@ -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

View File

@@ -21,11 +21,6 @@ public class TestInputEvent implements Events.InputEvent {
this.position = position;
}
@Override
public boolean isTouchEvent() {
return !mouseEvent;
}
@Override
public boolean isMouseEvent() {
return mouseEvent;