Fix NPE in LatinKeyboard

Bug: 4727778
Change-Id: I9d5b7185d75408a8af6d302fb348e118c0f9721e
This commit is contained in:
Tadashi G. Takaoka 2011-06-21 10:06:45 +09:00
parent cdc12db404
commit 05c0fc6136

View file

@ -136,12 +136,16 @@ public class LatinKeyboard extends Keyboard {
// The threshold is "key width" x 1.25 // The threshold is "key width" x 1.25
mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4; mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4;
final int spaceKeyWidth = Math.max(mSpaceKey.mWidth, if (mSpaceKey != null) {
final int slidingIconWidth = Math.max(mSpaceKey.mWidth,
(int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO)); (int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO));
final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight(); final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight();
mSlidingLocaleIcon = new SlidingLocaleDrawable( mSlidingLocaleIcon = new SlidingLocaleDrawable(
context, mSpacePreviewIcon, spaceKeyWidth, spaceKeyheight); context, mSpacePreviewIcon, slidingIconWidth, spaceKeyheight);
mSlidingLocaleIcon.setBounds(0, 0, spaceKeyWidth, spaceKeyheight); mSlidingLocaleIcon.setBounds(0, 0, slidingIconWidth, spaceKeyheight);
} else {
mSlidingLocaleIcon = null;
}
} }
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardView view) { public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardView view) {
@ -350,6 +354,8 @@ public class LatinKeyboard extends Keyboard {
if (mSpacebarSlidingLanguageSwitchDiff == diff) if (mSpacebarSlidingLanguageSwitchDiff == diff)
return; return;
mSpacebarSlidingLanguageSwitchDiff = diff; mSpacebarSlidingLanguageSwitchDiff = diff;
if (mSlidingLocaleIcon == null)
return;
mSlidingLocaleIcon.setDiff(diff); mSlidingLocaleIcon.setDiff(diff);
if (Math.abs(diff) == Integer.MAX_VALUE) { if (Math.abs(diff) == Integer.MAX_VALUE) {
mSpaceKey.setPreviewIcon(mSpacePreviewIcon); mSpaceKey.setPreviewIcon(mSpacePreviewIcon);