am 4e9e6cd1
: Fix IllegalStateException of KeyDetector
* commit '4e9e6cd1544f59be2ae02536af62fe5301e0cebb': Fix IllegalStateException of KeyDetector
This commit is contained in:
commit
2687b667a7
2 changed files with 7 additions and 4 deletions
|
@ -37,8 +37,9 @@ public class KeyDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboard(Keyboard keyboard, float correctionX, float correctionY) {
|
public void setKeyboard(Keyboard keyboard, float correctionX, float correctionY) {
|
||||||
if (keyboard == null)
|
if (keyboard == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
mCorrectionX = (int)correctionX;
|
mCorrectionX = (int)correctionX;
|
||||||
mCorrectionY = (int)correctionY;
|
mCorrectionY = (int)correctionY;
|
||||||
mKeyboard = keyboard;
|
mKeyboard = keyboard;
|
||||||
|
@ -58,8 +59,6 @@ public class KeyDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Keyboard getKeyboard() {
|
public Keyboard getKeyboard() {
|
||||||
if (mKeyboard == null)
|
|
||||||
throw new IllegalStateException("keyboard isn't set");
|
|
||||||
return mKeyboard;
|
return mKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,11 @@ public class MoreKeysDetector extends KeyDetector {
|
||||||
|
|
||||||
Key nearestKey = null;
|
Key nearestKey = null;
|
||||||
int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
|
int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
|
||||||
for (final Key key : getKeyboard().mKeys) {
|
final Keyboard keyboard = getKeyboard();
|
||||||
|
if (keyboard == null) {
|
||||||
|
throw new NullPointerException("Keyboard isn't set");
|
||||||
|
}
|
||||||
|
for (final Key key : keyboard.mKeys) {
|
||||||
final int dist = key.squaredDistanceToEdge(touchX, touchY);
|
final int dist = key.squaredDistanceToEdge(touchX, touchY);
|
||||||
if (dist < nearestDist) {
|
if (dist < nearestDist) {
|
||||||
nearestKey = key;
|
nearestKey = key;
|
||||||
|
|
Loading…
Reference in a new issue