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
This commit is contained in:
parent
72b358aa90
commit
c7564a787e
1 changed files with 5 additions and 5 deletions
|
@ -179,7 +179,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> {
|
public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> {
|
||||||
private static final int MSG_UPDATE_SHIFT_STATE = 1;
|
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_SET_BIGRAM_PREDICTIONS = 5;
|
||||||
private static final int MSG_PENDING_IMS_CALLBACK = 6;
|
private static final int MSG_PENDING_IMS_CALLBACK = 6;
|
||||||
private static final int MSG_UPDATE_SUGGESTIONS = 7;
|
private static final int MSG_UPDATE_SUGGESTIONS = 7;
|
||||||
|
@ -187,6 +186,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private int mDelayUpdateSuggestions;
|
private int mDelayUpdateSuggestions;
|
||||||
private int mDelayUpdateShiftState;
|
private int mDelayUpdateShiftState;
|
||||||
private long mDoubleSpacesTurnIntoPeriodTimeout;
|
private long mDoubleSpacesTurnIntoPeriodTimeout;
|
||||||
|
private long mDoubleSpaceTimerStart;
|
||||||
|
|
||||||
public UIHandler(LatinIME outerInstance) {
|
public UIHandler(LatinIME outerInstance) {
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
|
@ -251,16 +251,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startDoubleSpacesTimer() {
|
public void startDoubleSpacesTimer() {
|
||||||
removeMessages(MSG_SPACE_TYPED);
|
mDoubleSpaceTimerStart = SystemClock.uptimeMillis();
|
||||||
sendMessageDelayed(obtainMessage(MSG_SPACE_TYPED), mDoubleSpacesTurnIntoPeriodTimeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelDoubleSpacesTimer() {
|
public void cancelDoubleSpacesTimer() {
|
||||||
removeMessages(MSG_SPACE_TYPED);
|
mDoubleSpaceTimerStart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAcceptingDoubleSpaces() {
|
public boolean isAcceptingDoubleSpaces() {
|
||||||
return hasMessages(MSG_SPACE_TYPED);
|
return SystemClock.uptimeMillis() - mDoubleSpaceTimerStart
|
||||||
|
< mDoubleSpacesTurnIntoPeriodTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working variables for the following methods.
|
// Working variables for the following methods.
|
||||||
|
|
Loading…
Reference in a new issue