You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/10/22 21:20:03 UTC

[05/16] android commit: Prevent NPE in case webview is lately initialized (cherry picked from commit a9ebf50b86bcb9de40cbf4013e98fd1a24be25e8)

Prevent NPE in case webview is lately initialized
(cherry picked from commit a9ebf50b86bcb9de40cbf4013e98fd1a24be25e8)


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/dd770ef3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/dd770ef3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/dd770ef3

Branch: refs/heads/2.9.x
Commit: dd770ef303e8b484bfc83e8ac93d38b08f2d4ba3
Parents: 8b3fa5c
Author: denis <de...@orange.com>
Authored: Mon Jul 1 15:37:29 2013 +0800
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Oct 22 15:09:51 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaActivity.java | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd770ef3/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 95cb2f1..5c90316 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -858,8 +858,8 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         LOG.d(TAG, "Incoming Result");
         super.onActivityResult(requestCode, resultCode, intent);
         Log.d(TAG, "Request code = " + requestCode);
-        ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
-        if (requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
+        if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
+        	ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
             Log.d(TAG, "did we get here?");
             if (null == mUploadMessage)
                 return;
@@ -1079,9 +1079,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
     @Override
     public boolean onKeyUp(int keyCode, KeyEvent event)
     {
-        //Get whatever has focus!
-        View childView = appView.getFocusedChild();
-        if ((appView.isCustomViewShowing() || childView != null ) &&
+        if (appView != null && (appView.isCustomViewShowing() || appView.getFocusedChild() != null ) &&
                 (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
             return appView.onKeyUp(keyCode, event);
         } else {
@@ -1099,10 +1097,8 @@ public class CordovaActivity extends Activity implements CordovaInterface {
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event)
     {
-        //Get whatever has focus!
-        View childView = appView.getFocusedChild();
         //Determine if the focus is on the current view or not
-        if (childView != null && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
+        if (appView != null && appView.getFocusedChild() != null && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
                     return appView.onKeyDown(keyCode, event);
         }
         else