Bug 788106 - Band-aid ArrayIndexOutOfBoundsException. r=bnicholson
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 20 Nov 2012 20:28:35 -0500
changeset 113857 296a47893d907bb3e1af16fe4b1155379826d89f
parent 113856 33493f12809d82cc8488a9a75619f03e750b5c0c
child 113858 cea5c31daab96fb1887541c9a8e6bfe28b5848fc
push id23891
push useremorley@mozilla.com
push dateWed, 21 Nov 2012 15:30:36 +0000
treeherdermozilla-central@905492e644e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson
bugs788106
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 788106 - Band-aid ArrayIndexOutOfBoundsException. r=bnicholson
mobile/android/base/FontSizePreference.java
--- a/mobile/android/base/FontSizePreference.java
+++ b/mobile/android/base/FontSizePreference.java
@@ -76,27 +76,29 @@ class FontSizePreference extends DialogP
         mScrollingContainer.setBackgroundColor(Color.WHITE);
         mPreviewFontView = (TextView) dialogView.findViewById(R.id.preview);
 
         mDecreaseFontButton = (Button) dialogView.findViewById(R.id.decrease_preview_font_button);
         mIncreaseFontButton = (Button) dialogView.findViewById(R.id.increase_preview_font_button);
         setButtonState(mPreviewFontIndex);
         mDecreaseFontButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
-                updatePreviewFontSize(mFontTwipValues[--mPreviewFontIndex]);
+                mPreviewFontIndex = Math.max(mPreviewFontIndex - 1, 0);
+                updatePreviewFontSize(mFontTwipValues[mPreviewFontIndex]);
                 mIncreaseFontButton.setEnabled(true);
                 // If we reached the minimum index, disable the button.
                 if (mPreviewFontIndex == 0) {
                     mDecreaseFontButton.setEnabled(false);
                 }
             }
         });
         mIncreaseFontButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
-                updatePreviewFontSize(mFontTwipValues[++mPreviewFontIndex]);
+                mPreviewFontIndex = Math.min(mPreviewFontIndex + 1, mFontTwipValues.length - 1);
+                updatePreviewFontSize(mFontTwipValues[mPreviewFontIndex]);
 
                 mDecreaseFontButton.setEnabled(true);
                 // If we reached the maximum index, disable the button.
                 if (mPreviewFontIndex == mFontTwipValues.length - 1) {
                     mIncreaseFontButton.setEnabled(false);
                 }
             }
         });