From 492be7cceefd27cdf2ef370215b7445adc58f525 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Wed, 31 Jul 2019 14:41:18 -0400 Subject: [PATCH] Fix number of pages in PagedTileLayout If there's less that one full page of tiles, do not create an extra page (as there's always a minimum of 1 page). Fixes: 138625713 Test: manual with less and more than one page of tiles Change-Id: I59a111f55ce3b00b94d8fb1a0594497c5a3af35c --- .../SystemUI/src/com/android/systemui/qs/PagedTileLayout.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index 991d9fa549ac4..0403a0505b003 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -248,7 +248,9 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { int numPages = Math.max(nTiles / mPages.get(0).maxTiles(), 1); // Add one more not full page if needed - numPages += (nTiles % mPages.get(0).maxTiles() == 0 ? 0 : 1); + if (nTiles > numPages * mPages.get(0).maxTiles()) { + numPages++; + } final int NP = mPages.size(); for (int i = 0; i < NP; i++) {