summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/textservice
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-11-03 04:12:51 +0900
committersatok <satok@google.com>2011-11-10 11:50:45 +0900
commitb4aff97c85e730857893742f73a082f6b8d139ca (patch)
tree6def3a6e5f783274d3a72e28cd940722a2adb18d /core/java/android/view/textservice
parent76bb11ca642556673249a6ef8b84ab2813deaa87 (diff)
downloadframeworks_base-b4aff97c85e730857893742f73a082f6b8d139ca.zip
frameworks_base-b4aff97c85e730857893742f73a082f6b8d139ca.tar.gz
frameworks_base-b4aff97c85e730857893742f73a082f6b8d139ca.tar.bz2
Introduce an API to cancel pending/running spell check tasks
Bug: 5554629 Change-Id: Ifd840ea13976813639a2ee259124a21d9bb56893
Diffstat (limited to 'core/java/android/view/textservice')
-rw-r--r--core/java/android/view/textservice/SpellCheckerSession.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java
index 01b114c..0eb6e27 100644
--- a/core/java/android/view/textservice/SpellCheckerSession.java
+++ b/core/java/android/view/textservice/SpellCheckerSession.java
@@ -146,6 +146,13 @@ public class SpellCheckerSession {
}
/**
+ * Cancel pending and running spell check tasks
+ */
+ public void cancel() {
+ mSpellCheckerSessionListenerImpl.cancel();
+ }
+
+ /**
* Finish this session and allow TextServicesManagerService to disconnect the bound spell
* checker.
*/
@@ -242,6 +249,13 @@ public class SpellCheckerSession {
}
}
+ public void cancel() {
+ if (DBG) {
+ Log.w(TAG, "cancel");
+ }
+ processOrEnqueueTask(new SpellCheckerParams(TASK_CANCEL, null, 0, false));
+ }
+
public void getSuggestionsMultiple(
TextInfo[] textInfos, int suggestionsLimit, boolean sequentialWords) {
if (DBG) {
@@ -275,8 +289,22 @@ public class SpellCheckerSession {
if (DBG) {
Log.d(TAG, "process or enqueue task: " + mISpellCheckerSession);
}
+ SpellCheckerParams closeTask = null;
if (mISpellCheckerSession == null) {
+ if (scp.mWhat == TASK_CANCEL) {
+ while (!mPendingTasks.isEmpty()) {
+ final SpellCheckerParams tmp = mPendingTasks.poll();
+ if (tmp.mWhat == TASK_CLOSE) {
+ // Only one close task should be processed, while we need to remove all
+ // close tasks from the queue
+ closeTask = tmp;
+ }
+ }
+ }
mPendingTasks.offer(scp);
+ if (closeTask != null) {
+ mPendingTasks.offer(closeTask);
+ }
} else {
processTask(scp);
}