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,25 +123,30 @@ 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
for (int i = this.mOriginText.length(); i > 0; i--) {
this.mCocos2dxGLSurfaceView.deleteBackward();
/*
if (BuildConfig.DEBUG) {
Log.d(TAG, "deleteBackward");
if (null != mOriginText) {
for (int i = this.mOriginText.length(); i > 0; i--) {
this.mCocos2dxGLSurfaceView.deleteBackward();
/*
if (BuildConfig.DEBUG) {
Log.d(TAG, "deleteBackward");
}
*/
}
*/
}
String text = pTextView.getText().toString();
if (text != null) {
/* If user input nothing, translate "\n" to engine. */
if ( text.compareTo("") == 0) {
text = "\n";
}
/* If user input nothing, translate "\n" to engine. */
if (text.compareTo("") == 0) {
text = "\n";
if ( '\n' != text.charAt(text.length() - 1)) {
text += '\n';
}
}
if ('\n' != text.charAt(text.length() - 1)) {
text += '\n';
}
final String insertText = text;
this.mCocos2dxGLSurfaceView.insertText(insertText);
/*