UI thread check.

This commit is contained in:
James Chen 2016-05-26 12:02:23 +08:00
parent a472ab2931
commit cf883b5c0f
1 changed files with 6 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Looper;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
@ -394,6 +395,11 @@ public class Cocos2dxEditBoxHelper {
}
private static void closeKeyboardOnUiThread(int index) {
if (Looper.myLooper() != Looper.getMainLooper()) {
Log.e(TAG, "closeKeyboardOnUiThread doesn't run on UI thread!");
return;
}
final InputMethodManager imm = (InputMethodManager) mCocos2dxActivity.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
Cocos2dxEditBox editBox = mEditBoxArray.get(index);
if (null != editBox) {