Fix search layout crash

This commit is contained in:
NekoInverter committed 2020-12-18 15:24:54 +08:00
1 parent 8c07b6c473
commit a916447599
1 file changed
+17 -1
@@ -103,7 +103,7 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
Resources resources = context.getResources();
mInflater = LayoutInflater.from(context);
mLayoutManager = new LinearLayoutManager(context);
mLayoutManager = new SearchLayoutManager(context);
mAdapter = new SearchAdapter();
setLayoutManager(mLayoutManager);
setAdapter(mAdapter);
@@ -383,4 +383,20 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
}
}
}
static class SearchLayoutManager extends LinearLayoutManager {
public SearchLayoutManager(Context context) {
super(context);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}
}