Add SuggestedWords.isEmpty() method

Change-Id: I0fcb104a6a81aee4b99f5ee848eba7495630dc7d
main
Tadashi G. Takaoka 2012-10-03 14:06:44 +09:00
parent 3e5a3c18be
commit c6ff7c42d9
4 changed files with 14 additions and 17 deletions

View File

@ -108,8 +108,8 @@ public final class SuggestionSpanUtils {
CharSequence pickedWord, SuggestedWords suggestedWords, boolean dictionaryAvailable) {
if (!dictionaryAvailable || TextUtils.isEmpty(pickedWord)
|| CONSTRUCTOR_SuggestionSpan == null
|| suggestedWords == null || suggestedWords.size() == 0
|| suggestedWords.mIsPrediction || suggestedWords.mIsPunctuationSuggestions
|| suggestedWords.isEmpty() || suggestedWords.mIsPrediction
|| suggestedWords.mIsPunctuationSuggestions
|| OBJ_SUGGESTIONS_MAX_SIZE == null) {
return pickedWord;
}

View File

@ -1518,8 +1518,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
final boolean dismissGestureFloatingPreviewText) {
final String batchInputText = (suggestedWords.size() > 0)
? suggestedWords.getWord(0) : null;
final String batchInputText = suggestedWords.isEmpty()
? null : suggestedWords.getWord(0);
final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
mainKeyboardView.showGestureFloatingPreviewText(batchInputText);
showSuggestionStrip(suggestedWords, null);
@ -1537,8 +1537,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
public void onEndBatchInput(final InputPointers batchPointers) {
final SuggestedWords suggestedWords = BatchInputUpdater.getInstance().onEndBatchInput(
batchPointers, this);
final String batchInputText = (suggestedWords.size() > 0)
? suggestedWords.getWord(0) : null;
final String batchInputText = suggestedWords.isEmpty()
? null : suggestedWords.getWord(0);
if (TextUtils.isEmpty(batchInputText)) {
return;
}
@ -1963,19 +1963,15 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private void showSuggestionStrip(final SuggestedWords suggestedWords,
final CharSequence typedWord) {
if (null == suggestedWords || suggestedWords.size() <= 0) {
if (suggestedWords.isEmpty()) {
clearSuggestionStrip();
return;
}
final CharSequence autoCorrection;
if (suggestedWords.size() > 0) {
if (suggestedWords.mWillAutoCorrect) {
autoCorrection = suggestedWords.getWord(1);
} else {
autoCorrection = typedWord;
}
if (suggestedWords.mWillAutoCorrect) {
autoCorrection = suggestedWords.getWord(1);
} else {
autoCorrection = null;
autoCorrection = typedWord;
}
mWordComposer.setAutoCorrection(autoCorrection);
final boolean isAutoCorrection = suggestedWords.willAutoCorrect();

View File

@ -53,6 +53,10 @@ public final class SuggestedWords {
mIsPrediction = isPrediction;
}
public boolean isEmpty() {
return mSuggestedWordInfoList.isEmpty();
}
public int size() {
return mSuggestedWordInfoList.size();
}

View File

@ -672,9 +672,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
}
public void setSuggestions(final SuggestedWords suggestedWords) {
if (suggestedWords == null)
return;
clear();
mSuggestedWords = suggestedWords;
mParams.layout(mSuggestedWords, mSuggestionsStrip, this, getWidth());