From 8e469ab1d8e3a931453ebd7878d3ef634b4f722b Mon Sep 17 00:00:00 2001 From: dlemmermann Date: Thu, 26 Sep 2024 12:13:07 +0100 Subject: [PATCH] Limit end index to total item count Previously, the end index could exceed the total item count, potentially causing inconsistencies in the displayed range of items. This change ensures the end index is always within the bounds of the total item count, improving the accuracy of the pagination display. --- gemsfx/src/main/java/com/dlsc/gemsfx/PagingControls.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControls.java b/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControls.java index eb1bea7c..381dd0b1 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControls.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControls.java @@ -48,6 +48,8 @@ public PagingControls() { int startIndex = (view.getPage() * getPageSize()) + 1; int endIndex = startIndex + getPageSize() - 1; + endIndex = Math.min(endIndex, getTotalItemCount()); + return "Showing items " + startIndex + " to " + endIndex + " of " + getTotalItemCount(); });