Skip to content

Commit 5b51def

Browse files
committed
remove blocking queue
1 parent a1d482a commit 5b51def

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Android/Example/res/raw/WebViewJavascriptBridge.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
function _handleMessageFromJava(messageJSON) {
7676
_dispatchMessageFromJava(messageJSON)
7777
}
78-
78+
/*
7979
function _getNewMessageFromJava(){
8080
var messageJSON=null;
8181
while(messageJSON=_WebViewJavascriptBridge._getQueuedMessage()){
@@ -84,15 +84,15 @@
8484
console.log("finish");
8585
}
8686
}
87-
87+
*/
8888
//export
8989
window.WebViewJavascriptBridge = {
9090
init: init,
9191
send: send,
9292
registerHandler: registerHandler,
9393
callHandler: callHandler,
94-
_handleMessageFromJava: _handleMessageFromJava,
95-
_getNewMessageFromJava:_getNewMessageFromJava
94+
_handleMessageFromJava: _handleMessageFromJava
95+
// _getNewMessageFromJava:_getNewMessageFromJava
9696
}
9797

9898
//dispatch event

Android/Example/src/com/fangjian/WebViewJavascriptBridge.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class WebViewJavascriptBridge {
2828
Map<String,WVJBHandler> _messageHandlers;
2929
Map<String,WVJBResponseCallback> _responseCallbacks;
3030
long _uniqueId;
31-
BlockingQueue<String> _messageQueue;
31+
// BlockingQueue<String> _messageQueue;
3232

3333
public WebViewJavascriptBridge(Context context,WebView webview,WVJBHandler handler) {
3434
this.mContext=context;
@@ -37,7 +37,7 @@ public WebViewJavascriptBridge(Context context,WebView webview,WVJBHandler handl
3737
_messageHandlers=new HashMap<String,WVJBHandler>();
3838
_responseCallbacks=new HashMap<String, WVJBResponseCallback>();
3939
_uniqueId=0;
40-
_messageQueue=new LinkedBlockingQueue<String>();
40+
// _messageQueue=new LinkedBlockingQueue<String>();
4141
WebSettings webSettings = mWebView.getSettings();
4242
webSettings.setJavaScriptEnabled(true);
4343
mWebView.addJavascriptInterface(this, "_WebViewJavascriptBridge");
@@ -166,9 +166,9 @@ private void _sendData(String data,WVJBResponseCallback responseCallback,String
166166
if (null!=handlerName) {
167167
message.put("handlerName", handlerName);
168168
}
169-
_queueMessage(message);
169+
_dispatchMessage(message);
170170
}
171-
171+
/*
172172
private void _queueMessage(Map<String, String> message) {
173173
String messageJSON = new JSONObject(message).toString();
174174
try {
@@ -190,7 +190,7 @@ private void _notifyNewMessage() {
190190
"javascript:WebViewJavascriptBridge._getNewMessageFromJava();";
191191
mWebView.loadUrl(javascriptCommand);
192192
}
193-
193+
*/
194194
private void _dispatchMessage(Map <String, String> message){
195195
String messageJSON = new JSONObject(message).toString();
196196
Log.d("test","sending:"+messageJSON);

0 commit comments

Comments
 (0)