I am using drag-sort-listview (https://github.com/bauerca/drag-sort-listview) in a ListFragment.
Things are working when I enable the dragsort on creation. However, I would like to leave it disabled until a longclick on one of the items in the listview.
So I would like to set
mDslv.setDragEnabled(false);
in 3 places: onCreateView(), DragSortListView.DropListener, and DragSortListView.RemoveListener
In my ListFragment, I have:
listView.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener(){
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
mDslv.setDragEnabled(true);
return true;
}
});
My hope is that a long click on any item will turn on the DSLV and allow that item to be dropped or removed, after which DSLV will be disabled again.
However, after (not while) the setDrageEnabled(true) is called, I get a NullPointerException:
09-03 00:03:33.749: E/AndroidRuntime(9703): FATAL EXCEPTION: main
09-03 00:03:33.749: E/AndroidRuntime(9703): java.lang.NullPointerException
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.mobeta.android.dslv.DragSortController.onScroll(DragSortController.java:381)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:541)
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.mobeta.android.dslv.DragSortController.onTouch(DragSortController.java:243)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.View.dispatchTouchEvent(View.java:3881)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1703)
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1133)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1687)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2196)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.view.ViewRoot.handleMessage(ViewRoot.java:1880)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.os.Handler.dispatchMessage(Handler.java:99)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.os.Looper.loop(Looper.java:130)
09-03 00:03:33.749: E/AndroidRuntime(9703): at android.app.ActivityThread.main(ActivityThread.java:3729)
09-03 00:03:33.749: E/AndroidRuntime(9703): at java.lang.reflect.Method.invokeNative(Native Method)
09-03 00:03:33.749: E/AndroidRuntime(9703): at java.lang.reflect.Method.invoke(Method.java:507)
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
09-03 00:03:33.749: E/AndroidRuntime(9703): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
09-03 00:03:33.749: E/AndroidRuntime(9703): at dalvik.system.NativeStart.main(Native Method)
Has anyone tried this? Any ideas? It looks like one of the motion events is NULL, probably because I am enabling DSLV during a touch event.