List of usage examples for android.webkit WebView isShown
public boolean isShown()
From source file:com.facebook.internal.FacebookWebFallbackDialog.java
@Override public void dismiss() { WebView webView = getWebView(); if (isListenerCalled() || webView == null || !webView.isShown()) { // If the listener has been called, or if the WebView isn't visible, we cannot give the dialog a chance // to respond. So defer to the parent implementation. super.dismiss(); return;/*from ww w.jav a 2s . com*/ } // If we have already notified the dialog to close, then ignore this request to dismiss. The timer will // honor the request. if (waitingForDialogToClose) { return; } waitingForDialogToClose = true; // Now fire off the event that will tell the dialog to wind down. String eventJS = "(function() {" + " var event = document.createEvent('Event');" + " event.initEvent('fbPlatformDialogMustClose',true,true);" + " document.dispatchEvent(event);" + "})();"; webView.loadUrl("javascript:" + eventJS); // Set up a timeout for the dialog to respond. If the timer expires, we need to honor the user's desire to // dismiss the dialog. Handler handler = new Handler(Looper.getMainLooper()); handler.postDelayed(new Runnable() { @Override public void run() { if (!isListenerCalled()) { // If we get here, then the dialog did not close quickly enough. So we need to honor the user's // wish to cancel. sendCancelToListener(); } } }, OS_BACK_BUTTON_RESPONSE_TIMEOUT_MILLISECONDS); }