Permalink
Browse files

Workaround for a race condition in EditText implementation. Fixes #67.

  • Loading branch information...
1 parent 5d68a5e commit 35b896c3d6e9d222a68c36c999e002c55a36c3f4 @pocmo committed Apr 12, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 application/src/org/yaaic/activity/ConversationActivity.java
@@ -65,6 +65,7 @@
import android.speech.RecognizerIntent;
import android.support.v4.view.ViewPager;
import android.text.InputType;
+import android.text.method.TextKeyListener;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
@@ -119,7 +120,7 @@
private boolean reconnectDialogActive = false;
- OnKeyListener inputKeyListener = new OnKeyListener() {
+ private final OnKeyListener inputKeyListener = new OnKeyListener() {
/**
* On key pressed (input line)
*/
@@ -150,7 +151,14 @@ public boolean onKey(View view, int keyCode, KeyEvent event)
if (keyCode == KeyEvent.KEYCODE_ENTER) {
sendMessage(input.getText().toString());
- input.setText("");
+
+ // Workaround for a race condition in EditText
+ // Instead of calling input.setText("");
+ // See:
+ // - https://github.com/pocmo/Yaaic/issues/67
+ // - http://code.google.com/p/android/issues/detail?id=17508
+ TextKeyListener.clear(input.getText());
+
return true;
}

0 comments on commit 35b896c

Please sign in to comment.