CB-7261 Fix setNativeToJsBridgeMode sometimes crashing when switching to ONLINE_EVENT
Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/96c6c52a Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/96c6c52a Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/96c6c52a Branch: refs/heads/master Commit: 96c6c52ac3bcff837696efbbffea54fe4430002b Parents: cdcf5f3 Author: Andrew Grieve <[email protected]> Authored: Thu Aug 7 16:18:56 2014 -0400 Committer: Archana Naik <[email protected]> Committed: Mon Aug 18 12:33:33 2014 -0700 ---------------------------------------------------------------------- .../src/org/apache/cordova/NativeToJsMessageQueue.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/96c6c52a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java index c306d8d..ebc93cb 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);
