Fix NPE in LatinKeyboard
Bug: 4727778 Change-Id: I9d5b7185d75408a8af6d302fb348e118c0f9721e
This commit is contained in:
parent
cdc12db404
commit
05c0fc6136
1 changed files with 12 additions and 6 deletions
|
@ -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) {
|
||||||
(int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO));
|
final int slidingIconWidth = Math.max(mSpaceKey.mWidth,
|
||||||
final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight();
|
(int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO));
|
||||||
mSlidingLocaleIcon = new SlidingLocaleDrawable(
|
final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight();
|
||||||
context, mSpacePreviewIcon, spaceKeyWidth, spaceKeyheight);
|
mSlidingLocaleIcon = new SlidingLocaleDrawable(
|
||||||
mSlidingLocaleIcon.setBounds(0, 0, spaceKeyWidth, spaceKeyheight);
|
context, mSpacePreviewIcon, slidingIconWidth, 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);
|
||||||
|
|
Loading…
Reference in a new issue