From 4556d50eda3535e03e12a3c68dc7378795d14973 Mon Sep 17 00:00:00 2001 From: Xiao Bao Clark Date: Sat, 26 Sep 2015 10:13:16 +1000 Subject: [PATCH] DragSortController: Check for null MotionEvent arguments (#202) This fixes a rare crash on Samsung Galaxy S6 devices. The null arguments appear to be caused by the GestureDetector not receiving an ACTION_DOWN event before receiving an ACTION_MOVE event. As we are unable to reproduce it, this commit work around the issue. It might cause some scrolling issues in the cases that cause the issue, but better than crashing. --- src/com/mobeta/android/dslv/DragSortController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/mobeta/android/dslv/DragSortController.java b/src/com/mobeta/android/dslv/DragSortController.java index 665889ea..bd83f537 100644 --- a/src/com/mobeta/android/dslv/DragSortController.java +++ b/src/com/mobeta/android/dslv/DragSortController.java @@ -378,6 +378,11 @@ public class DragSortController extends SimpleFloatViewManager implements View.O @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { + // Guard against rare case of null MotionEvents on some devices + if (e1 == null || e2 == null) { + return false; + } + final int x1 = (int) e1.getX(); final int y1 = (int) e1.getY(); final int x2 = (int) e2.getX();