Использую в двух активити своего проекта библиотеку
PullToRefresh. Да, сейчас библиотека уже объявлена как deprecated, но тем не менее, она крайне удобна и умеет обновлять, как сверху, так и снизу. Тем не менее, есть и проблема — изредка приложение вылетает со следующим логом:
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(16908298, class com.handmark.pulltorefresh.library.PullToRefreshListView$InternalListViewSDK9) with Adapter(class android.widget.HeaderViewListAdapter)]
at android.widget.ListView.layoutChildren(ListView.java:1551)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:4218)
at android.view.View.dispatchTouchEvent(View.java:7461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2264)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1995)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2270)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2010)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2182)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1512)
at android.app.Activity.dispatchTouchEvent(Activity.java:2466)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2130)
at android.view.View.dispatchPointerEvent(View.java:7641)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3682)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3613)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4804)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4783)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4875)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:174)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4854)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4894)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:530)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Изредка настолько, что лично я это видел только один раз за много месяцев частого использования приложения. Но тем не менее периодически и пользователи присылают отчеты с этим логом.
Насколько я понимаю, это ошибка происходит не в моем коде, а в коде библиотеки, в частности в классе InternalListViewSDK9. Вот его код:
@TargetApi(9)
final class InternalListViewSDK9 extends InternalListView {
public InternalListViewSDK9(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX,
int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX,
scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
// Does all of the hard work...
OverscrollHelper.overScrollBy(PullToRefreshListView.this, deltaY, scrollY, isTouchEvent);
return returnValue;
}
}
Как можно устранить эту проблему, если даже нет возможности гарантированно ее воспроизвести? Может быть ее можно хотя бы как-то подавить, чтобы приложение не вылетало?