Optimization

This is much faster. It doesn't create messages, it doesn't post
stuff in a queue, it doesn't delay execution of other messages.
Also, it decouples the timer from the functionality of the Handler
so this can be pulled up in another change to consolidate with
mLastKeyTime or so.

Change-Id: I9044fc031373e66b9b40eee8025633613d0945dc
main
Jean Chalard 2012-06-08 22:36:17 +09:00
parent 72b358aa90
commit c7564a787e
1 changed files with 5 additions and 5 deletions

View File

@ -179,7 +179,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> {
private static final int MSG_UPDATE_SHIFT_STATE = 1;
private static final int MSG_SPACE_TYPED = 4;
private static final int MSG_SET_BIGRAM_PREDICTIONS = 5;
private static final int MSG_PENDING_IMS_CALLBACK = 6;
private static final int MSG_UPDATE_SUGGESTIONS = 7;
@ -187,6 +186,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private int mDelayUpdateSuggestions;
private int mDelayUpdateShiftState;
private long mDoubleSpacesTurnIntoPeriodTimeout;
private long mDoubleSpaceTimerStart;
public UIHandler(LatinIME outerInstance) {
super(outerInstance);
@ -251,16 +251,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
public void startDoubleSpacesTimer() {
removeMessages(MSG_SPACE_TYPED);
sendMessageDelayed(obtainMessage(MSG_SPACE_TYPED), mDoubleSpacesTurnIntoPeriodTimeout);
mDoubleSpaceTimerStart = SystemClock.uptimeMillis();
}
public void cancelDoubleSpacesTimer() {
removeMessages(MSG_SPACE_TYPED);
mDoubleSpaceTimerStart = 0;
}
public boolean isAcceptingDoubleSpaces() {
return hasMessages(MSG_SPACE_TYPED);
return SystemClock.uptimeMillis() - mDoubleSpaceTimerStart
< mDoubleSpacesTurnIntoPeriodTimeout;
}
// Working variables for the following methods.