aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-10-20 14:48:56 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-10-21 19:28:37 +0900
commit5f00fe09e9a611b647592188316e5999465df4d3 (patch)
tree954a429256171897c7b9ed56a732e386eec76b2b /java/src/com/android/inputmethod/latin/spellcheck/SentenceLevelAdapter.java
parentfa1e65cb3a5dcce6299a6dd067cee95720107307 (diff)
downloadlatinime-5f00fe09e9a611b647592188316e5999465df4d3.tar.gz
latinime-5f00fe09e9a611b647592188316e5999465df4d3.tar.xz
latinime-5f00fe09e9a611b647592188316e5999465df4d3.zip
Fix some compiler warnings
This CL fixes the following compiler warnings. - Indirect access to static member - Access to a non-accessible member of an enclosing type - Parameter assignment - Method can be static - Local variable declaration hides another field or variable - Value of local variable is not used - Unused import - Unused private member - Unnecessary 'else' statement - Unnecessary declaration of throw exception - Redundant type arguments - Missing '@Override' annotation - Unused '@SuppressWarning' annotations Bug: 18003991 Change-Id: Icfebe753e53a2cc621848f769d6a3d7ce501ebc7
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) {