jenkins-bot has submitted this change and it was merged.
Change subject: Fix/improve Bridge uninitialization.
..
Fix/improve Bridge uninitialization.
It looks like removeJavascriptInterface and setWebChromeClient(null) were
not necessary, and were actually causing some strange behavior.
Change-Id: I5d0e14eb2bf552bfdc306c04985a9d6dc8740912
---
M wikipedia/src/main/java/org/wikipedia/bridge/CommunicationBridge.java
1 file changed, 13 insertions(+), 10 deletions(-)
Approvals:
BearND: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/wikipedia/src/main/java/org/wikipedia/bridge/CommunicationBridge.java
b/wikipedia/src/main/java/org/wikipedia/bridge/CommunicationBridge.java
index d302eba..5c9a1cc 100644
--- a/wikipedia/src/main/java/org/wikipedia/bridge/CommunicationBridge.java
+++ b/wikipedia/src/main/java/org/wikipedia/bridge/CommunicationBridge.java
@@ -1,6 +1,5 @@
package org.wikipedia.bridge;
-import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -59,12 +58,11 @@
}
public void cleanup() {
-if (Build.VERSION.SDK_INT = Build.VERSION_CODES.HONEYCOMB) {
-webView.removeJavascriptInterface(marshaller);
-}
-webView.setWebChromeClient(null);
eventListeners.clear();
-incomingMessageHandler.removeCallbacksAndMessages(null);
+if (incomingMessageHandler != null) {
+incomingMessageHandler.removeCallbacksAndMessages(null);
+incomingMessageHandler = null;
+}
}
public void addListener(String type, JSEventListener listener) {
@@ -122,15 +120,20 @@
@Override
public boolean onJsPrompt(WebView view, String url, String message,
String defaultValue, JsPromptResult result) {
try {
-JSONObject messagePack = new
JSONObject(URLDecoder.decode(message, utf-8));
-Message msg = Message.obtain(incomingMessageHandler,
MESSAGE_HANDLE_MESSAGE_FROM_JS, messagePack);
-incomingMessageHandler.sendMessage(msg);
-result.confirm();
+// If incomingMessageHandler is null, it means that we've been
cleaned up, but we're
+// still receiving some final messages from the WebView, so
we'll just ignore them.
+// But we should still return true and confirm the
JsPromptResult down below.
+if (incomingMessageHandler != null) {
+JSONObject messagePack = new
JSONObject(URLDecoder.decode(message, utf-8));
+Message msg = Message.obtain(incomingMessageHandler,
MESSAGE_HANDLE_MESSAGE_FROM_JS, messagePack);
+incomingMessageHandler.sendMessage(msg);
+}
} catch (JSONException e) {
throw new RuntimeException(e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
+result.confirm();
return true;
}
--
To view, visit https://gerrit.wikimedia.org/r/167208
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5d0e14eb2bf552bfdc306c04985a9d6dc8740912
Gerrit-PatchSet: 3
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant dbr...@wikimedia.org
Gerrit-Reviewer: BearND bsitzm...@wikimedia.org
Gerrit-Reviewer: Brion VIBBER br...@wikimedia.org
Gerrit-Reviewer: jenkins-bot
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits