Merge "Merge "Set PageIndicator pages in QSPanel#onMeasure" into rvc-dev am: 7577e1d2cf am: a7d9ccee13" into rvc-d1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
a124e6c9af
@@ -291,15 +291,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void emptyAndInflateOrRemovePages() {
|
private void emptyAndInflateOrRemovePages() {
|
||||||
final int nTiles = mTiles.size();
|
final int numPages = getNumPages();
|
||||||
// We should always have at least one page, even if it's empty.
|
|
||||||
int numPages = Math.max(nTiles / mPages.get(0).maxTiles(), 1);
|
|
||||||
|
|
||||||
// Add one more not full page if needed
|
|
||||||
if (nTiles > numPages * mPages.get(0).maxTiles()) {
|
|
||||||
numPages++;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int NP = mPages.size();
|
final int NP = mPages.size();
|
||||||
for (int i = 0; i < NP; i++) {
|
for (int i = 0; i < NP; i++) {
|
||||||
mPages.get(i).removeAllViews();
|
mPages.get(i).removeAllViews();
|
||||||
@@ -431,6 +423,22 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
|||||||
return mPages.get(0).mColumns;
|
return mPages.get(0).mColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of pages in this paged tile layout
|
||||||
|
*/
|
||||||
|
public int getNumPages() {
|
||||||
|
final int nTiles = mTiles.size();
|
||||||
|
// We should always have at least one page, even if it's empty.
|
||||||
|
int numPages = Math.max(nTiles / mPages.get(0).maxTiles(), 1);
|
||||||
|
|
||||||
|
// Add one more not full page if needed
|
||||||
|
if (nTiles > numPages * mPages.get(0).maxTiles()) {
|
||||||
|
numPages++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numPages;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumVisibleTiles() {
|
public int getNumVisibleTiles() {
|
||||||
if (mPages.size() == 0) return 0;
|
if (mPages.size() == 0) return 0;
|
||||||
TilePage currentPage = mPages.get(getCurrentPageNumber());
|
TilePage currentPage = mPages.get(getCurrentPageNumber());
|
||||||
|
|||||||
@@ -240,8 +240,13 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
|
||||||
if (mTileLayout instanceof PagedTileLayout) {
|
if (mTileLayout instanceof PagedTileLayout) {
|
||||||
|
// Since PageIndicator gets measured before PagedTileLayout, we preemptively set the
|
||||||
|
// # of pages before the measurement pass so PageIndicator is measured appropriately
|
||||||
|
if (mFooterPageIndicator != null) {
|
||||||
|
mFooterPageIndicator.setNumPages(((PagedTileLayout) mTileLayout).getNumPages());
|
||||||
|
}
|
||||||
|
|
||||||
// Allow the UI to be as big as it want's to, we're in a scroll view
|
// Allow the UI to be as big as it want's to, we're in a scroll view
|
||||||
int newHeight = 10000;
|
int newHeight = 10000;
|
||||||
int availableHeight = MeasureSpec.getSize(heightMeasureSpec);
|
int availableHeight = MeasureSpec.getSize(heightMeasureSpec);
|
||||||
|
|||||||
Reference in New Issue
Block a user