RecyclerView 在使用的时候发生:
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder
翻译为:
角标越界,检测到不一致。无效的视图保持架适配器位置视图保持架
当RecyclerView遇到Inconsistency detected崩溃时
自我分析:
使用场景实在 SwipReflashLayout 进行下拉刷新和上拉加载的时候,正常请求比较慢,可以多次请求,由于网络的不稳定,请求的数据可能会有并发操作,对同一个数据进行处理。导致recyclerview adpter里面的 数据集和 外部的数据集不一致。eg : 加载 和 刷新 同时操作 ,会有 该问题。
解决方式: 在 下拉刷新 或者 上拉加载的时候 不可进行网络请求,一般 刷新框架 都有对应的方法,直接调用即可。
显示的内容:
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{73b73d7 position=12 id=-1, oldPos=-1, pLpos:-1 no parent}
at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5297)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5479)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1551)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1325)
at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1061)
at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1695)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2883)
at android.view.View.dispatchTouchEvent(View.java:10011)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2833)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2504)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at com.scwang.smartrefresh.layout.SmartRefreshLayout.dispatchTouchEvent(SmartRefreshLayout.java:1005)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2840)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1853)
at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2801)
at android.view.View.dispatchPointerEvent(View.java:10246)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5447)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5283)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4882)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4939)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl.delive
网友评论