am 1502d977: am 12e77de2: Merge "Use private lock object instead of synchronized method"
* commit '1502d9779555958b0ca147fda1cab1e6302c9035': Use private lock object instead of synchronized methodmain
commit
4516304436
|
@ -1551,7 +1551,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
private static final class BatchInputUpdater implements Handler.Callback {
|
||||
private final Handler mHandler;
|
||||
private LatinIME mLatinIme;
|
||||
private boolean mInBatchInput; // synchronized using "this".
|
||||
private final Object mLock = new Object();
|
||||
private boolean mInBatchInput; // synchronized using {@link #mLock}.
|
||||
|
||||
private BatchInputUpdater() {
|
||||
final HandlerThread handlerThread = new HandlerThread(
|
||||
|
@ -1582,14 +1583,17 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
}
|
||||
|
||||
// Run in the UI thread.
|
||||
public synchronized void onStartBatchInput(final LatinIME latinIme) {
|
||||
public void onStartBatchInput(final LatinIME latinIme) {
|
||||
synchronized (mLock) {
|
||||
mHandler.removeMessages(MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP);
|
||||
mLatinIme = latinIme;
|
||||
mInBatchInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Run in the Handler thread.
|
||||
private synchronized void updateBatchInput(final InputPointers batchPointers) {
|
||||
private void updateBatchInput(final InputPointers batchPointers) {
|
||||
synchronized (mLock) {
|
||||
if (!mInBatchInput) {
|
||||
// Batch input has ended or canceled while the message was being delivered.
|
||||
return;
|
||||
|
@ -1598,6 +1602,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
mLatinIme.mHandler.showGesturePreviewAndSuggestionStrip(
|
||||
suggestedWords, false /* dismissGestureFloatingPreviewText */);
|
||||
}
|
||||
}
|
||||
|
||||
// Run in the UI thread.
|
||||
public void onUpdateBatchInput(final InputPointers batchPointers) {
|
||||
|
@ -1609,20 +1614,24 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
.sendToTarget();
|
||||
}
|
||||
|
||||
public synchronized void onCancelBatchInput() {
|
||||
public void onCancelBatchInput() {
|
||||
synchronized (mLock) {
|
||||
mInBatchInput = false;
|
||||
mLatinIme.mHandler.showGesturePreviewAndSuggestionStrip(
|
||||
SuggestedWords.EMPTY, true /* dismissGestureFloatingPreviewText */);
|
||||
}
|
||||
}
|
||||
|
||||
// Run in the UI thread.
|
||||
public synchronized SuggestedWords onEndBatchInput(final InputPointers batchPointers) {
|
||||
public SuggestedWords onEndBatchInput(final InputPointers batchPointers) {
|
||||
synchronized (mLock) {
|
||||
mInBatchInput = false;
|
||||
final SuggestedWords suggestedWords = getSuggestedWordsGestureLocked(batchPointers);
|
||||
mLatinIme.mHandler.showGesturePreviewAndSuggestionStrip(
|
||||
suggestedWords, true /* dismissGestureFloatingPreviewText */);
|
||||
return suggestedWords;
|
||||
}
|
||||
}
|
||||
|
||||
// {@link LatinIME#getSuggestedWords(int)} method calls with same session id have to
|
||||
// be synchronized.
|
||||
|
|
Loading…
Reference in New Issue