Bug 788106 - Band-aid ArrayIndexOutOfBoundsException. r=bnicholson

This commit is contained in:
Michael Comella 2012-11-20 20:28:35 -05:00
parent 98856ba73e
commit c4268c1480

View File

@ -81,7 +81,8 @@ class FontSizePreference extends DialogPreference {
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) {
@ -91,7 +92,8 @@ class FontSizePreference extends DialogPreference {
});
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.