Class GridViewImpl
java.lang.Object
com.refinedmods.refinedstorage.api.grid.view.GridViewImpl
- All Implemented Interfaces:
GridView
-
Constructor Summary
ConstructorDescriptionGridViewImpl
(GridResourceFactory resourceFactory, ResourceList backingList, Map<ResourceKey, TrackedResource> initialTrackedResources, GridSortingType identitySortingType, GridSortingType defaultSortingType) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the backing list, view list and tracked resources index.long
getAmount
(ResourceKey resource) getTrackedResource
(ResourceKey resource) void
onChange
(ResourceKey resource, long amount, TrackedResource trackedResource) Applies a change to a resource.setFilterAndSort
(BiPredicate<GridView, GridResource> predicate) void
setListener
(Runnable listener) Sets a listener that is called when the grid view changes.boolean
setPreventSorting
(boolean changedPreventSorting) Preventing sorting means that the changes will still arrive at the backing list and view list, but, the view list won't be resorted and if a resource is zeroed, will stay in view until sorting is enabled again.void
setSortingDirection
(GridSortingDirection sortingDirection) Changing the sorting direction still requires a call toGridView.sort()
.void
setSortingType
(GridSortingType sortingType) Changing the sorting type still requires a call toGridView.sort()
.void
sort()
Sorts the view list.
-
Constructor Details
-
GridViewImpl
public GridViewImpl(GridResourceFactory resourceFactory, ResourceList backingList, Map<ResourceKey, TrackedResource> initialTrackedResources, GridSortingType identitySortingType, GridSortingType defaultSortingType) - Parameters:
resourceFactory
- a factory that transforms a resource amount to a grid resourcebackingList
- the backing listinitialTrackedResources
- initial tracked resources stateidentitySortingType
- a sorting type required to keep a consistent sorting order with quantity sortingdefaultSortingType
- the default sorting type
-
-
Method Details
-
setListener
Description copied from interface:GridView
Sets a listener that is called when the grid view changes.- Specified by:
setListener
in interfaceGridView
- Parameters:
listener
- the listener, can be null
-
setSortingType
Description copied from interface:GridView
Changing the sorting type still requires a call toGridView.sort()
.- Specified by:
setSortingType
in interfaceGridView
- Parameters:
sortingType
- the sorting type
-
setFilterAndSort
public BiPredicate<GridView,GridResource> setFilterAndSort(BiPredicate<GridView, GridResource> predicate) - Specified by:
setFilterAndSort
in interfaceGridView
- Parameters:
predicate
- the filter- Returns:
- the previous filtering predicate
-
setPreventSorting
public boolean setPreventSorting(boolean changedPreventSorting) Description copied from interface:GridView
Preventing sorting means that the changes will still arrive at the backing list and view list, but, the view list won't be resorted and if a resource is zeroed, will stay in view until sorting is enabled again. This still requires a call toGridView.sort()
when preventing sorting is disabled again.- Specified by:
setPreventSorting
in interfaceGridView
- Parameters:
changedPreventSorting
- whether the view should prevent sorting on changes- Returns:
- whether prevent sorting has changed
-
setSortingDirection
Description copied from interface:GridView
Changing the sorting direction still requires a call toGridView.sort()
.- Specified by:
setSortingDirection
in interfaceGridView
- Parameters:
sortingDirection
- the sorting direction
-
getTrackedResource
- Specified by:
getTrackedResource
in interfaceGridView
- Parameters:
resource
- the resource- Returns:
- the tracked resource, if present
-
getAmount
-
sort
public void sort()Description copied from interface:GridView
Sorts the view list. Applies sorting and filtering rules. -
onChange
Description copied from interface:GridView
Applies a change to a resource. Will update the backing list, and will also update the view list (depending on if the view is preventing sorting). -
getViewList
- Specified by:
getViewList
in interfaceGridView
- Returns:
- the view list
-
copyBackingList
- Specified by:
copyBackingList
in interfaceGridView
- Returns:
- a copy of the backing list
-
clear
public void clear()Description copied from interface:GridView
Clears the backing list, view list and tracked resources index.
-