Java Code Examples for com.tencent.smtt.sdk.webview#reload()

The following examples show how to use com.tencent.smtt.sdk.webview#reload() . 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: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
@Override
public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray args) {
    switch (commandId) {
        case COMMAND_GO_BACK:
            root.goBack();
            break;
        case COMMAND_GO_FORWARD:
            root.goForward();
            break;
        case COMMAND_RELOAD:
            root.reload();
            break;
        case COMMAND_STOP_LOADING:
            root.stopLoading();
            break;
        case COMMAND_POST_MESSAGE:
            try {
                JSONObject eventInitDict = new JSONObject();
                eventInitDict.put("data", args.getString(0));
                root.loadUrl("javascript:(document.dispatchEvent(new MessageEvent('message', " + eventInitDict.toString() + ")))");
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
            break;
    }
}
 
Example 2
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 解决重定向
 * @param view                              webView
 */
private void resolveRedirect(WebView view) {
    //记录当前时间
    final long now = System.currentTimeMillis();
    //mLastRedirectTime 记录上次出现重定向的时间
    if (now - mLastRedirectTime > DEFAULT_REDIRECT_INTERVAL) {
        mLastRedirectTime = System.currentTimeMillis();
        view.reload();
    }
}