SwipeDismissBehavior崩溃

时间:2017-08-24 05:42:25

标签: android

我正面临着这次崩溃但我无法找到任何解决方案,即使我无法重现它。我在滑动行为中面临这个问题。我尝试了不同的解决方案,但通过解除触摸行为而言都是徒劳的,还有更多的请给我这个崩溃的解决方案,因为它经常崩溃。

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewParent android.view.View.getParent()' on a null object reference
   at android.support.design.widget.SwipeDismissBehavior$1.onViewReleased(SwipeDismissBehavior.java:243)
   at android.support.v4.widget.ViewDragHelper.dispatchViewReleased(ViewDragHelper.java:770)
   at android.support.v4.widget.ViewDragHelper.releaseViewForPointerUp(ViewDragHelper.java:1413)
   at android.support.v4.widget.ViewDragHelper.processTouchEvent(ViewDragHelper.java:1231)
   at android.support.design.widget.SwipeDismissBehavior.onTouchEvent(SwipeDismissBehavior.java:197)
   at android.support.design.widget.CoordinatorLayout.performIntercept(CoordinatorLayout.java:436)
   at android.support.design.widget.CoordinatorLayout.onTouchEvent(CoordinatorLayout.java:493)
   at android.view.View.dispatchTouchEvent(View.java:9399)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2549)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
   at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2469)
   at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1785)
   at android.app.Activity.dispatchTouchEvent(Activity.java:2867)
   at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:67)
   at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2430)
   at android.view.View.dispatchPointerEvent(View.java:9619)
   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4471)
   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4337)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3869)
   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3922)
   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3888)
   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4014)
   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3896)
   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4071)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3869)
   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3922)
   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3888)
   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3896)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3869)
   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6170)
   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6144)
   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6105)
   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6286)
   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:192)
   at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
   at android.os.MessageQueue.next(MessageQueue.java:330)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:5665)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)

这是我的代码我不确定,因为没有提到行号。我正在接受Fabric的这次崩溃。

// Private class for gestures
private class SwipeGestureDetector extends GestureDetector.SimpleOnGestureListener {
    // Swipe properties, you can change it to make the swipe
    // longer or shorter and speed
    private static final int SWIPE_MIN_DISTANCE = 100;
    private static final int SWIPE_MAX_OFF_PATH = 800;
    private static final int SWIPE_THRESHOLD_VELOCITY = 300;
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        boolean result = false;
        try {
            float diffY = e2.getY() - e1.getY();
            float diffX = e2.getX() - e1.getX();
            if (Math.abs(diffX) > Math.abs(diffY)) {
                if (Math.abs(diffX) > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    if (diffX > 0) {
                    } else {
                    }
                    result = true;
                }
            } else if (Math.abs(diffY) > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
                if (diffY > 0) {
                    onSlideDown();
                } else {
                   onSlideUp();
                }
                result = true;
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return result;
    }
}

0 个答案:

没有答案