Simplification (A56)
If suggestion and prediction messages both happen to be in the queue, the latest one will win (update the suggestion strip later than the other, overwriting any previous suggestions). So when we enqueue either one, it is always safe to cancel all messages of both types. Change-Id: Iad9dd06d08c49f60cac16b88edcc9531a18ec02emain
parent
414f14436e
commit
d81e7d24d3
|
@ -218,12 +218,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postUpdateSuggestions() {
|
public void postUpdateSuggestions() {
|
||||||
removeMessages(MSG_UPDATE_SUGGESTIONS);
|
cancelUpdateSuggestionStrip();
|
||||||
sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTIONS), mDelayUpdateSuggestions);
|
sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTIONS), mDelayUpdateSuggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelUpdateSuggestions() {
|
public void cancelUpdateSuggestionStrip() {
|
||||||
removeMessages(MSG_UPDATE_SUGGESTIONS);
|
removeMessages(MSG_UPDATE_SUGGESTIONS);
|
||||||
|
removeMessages(MSG_SET_BIGRAM_PREDICTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPendingUpdateSuggestions() {
|
public boolean hasPendingUpdateSuggestions() {
|
||||||
|
@ -240,14 +241,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postUpdateBigramPredictions() {
|
public void postUpdateBigramPredictions() {
|
||||||
removeMessages(MSG_SET_BIGRAM_PREDICTIONS);
|
cancelUpdateSuggestionStrip();
|
||||||
sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), mDelayUpdateSuggestions);
|
sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), mDelayUpdateSuggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelUpdateBigramPredictions() {
|
|
||||||
removeMessages(MSG_SET_BIGRAM_PREDICTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startDoubleSpacesTimer() {
|
public void startDoubleSpacesTimer() {
|
||||||
mDoubleSpaceTimerStart = SystemClock.uptimeMillis();
|
mDoubleSpaceTimerStart = SystemClock.uptimeMillis();
|
||||||
}
|
}
|
||||||
|
@ -737,7 +734,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView != null) inputView.cancelAllMessages();
|
if (inputView != null) inputView.cancelAllMessages();
|
||||||
// Remove pending messages related to update suggestions
|
// Remove pending messages related to update suggestions
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestionStrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1547,7 +1544,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final int spaceState) {
|
final int spaceState) {
|
||||||
// Should dismiss the "Touch again to save" message when handling separator
|
// Should dismiss the "Touch again to save" message when handling separator
|
||||||
if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) {
|
if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) {
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,7 +1582,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
mHandler.startDoubleSpacesTimer();
|
mHandler.startDoubleSpacesTimer();
|
||||||
if (!mConnection.isCursorTouchingWord(mCurrentSettings)) {
|
if (!mConnection.isCursorTouchingWord(mCurrentSettings)) {
|
||||||
mHandler.cancelUpdateSuggestions();
|
|
||||||
mHandler.postUpdateBigramPredictions();
|
mHandler.postUpdateBigramPredictions();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1668,8 +1663,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSuggestionsOrPredictions(final boolean isPredictions) {
|
public void updateSuggestionsOrPredictions(final boolean isPredictions) {
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestionStrip();
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
|
||||||
|
|
||||||
// Check if we have a suggestion engine attached.
|
// Check if we have a suggestion engine attached.
|
||||||
if (mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
|
if (mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
|
||||||
|
@ -1760,7 +1754,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private void commitCurrentAutoCorrection(final int separatorCodePoint) {
|
private void commitCurrentAutoCorrection(final int separatorCodePoint) {
|
||||||
// Complete any pending suggestions query first
|
// Complete any pending suggestions query first
|
||||||
if (mHandler.hasPendingUpdateSuggestions()) {
|
if (mHandler.hasPendingUpdateSuggestions()) {
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestionStrip();
|
||||||
updateSuggestionsOrPredictions(false /* isPredictions */);
|
updateSuggestionsOrPredictions(false /* isPredictions */);
|
||||||
}
|
}
|
||||||
final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
|
final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
|
||||||
|
@ -2024,7 +2018,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// separator.
|
// separator.
|
||||||
}
|
}
|
||||||
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
|
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue