mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-18 21:10:19 +08:00
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:
parent
b42e440fff
commit
947236a4c5
@ -27,6 +27,7 @@ import org.autojs.autojs.model.indices.Module;
|
||||
import org.autojs.autojs.model.indices.Modules;
|
||||
import org.autojs.autojs.model.indices.Property;
|
||||
import org.autojs.autojs.ui.widget.GridDividerDecoration;
|
||||
import org.autojs.autojs.workground.WrapContentGridLayoutManger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -98,10 +99,11 @@ public class FunctionsKeyboardView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void initPropertiesView() {
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), SPAN_COUNT);
|
||||
mPropertiesView.setLayoutManager(gridLayoutManager);
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(getContext(), 2);
|
||||
manager.setDebugInfo("FunctionsKeyboardView");
|
||||
mPropertiesView.setLayoutManager(manager);
|
||||
mPropertiesView.setAdapter(new PropertiesAdapter());
|
||||
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
|
||||
@ -42,6 +42,7 @@ import org.autojs.autojs.ui.viewmodel.ExplorerItemList;
|
||||
import org.autojs.autojs.ui.widget.BindableViewHolder;
|
||||
import org.autojs.autojs.theme.widget.ThemeColorSwipeRefreshLayout;
|
||||
|
||||
import org.autojs.autojs.workground.WrapContentGridLayoutManger;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.Stack;
|
||||
@ -194,7 +195,8 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
|
||||
private void initExplorerItemListView() {
|
||||
mExplorerItemListView.setAdapter(mExplorerAdapter);
|
||||
GridLayoutManager manager = new GridLayoutManager(getContext(), 2);
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(getContext(), 2);
|
||||
manager.setDebugInfo("ExplorerView");
|
||||
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
@ -311,7 +313,7 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
sort(ExplorerItemList.SORT_TYPE_SIZE, mDirSortMenuShowing);
|
||||
break;
|
||||
case R.id.reset:
|
||||
// WorkspaceFileProvider.resetSample(mSelectedItem.toScriptFile());
|
||||
// WorkspaceFileProvider.resetSample(mSelectedItem.toScriptFile());
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -494,7 +496,7 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
if (!mExplorerItem.canRename()) {
|
||||
menu.removeItem(R.id.rename);
|
||||
}
|
||||
if(mExplorerItem instanceof ExplorerSampleItem){
|
||||
if (mExplorerItem instanceof ExplorerSampleItem) {
|
||||
|
||||
}
|
||||
popupMenu.setOnMenuItemClickListener(ExplorerView.this);
|
||||
|
||||
@ -25,6 +25,7 @@ import org.autojs.autojs.ui.BaseActivity;
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
import org.autojs.autojs.workground.WrapContentGridLayoutManger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -57,7 +58,9 @@ public class ShortcutIconSelectActivity extends BaseActivity {
|
||||
|
||||
private void setupApps() {
|
||||
mApps.setAdapter(new AppsAdapter());
|
||||
mApps.setLayoutManager(new GridLayoutManager(this, 5));
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(this, 2);
|
||||
manager.setDebugInfo("IconSelectView");
|
||||
mApps.setLayoutManager(manager);
|
||||
loadApps();
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package org.autojs.autojs.workground;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.bugly.crashreport.BuglyLog;
|
||||
|
||||
public class WrapContentGridLayoutManger extends GridLayoutManager {
|
||||
|
||||
private String mDebugInfo;
|
||||
|
||||
public WrapContentGridLayoutManger(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public WrapContentGridLayoutManger(Context context, int spanCount) {
|
||||
super(context, spanCount);
|
||||
}
|
||||
|
||||
public WrapContentGridLayoutManger(Context context, int spanCount, int orientation, boolean reverseLayout) {
|
||||
super(context, spanCount, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
public void setDebugInfo(String debugInfo) {
|
||||
mDebugInfo = debugInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
try {
|
||||
super.onLayoutChildren(recycler, state);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
BuglyLog.e("GridLayoutManager", "Android bug: debug info = " + mDebugInfo, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user