OSDN Git Service

QS: Fix crash when removing pages in RTL
authorJason Monk <jmonk@google.com>
Thu, 9 Jun 2016 13:59:56 +0000 (09:59 -0400)
committerJason Monk <jmonk@google.com>
Thu, 9 Jun 2016 13:59:56 +0000 (09:59 -0400)
Change-Id: Ic8f082a3dc61fbf12f576d4cffb8ab31e669cb7c
Fixes: 29122756

packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java

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