Merge "Fix a native crash"
This commit is contained in:
commit
08baf5ff8e
2 changed files with 12 additions and 2 deletions
|
@ -574,8 +574,13 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
|||
// The getXYForCodePointAndScript method returns (Y << 16) + X
|
||||
final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
|
||||
codePoint, mScript);
|
||||
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
|
||||
composer.add(codePoint, WordComposer.NOT_A_COORDINATE,
|
||||
WordComposer.NOT_A_COORDINATE, null);
|
||||
} else {
|
||||
composer.add(codePoint, xy & 0xFFFF, xy >> 16, null);
|
||||
}
|
||||
}
|
||||
|
||||
final int capitalizeType = getCapitalizationType(text);
|
||||
boolean isInDict = true;
|
||||
|
|
|
@ -35,6 +35,9 @@ public class SpellCheckerProximityInfo {
|
|||
// The number of rows in the grid used by the spell checker.
|
||||
final public static int PROXIMITY_GRID_HEIGHT = 3;
|
||||
|
||||
final private static int NOT_AN_INDEX = -1;
|
||||
final public static int NOT_A_COORDINATE_PAIR = -1;
|
||||
|
||||
// Helper methods
|
||||
final protected static void buildProximityIndices(final int[] proximity,
|
||||
final TreeMap<Integer, Integer> indices) {
|
||||
|
@ -45,7 +48,7 @@ public class SpellCheckerProximityInfo {
|
|||
final protected static int computeIndex(final int characterCode,
|
||||
final TreeMap<Integer, Integer> indices) {
|
||||
final Integer result = indices.get(characterCode);
|
||||
if (null == result) return -1;
|
||||
if (null == result) return NOT_AN_INDEX;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -196,8 +199,10 @@ public class SpellCheckerProximityInfo {
|
|||
// Returns (Y << 16) + X to avoid creating a temporary object. This is okay because
|
||||
// X and Y are limited to PROXIMITY_GRID_WIDTH resp. PROXIMITY_GRID_HEIGHT which is very
|
||||
// inferior to 1 << 16
|
||||
// As an exception, this returns NOT_A_COORDINATE_PAIR if the key is not on the grid
|
||||
public static int getXYForCodePointAndScript(final int codePoint, final int script) {
|
||||
final int index = getIndexOfCodeForScript(codePoint, script);
|
||||
if (NOT_AN_INDEX == index) return NOT_A_COORDINATE_PAIR;
|
||||
final int y = index / PROXIMITY_GRID_WIDTH;
|
||||
final int x = index % PROXIMITY_GRID_WIDTH;
|
||||
if (y > PROXIMITY_GRID_HEIGHT) {
|
||||
|
|
Loading…
Reference in a new issue