fix: java.lang.IndexOutOfBoundsException

Inconsistency detected. Invalid view holder adapter positionViewHolder{b7a986a position=1 id=-1, oldPos=0, pLpos:0 scrap [attachedScrap] tmpDetached no parent} com.stardust.autojs.core.ui.widget.JsGridView{99f615b VFED..CL. ......ID 0,120-1080,1554 #133a2c2}, adapter:com.stardust.autojs.core.ui.widget.JsListView$Adapter@fe85df8, layout:android.support.v7.widget.GridLayoutManager@861c2d1, context:com.stardust.autojs.execution.ScriptExecuteActivity@6cd9514
This commit is contained in:
hyb1996
2018-10-12 10:38:53 +08:00
parent b42e440fff
commit 947236a4c5
6 changed files with 66 additions and 8 deletions

View File

@@ -18,6 +18,15 @@ public class JsGridView extends JsListView {
@Override
protected void init() {
super.init();
setLayoutManager(new GridLayoutManager(getContext(), 1));
setLayoutManager(new GridLayoutManager(getContext(), 1){
@Override
public void onLayoutChildren(Recycler recycler, State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
getScriptRuntime().console.error(e);
}
}
});
}
}

View File

@@ -54,6 +54,9 @@ public class JsListView extends RecyclerView {
setLayoutManager(new WrapContentLinearLayoutManager(getContext()));
}
protected ScriptRuntime getScriptRuntime() {
return mScriptRuntime;
}
public void setOnItemTouchListener(OnItemTouchListener onItemTouchListener) {
mOnItemTouchListener = onItemTouchListener;