Merge "QS: Fix crash when removing pages in RTL" into nyc-dev

This commit is contained in:
Jason Monk
2016-06-09 15:25:00 +00:00
committed by Android (Google) Code Review

View File

@@ -109,18 +109,18 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
if (mListening) { if (mListening) {
if (mPosition != position) { if (mPosition != position) {
// Clear out the last pages from listening. // Clear out the last pages from listening.
mPages.get(mPosition).setListening(false); setPageListening(mPosition, false);
if (mOffPage) { if (mOffPage) {
mPages.get(mPosition + 1).setListening(false); setPageListening(mPosition + 1, false);
} }
// Set the new pages to listening // Set the new pages to listening
mPages.get(position).setListening(true); setPageListening(position, true);
if (offPage) { if (offPage) {
mPages.get(position + 1).setListening(true); setPageListening(position + 1, true);
} }
} else if (mOffPage != offPage) { } else if (mOffPage != offPage) {
// Whether we are showing position + 1 has changed. // Whether we are showing position + 1 has changed.
mPages.get(mPosition + 1).setListening(offPage); setPageListening(mPosition + 1, offPage);
} }
} }
// Save the current state. // Save the current state.
@@ -128,6 +128,11 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
mOffPage = offPage; mOffPage = offPage;
} }
private void setPageListening(int position, boolean listening) {
if (position >= mPages.size()) return;
mPages.get(position).setListening(listening);
}
@Override @Override
public boolean hasOverlappingRendering() { public boolean hasOverlappingRendering() {
return false; return false;