Class VFXPaginatedListManager<T,C extends VFXCell<T>>

java.lang.Object
io.github.palexdev.mfxcore.behavior.BehaviorBase<VFXList<T,C>>
io.github.palexdev.virtualizedfx.list.VFXListManager<T,C>
io.github.palexdev.virtualizedfx.list.paginated.VFXPaginatedListManager<T,C>

public class VFXPaginatedListManager<T,C extends VFXCell<T>> extends VFXListManager<T,C>
Default behavior implementation for VFXPaginatedList, extends VFXListManager.

This is necessary to respond to the following property changes introduced by the paginated variant:

- cells per page changes, onCellsPerPageChanged()

- max page changes, onMaxPageChanged()

It also modifies some of the behaviors already defined in VFXListManager because the paginated variant should respond differently in some cases, and also to optimize performance as much as possible.
  • Constructor Details

  • Method Details

    • onCellsPerPageChanged

      protected void onCellsPerPageChanged()
      A paginated container's size strictly depends on how many cells/rows/items is set to display per page, and this is enforced by the default skin VFXPaginatedListSkin, see VFXPaginatedListSkin.getLength().

      This core method is called whenever the VFXPaginatedList.cellsPerPageProperty() changes and ensures that the layout bounds of the container become invalid (Parent.isNeedsLayout() becomes 'true'), by calling Parent.requestLayout().

      This way, computations that also rely on the container size become invalid too, thus leading to correct values.

    • onMaxPageChanged

      protected void onMaxPageChanged()
      This core method ensures that the paginated container is always at a valid page/position when the VFXPaginatedList.maxPageProperty() changes.

      The only one case this needs to correct the position is when the current page is greater than the new max page. (both in terms of indexes ofc).

      Important note: the page change would trigger a position change (so VFXListManager.onPositionChanged()), but this method avoids it by setting the VFXListManager.invalidatingPos flag to 'true' before and immediately re-setting it to false after. This may sound counterintuitive, but there is a reason.

      You see, the max page property can change on two occasions:

      1) the number of items changes

      2) the cells per page changes

      BUT... in the first case, we have a change in the list which is handled by VFXListManager.onItemsChanged(); and the second case is handled by VFXListManager.onGeometryChanged(). This last case is very peculiar, because it will work only if the container's skin is implemented to adapt to the number of items per page. It's the skin's implementation to trigger the geometry change, and this should be the intended default behavior.

      If you want to make a skin that doesn't follow this logic, then you probably want to change this method too.

    • onCellSizeChanged

      protected void onCellSizeChanged()
      Overridden to just call VFXList.requestViewportLayout().

      For the paginated variant, the cells' size is irrelevant for its state. The default behavior, also dependent on the skin, is to adapt the container's size to the size of each cell as well as the number of cells per page.

      Overrides:
      onCellSizeChanged in class VFXListManager<T,C extends VFXCell<T>>
    • onOrientationChanged

      protected void onOrientationChanged()
      As also described in the super method (VFXListManager.onOrientationChanged()), when the orientation changes the most reasonable behavior is to reset both the positions to 0.0. For the paginated variant this requires extra steps because, according to the previous orientation, the vPos or hPos properties are bound. Also, the reset also requires setting the page to 0.
      Overrides:
      onOrientationChanged in class VFXListManager<T,C extends VFXCell<T>>
    • getNode

      public VFXPaginatedList<T,C> getNode()
      Overridden to cast to VFXPaginatedList since this behavior only allows that type.
      Overrides:
      getNode in class io.github.palexdev.mfxcore.behavior.BehaviorBase<VFXList<T,C extends VFXCell<T>>>