Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 048ea2f4 authored by Steve McKay's avatar Steve McKay
Browse files

Remove unused "isTouchEvent" methods.

Update BandController to use InputEvent not contrete MotionInputEvent.

Change-Id: I47a7558d8dcebfa6c44dc9a62741487422bf0ff7
parent 984d575d
Loading
Loading
Loading
Loading
+1 −28
Original line number Diff line number Diff line
@@ -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);
+4 −4
Original line number Diff line number Diff line
@@ -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
+0 −5
Original line number Diff line number Diff line
@@ -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;