Pull up a common variable into the wrapping method (A50)

Change-Id: I0b62098308169b5c44ced25ffb902766e3732fbf
main
Jean Chalard 2012-06-29 15:42:29 +09:00
parent 7ed22f1f72
commit cbfd2e1fdb
1 changed files with 10 additions and 8 deletions

View File

@ -1708,17 +1708,19 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return; return;
} }
final CharSequence typedWord;
if (isPredictions || !mWordComposer.isComposingWord()) { if (isPredictions || !mWordComposer.isComposingWord()) {
updateBigramPredictions(); typedWord = "";
updateBigramPredictions(typedWord);
} else { } else {
updateSuggestions(); typedWord = mWordComposer.getTypedWord();
updateSuggestions(typedWord);
} }
} }
private void updateSuggestions() { private void updateSuggestions(final CharSequence typedWord) {
// TODO: May need a better way of retrieving previous word // TODO: May need a better way of retrieving previous word
final CharSequence prevWord = mConnection.getPreviousWord(mCurrentSettings.mWordSeparators); final CharSequence prevWord = mConnection.getPreviousWord(mCurrentSettings.mWordSeparators);
final CharSequence typedWord = mWordComposer.getTypedWord();
// getSuggestedWords handles gracefully a null value of prevWord // getSuggestedWords handles gracefully a null value of prevWord
final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer, final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer,
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(),
@ -1925,7 +1927,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
separatorCode, prevWord); separatorCode, prevWord);
} }
private void updateBigramPredictions() { private void updateBigramPredictions(final CharSequence typedWord) {
if (!mCurrentSettings.mBigramPredictionEnabled) { if (!mCurrentSettings.mBigramPredictionEnabled) {
setPunctuationSuggestions(); setPunctuationSuggestions();
return; return;
@ -1946,9 +1948,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
if (null != suggestedWords && suggestedWords.size() > 0) { if (null != suggestedWords && suggestedWords.size() > 0) {
// Explicitly supply an empty typed word (the no-second-arg version of // Typed word is always empty. We pass it because the no-second-arg version of
// showSuggestions will retrieve the word near the cursor, we don't want that here) // showSuggestions will retrieve the word near the cursor, and we don't want that here
showSuggestions(suggestedWords, ""); showSuggestions(suggestedWords, typedWord);
} else { } else {
clearSuggestions(); clearSuggestions();
} }