aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java b/java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java
index 9ddee8629..3c9f261b9 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java
@@ -16,7 +16,9 @@
package com.android.inputmethod.latin.spellcheck;
+import android.annotation.TargetApi;
import android.content.res.Resources;
+import android.os.Build;
import android.view.textservice.SentenceSuggestionsInfo;
import android.view.textservice.SuggestionsInfo;
import android.view.textservice.TextInfo;
@@ -76,19 +78,19 @@ public class SentenceLevelAdapter {
private static class WordIterator {
private final SpacingAndPunctuations mSpacingAndPunctuations;
public WordIterator(final Resources res, final Locale locale) {
- final RunInLocale<SpacingAndPunctuations> job
- = new RunInLocale<SpacingAndPunctuations>() {
+ final RunInLocale<SpacingAndPunctuations> job =
+ new RunInLocale<SpacingAndPunctuations>() {
@Override
- protected SpacingAndPunctuations job(final Resources res) {
- return new SpacingAndPunctuations(res);
+ protected SpacingAndPunctuations job(final Resources r) {
+ return new SpacingAndPunctuations(r);
}
};
mSpacingAndPunctuations = job.runInLocale(res, locale);
}
- public int getEndOfWord(final CharSequence sequence, int index) {
+ public int getEndOfWord(final CharSequence sequence, final int fromIndex) {
final int length = sequence.length();
- index = index < 0 ? 0 : Character.offsetByCodePoints(sequence, index, 1);
+ int index = fromIndex < 0 ? 0 : Character.offsetByCodePoints(sequence, fromIndex, 1);
while (index < length) {
final int codePoint = Character.codePointAt(sequence, index);
if (mSpacingAndPunctuations.isWordSeparator(codePoint)) {
@@ -111,12 +113,12 @@ public class SentenceLevelAdapter {
return index;
}
- public int getBeginningOfNextWord(final CharSequence sequence, int index) {
+ public int getBeginningOfNextWord(final CharSequence sequence, final int fromIndex) {
final int length = sequence.length();
- if (index >= length) {
+ if (fromIndex >= length) {
return -1;
}
- index = index < 0 ? 0 : Character.offsetByCodePoints(sequence, index, 1);
+ int index = fromIndex < 0 ? 0 : Character.offsetByCodePoints(sequence, fromIndex, 1);
while (index < length) {
final int codePoint = Character.codePointAt(sequence, index);
if (!mSpacingAndPunctuations.isWordSeparator(codePoint)) {
@@ -140,7 +142,7 @@ public class SentenceLevelAdapter {
final int cookie = originalTextInfo.getCookie();
final int start = -1;
final int end = originalText.length();
- final ArrayList<SentenceWordItem> wordItems = new ArrayList<SentenceWordItem>();
+ final ArrayList<SentenceWordItem> wordItems = new ArrayList<>();
int wordStart = wordIterator.getBeginningOfNextWord(originalText, start);
int wordEnd = wordIterator.getEndOfWord(originalText, wordStart);
while (wordStart <= end && wordEnd != -1 && wordStart != -1) {
@@ -158,6 +160,7 @@ public class SentenceLevelAdapter {
return new SentenceTextInfoParams(originalTextInfo, wordItems);
}
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static SentenceSuggestionsInfo reconstructSuggestions(
SentenceTextInfoParams originalTextInfoParams, SuggestionsInfo[] results) {
if (results == null || results.length == 0) {