closed #5188, fixed android NULL pointer exception

This commit is contained in:
andyque 2014-05-15 12:02:42 +08:00
parent 67f809e223
commit fc8d286fcb
1 changed files with 19 additions and 14 deletions

View File

@ -123,6 +123,7 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe
public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) {
if (this.mCocos2dxGLSurfaceView.getCocos2dxEditText() == pTextView && this.isFullScreenEdit()) {
// user press the action button, delete all old text and insert new text
if (null != mOriginText) {
for (int i = this.mOriginText.length(); i > 0; i--) {
this.mCocos2dxGLSurfaceView.deleteBackward();
/*
@ -131,8 +132,11 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe
}
*/
}
}
String text = pTextView.getText().toString();
if (text != null) {
/* If user input nothing, translate "\n" to engine. */
if ( text.compareTo("") == 0) {
text = "\n";
@ -141,6 +145,7 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe
if ( '\n' != text.charAt(text.length() - 1)) {
text += '\n';
}
}
final String insertText = text;
this.mCocos2dxGLSurfaceView.insertText(insertText);