Java Code Examples for android.webkit.WebView#isShown()

The following examples show how to use android.webkit.WebView#isShown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LightningView.java    From browser with GNU General Public License v2.0 9 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
	if (view.isShown()) {
		mBrowserController.updateUrl(url, true);
		view.postInvalidate();
	}
	if (view.getTitle() == null || view.getTitle().isEmpty()) {
		mTitle.setTitle(mActivity.getString(R.string.untitled));
	} else {
		mTitle.setTitle(view.getTitle());
	}
	if (API >= android.os.Build.VERSION_CODES.KITKAT && mInvertPage) {
		view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
	}
	mBrowserController.update();
}
 
Example 2
Source File: LightningWebClient.java    From Xndroid with GNU General Public License v3.0 8 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(@NonNull WebView view, String url) {
    if (view.isShown()) {
        mUIController.updateUrl(url, false);
        mUIController.setBackButtonEnabled(view.canGoBack());
        mUIController.setForwardButtonEnabled(view.canGoForward());
        view.postInvalidate();
    }
    if (view.getTitle() == null || view.getTitle().isEmpty()) {
        mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled));
    } else {
        mLightningView.getTitleInfo().setTitle(view.getTitle());
    }
    if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT &&
        mLightningView.getInvertePage()) {
        view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
    }
    mUIController.tabChanged(mLightningView);
}
 
Example 3
Source File: LightningView.java    From browser with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onScaleChanged(final WebView view, final float oldScale, final float newScale) {
	if (view.isShown() && mTextReflow && API >= android.os.Build.VERSION_CODES.KITKAT) {
		if (mIsRunning)
			return;
		if (Math.abs(mZoomScale - newScale) > 0.01f) {
			mIsRunning = view.postDelayed(new Runnable() {

				@Override
				public void run() {
					mZoomScale = newScale;
					view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null);
					mIsRunning = false;
				}

			}, 100);
		}

	}
}
 
Example 4
Source File: LightningWebClient.java    From Xndroid with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onScaleChanged(@NonNull final WebView view, final float oldScale, final float newScale) {
    if (view.isShown() && mLightningView.mPreferences.getTextReflowEnabled() &&
        Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        if (mIsRunning)
            return;
        float changeInPercent = Math.abs(100 - 100 / mZoomScale * newScale);
        if (changeInPercent > 2.5f && !mIsRunning) {
            mIsRunning = view.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mZoomScale = newScale;
                    view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, new ValueCallback<String>() {
                        @Override
                        public void onReceiveValue(String value) {
                            mIsRunning = false;
                        }
                    });
                }
            }, 100);
        }

    }
}
 
Example 5
Source File: LightningWebClient.java    From JumpGo with Mozilla Public License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(@NonNull WebView view, String url) {
    if (view.isShown()) {
        mUIController.updateUrl(url, false);
        mUIController.setBackButtonEnabled(view.canGoBack());
        mUIController.setForwardButtonEnabled(view.canGoForward());
        view.postInvalidate();
    }
    if (view.getTitle() == null || view.getTitle().isEmpty()) {
        mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled));
    } else {
        mLightningView.getTitleInfo().setTitle(view.getTitle());
    }
    if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT &&
        mLightningView.getInvertePage()) {
        view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
    }
    mUIController.tabChanged(mLightningView);
}
 
Example 6
Source File: LightningWebClient.java    From JumpGo with Mozilla Public License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onScaleChanged(@NonNull final WebView view, final float oldScale, final float newScale) {
    if (view.isShown() && mLightningView.mPreferences.getTextReflowEnabled() &&
        Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        if (mIsRunning)
            return;
        float changeInPercent = Math.abs(100 - 100 / mZoomScale * newScale);
        if (changeInPercent > 2.5f && !mIsRunning) {
            mIsRunning = view.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mZoomScale = newScale;
                    view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, new ValueCallback<String>() {
                        @Override
                        public void onReceiveValue(String value) {
                            mIsRunning = false;
                        }
                    });
                }
            }, 100);
        }

    }
}
 
Example 7
Source File: FacebookWebFallbackDialog.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
@Override
public void cancel() {
    WebView webView = getWebView();

    // If the page hasn't loaded, or the listener is already called, then we can't interrupt
    // this cancellation. Either the JS won't be ready to consume the event, or the listener
    // has already processed a result.
    // So let's just handle this cancellation in the standard way.
    if (!isPageFinished()
            || isListenerCalled()
            || webView == null
            || !webView.isShown()) {
        super.cancel();
        return;
    }

    // Return right away if we have already queued up the delayed-cancel call.
    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 we get here, then the dialog did not close quickly enough.
                    // So we need to honor the user's wish to cancel and we should do
                    // so without allowing interruptions.
                    FacebookWebFallbackDialog.super.cancel();
                }
            },
            OS_BACK_BUTTON_RESPONSE_TIMEOUT_MILLISECONDS);
}