diff options
author | Michael Kolb <kolby@google.com> | 2011-03-08 11:45:40 -0800 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2011-03-08 11:45:46 -0800 |
commit | dfe99a1ad8fa39277b0b8279f42e4380db4bf674 (patch) | |
tree | cbb8d9e358398cc6fc0adaa6a63f59ed5472a8b2 | |
parent | 637af7a41cf184f39c701f995aa02ead075ca013 (diff) | |
download | packages_apps_Browser-dfe99a1ad8fa39277b0b8279f42e4380db4bf674.zip packages_apps_Browser-dfe99a1ad8fa39277b0b8279f42e4380db4bf674.tar.gz packages_apps_Browser-dfe99a1ad8fa39277b0b8279f42e4380db4bf674.tar.bz2 |
fix NPE in dispatchKeyEvents
Bug: 3514737
Change-Id: I38e448c32c9591004e422627125f9d05db5f8083
-rw-r--r-- | src/com/android/browser/XLargeUi.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index 371e649..8c39f16 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -460,22 +460,23 @@ public class XLargeUi extends BaseUi implements ScrollListener { @Override public boolean dispatchKey(int code, KeyEvent event) { - WebView web = getActiveTab().getWebView(); - if (event.getAction() == KeyEvent.ACTION_DOWN) { - - switch (code) { - case KeyEvent.KEYCODE_TAB: - case KeyEvent.KEYCODE_DPAD_UP: - case KeyEvent.KEYCODE_DPAD_LEFT: - if ((web != null) && web.hasFocus() && !mTitleBar.hasFocus()) { - editUrl(false); - return true; - } - } - boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON); - if (!ctrl && isTypingKey(event) && !mTitleBar.isEditingUrl()) { - editUrl(true); - return mContentView.dispatchKeyEvent(event); + if (mActiveTab != null) { + WebView web = mActiveTab.getWebView(); + if (event.getAction() == KeyEvent.ACTION_DOWN) { + switch (code) { + case KeyEvent.KEYCODE_TAB: + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_LEFT: + if ((web != null) && web.hasFocus() && !mTitleBar.hasFocus()) { + editUrl(false); + return true; + } + } + boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON); + if (!ctrl && isTypingKey(event) && !mTitleBar.isEditingUrl()) { + editUrl(true); + return mContentView.dispatchKeyEvent(event); + } } } return false; |