From 41125ea1e2ce9bff3191f57d88c10c277cbb3e94 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 7 Aug 2014 16:18:56 -0400 Subject: [PATCH] CB-7261 Fix setNativeToJsBridgeMode sometimes crashing when switching to ONLINE_EVENT --- .../org/apache/cordova/NativeToJsMessageQueue.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java index d05eed82..497366f2 100755 --- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java +++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java @@ -321,11 +321,16 @@ public class NativeToJsMessageQueue { } } }; + final Runnable resetNetworkRunnable = new Runnable() { + public void run() { + online = false; + // If the following call triggers a notifyOfFlush, then ignore it. + ignoreNextFlush = true; + webView.setNetworkAvailable(true); + } + }; @Override void reset() { - online = false; - // If the following call triggers a notifyOfFlush, then ignore it. - ignoreNextFlush = true; - webView.setNetworkAvailable(true); + cordova.getActivity().runOnUiThread(resetNetworkRunnable); } @Override void onNativeToJsMessageAvailable() { cordova.getActivity().runOnUiThread(toggleNetworkRunnable);