bauerca / drag-sort-listview

Android ListView with drag and drop reordering.
3.2k stars 1.44k forks source link

ListView did not receive a notification error #128

Open SunMaungOo opened 10 years ago

SunMaungOo commented 10 years ago

I have added about 80 view (which has buttons) in the DragSortListView. Then I remove the view with the DragSortListView removeItem(int which) method. Before the DragSortListView has finished removing view (i.e , it been in the reordering view stage) I click the view in the drag sort list view and the error is shown which tell me that

"The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2130968590, class com.mobeta.android.dslv.DragSortListView) with Adapter(class com.mobeta.android.dslv.DragSortListView$AdapterWrapper)] "

Below is my complete logcat. Any solution is welcome

08-22 16:56:44.530: E/AndroidRuntime(2800): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2130968590, class com.mobeta.android.dslv.DragSortListView) with Adapter(class com.mobeta.android.dslv.DragSortListView$AdapterWrapper)] 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.widget.ListView.layoutChildren(ListView.java:1544) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.mobeta.android.dslv.DragSortListView.layoutChildren(DragSortListView.java:2136) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.widget.AbsListView.onTouchEvent(AbsListView.java:3348) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.mobeta.android.dslv.DragSortListView.onTouchEvent(DragSortListView.java:1641) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.View.dispatchTouchEvent(View.java:7246) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2168) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1903) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.app.Activity.dispatchTouchEvent(Activity.java:2410) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.View.dispatchPointerEvent(View.java:7426) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3236) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3180) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4308) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4287) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4379) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4358) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4398) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.Choreographer.doCallbacks(Choreographer.java:562) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.Choreographer.doFrame(Choreographer.java:530) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.os.Handler.handleCallback(Handler.java:725) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.os.Handler.dispatchMessage(Handler.java:92) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.os.Looper.loop(Looper.java:137) 08-22 16:56:44.530: E/AndroidRuntime(2800): at android.app.ActivityThread.main(ActivityThread.java:5041) 08-22 16:56:44.530: E/AndroidRuntime(2800): at java.lang.reflect.Method.invokeNative(Native Method) 08-22 16:56:44.530: E/AndroidRuntime(2800): at java.lang.reflect.Method.invoke(Method.java:511) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817) 08-22 16:56:44.530: E/AndroidRuntime(2800): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 08-22 16:56:44.530: E/AndroidRuntime(2800): at dalvik.system.NativeStart.main(Native Method) 08-22 16:56:44.570: D/dalvikvm(2800): GC_CONCURRENT freed 473K, 19% free 4956K/6072K, paused 3ms+5ms, total 36ms

SunMaungOo commented 10 years ago

I seem that I been lucky for a long time . Basically I used a loader to automatically update data on drag sort list view and I forgot to call notifyDataSetChanged() since I thought that calling swapCursor() on both onLoadFinished() and onLoaderReset() is enough. The problem is solved for now so I think this is a main reason for the error.