* Use mutable list to allow updates even when grid is inactive I don't think this should happen but it does, so this makes it continue silently instead of crashing. Fix refinedmods/refinedstorage#2811 * Do not show updated items if there is no full inventory yet * Ensure gridview list implementation is ArrayList The update code relies on an indexed mutable list, so that should be made explicit here.
This commit is contained in:
@@ -16,6 +16,7 @@ import java.util.stream.Stream;
|
|||||||
public class GridViewImpl implements IGridView {
|
public class GridViewImpl implements IGridView {
|
||||||
private final GridScreen screen;
|
private final GridScreen screen;
|
||||||
private boolean canCraft;
|
private boolean canCraft;
|
||||||
|
private boolean active = false;
|
||||||
|
|
||||||
private final IGridSorter defaultSorter;
|
private final IGridSorter defaultSorter;
|
||||||
private final List<IGridSorter> sorters;
|
private final List<IGridSorter> sorters;
|
||||||
@@ -55,9 +56,11 @@ public class GridViewImpl implements IGridView {
|
|||||||
this.stacks = map.values().stream()
|
this.stacks = map.values().stream()
|
||||||
.filter(getActiveFilters())
|
.filter(getActiveFilters())
|
||||||
.sorted(getActiveSort())
|
.sorted(getActiveSort())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
this.active = true;
|
||||||
} else {
|
} else {
|
||||||
this.stacks = Collections.emptyList();
|
this.stacks = new ArrayList<>();
|
||||||
|
this.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.screen.updateScrollbar();
|
this.screen.updateScrollbar();
|
||||||
@@ -111,6 +114,9 @@ public class GridViewImpl implements IGridView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postChange(IGridStack stack, int delta) {
|
public void postChange(IGridStack stack, int delta) {
|
||||||
|
if (!this.active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// COMMENT 1 (about this if check in general)
|
// COMMENT 1 (about this if check in general)
|
||||||
// Update the other id reference if needed.
|
// Update the other id reference if needed.
|
||||||
// Taking a stack out - and then re-inserting it - gives the new stack a new ID
|
// Taking a stack out - and then re-inserting it - gives the new stack a new ID
|
||||||
|
|||||||
Reference in New Issue
Block a user