Skip to content

Commit

Permalink
Merge pull request #2174 from CruGlobal/viewInvalidTouchEvents
Browse files Browse the repository at this point in the history
GT-2454 Handle updated invalid touch event exceptions
  • Loading branch information
frett authored Sep 25, 2024
2 parents 7d8f21f + 829b606 commit a71cca4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public static <T extends Throwable> boolean handleOnTouchEventException(@NonNull
}

private static boolean isMotionEventPointerIndexException(@NonNull final Throwable cause) {
return cause instanceof IllegalArgumentException && cause.getMessage() != null &&
cause.getMessage().startsWith("pointerIndex out of range");
if (!(cause instanceof IllegalArgumentException)) return false;
final String message = cause.getMessage();
if (message == null) return false;
if (message.startsWith("pointerIndex out of range")) return true;
return message.startsWith("invalid pointerIndex");
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package org.ccci.gto.android.common.util.view;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Test;

public class ViewUtilsTest {
private static final Exception[] TOUCH_EXCEPTIONS_TO_SUPPRESS = {
new IllegalArgumentException("pointerIndex out of range"),
new IllegalArgumentException("pointerIndex out of range pointerIndex=-1 pointerCount=1"),
new IllegalArgumentException(
"invalid pointerIndex -1 for MotionEvent { action=MOVE, id[0]=1, x[0]=281.459, y[0]=212.818, " +
"historySize=2, eventTime=22300703589796, downTime=22299744899000, deviceId=3, " +
"source=TOUCHSCREEN, displayId=0, eventId=313846789}"
)
};

private static final Exception[] TOUCH_EXCEPTIONS_TO_PROPAGATE = {
new RuntimeException(),
new IllegalArgumentException()
};

Expand Down

0 comments on commit a71cca4

Please sign in to comment.