CB-7261 Fix setNativeToJsBridgeMode sometimes crashing when switching to ONLINE_EVENT

This commit is contained in:
Andrew Grieve 2014-08-07 16:18:56 -04:00
parent 73219bf2d2
commit 41125ea1e2

View File

@ -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() { @Override void reset() {
online = false; cordova.getActivity().runOnUiThread(resetNetworkRunnable);
// If the following call triggers a notifyOfFlush, then ignore it.
ignoreNextFlush = true;
webView.setNetworkAvailable(true);
} }
@Override void onNativeToJsMessageAvailable() { @Override void onNativeToJsMessageAvailable() {
cordova.getActivity().runOnUiThread(toggleNetworkRunnable); cordova.getActivity().runOnUiThread(toggleNetworkRunnable);