From c5f39cf9ee1ffa4efb1d74aa34c77ffcfeef371b Mon Sep 17 00:00:00 2001 From: CappielloAntonio Date: Mon, 30 Aug 2021 09:15:16 +0200 Subject: [PATCH] Do not draw the dot icon if there is only one page --- .../play/helper/recyclerview/DotsIndicatorDecoration.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/cappielloantonio/play/helper/recyclerview/DotsIndicatorDecoration.java b/app/src/main/java/com/cappielloantonio/play/helper/recyclerview/DotsIndicatorDecoration.java index 647a90ae..27198e99 100644 --- a/app/src/main/java/com/cappielloantonio/play/helper/recyclerview/DotsIndicatorDecoration.java +++ b/app/src/main/java/com/cappielloantonio/play/helper/recyclerview/DotsIndicatorDecoration.java @@ -51,6 +51,10 @@ public class DotsIndicatorDecoration extends RecyclerView.ItemDecoration { int itemCount = (int) Math.ceil((double) parent.getAdapter().getItemCount() / 5); + if (itemCount <= 1) { + return; + } + // center horizontally, calculate width and subtract half from center float totalLength = this.radius * 2 * itemCount; float paddingBetweenItems = Math.max(0, itemCount - 1) * indicatorItemPadding;