com.tencent.smtt.export.external.interfaces.JsResult Java Examples

The following examples show how to use com.tencent.smtt.export.external.interfaces.JsResult. 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: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
    if (!((EBrowserActivity) view.getContext()).isVisable()) {
        result.confirm();
    }
    AlertDialog.Builder dia = new AlertDialog.Builder(view.getContext());
    dia.setTitle(EUExUtil.getResStringID("prompt"));
    dia.setMessage(message);
    dia.setCancelable(false);
    dia.setPositiveButton(EUExUtil.getResStringID("confirm"), new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            result.confirm();
        }
    });
    dia.create();
    dia.show();
    return true;
}
 
Example #2
Source File: WvWebView.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
    if(!alertBoxBlock){
        result.confirm();
    }
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if(alertBoxBlock) {
                if (which == Dialog.BUTTON_POSITIVE) {
                    result.confirm();
                } else {
                    result.cancel();
                }
            }
        }
    };
    new AlertDialog.Builder(getContext())
            .setMessage(message)
            .setCancelable(false)
            .setPositiveButton(android.R.string.ok, listener)
            .setNegativeButton(android.R.string.cancel, listener).show();
    return true;
}
 
Example #3
Source File: WvWebView.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onJsAlert(WebView view, String url, final String message, final JsResult result) {
    if(!alertBoxBlock){
        result.confirm();
    }
    Dialog alertDialog = new AlertDialog.Builder(getContext()).
            setMessage(message).
            setCancelable(false).
            setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    if(alertBoxBlock) {
                        result.confirm();
                    }
                }
            })
            .create();
    alertDialog.show();
    return true;
}
 
Example #4
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {


    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "onJsAlert", "public boolean " + ChromePath + ".onJsAlert", WebView.class, String.class, String.class, JsResult.class)) {

        return super.onJsAlert(view, url, message, result);
    }

    Activity mActivity = this.mActivityWeakReference.get();
    if (mActivity == null||mActivity.isFinishing()) {
        result.cancel();
        return true;
    }
    //
    try {
        AgentWebX5Utils.show(view,
                message,
                Snackbar.LENGTH_SHORT,
                Color.WHITE,
                mActivity.getResources().getColor(R.color.black),
                null,
                -1,
                null);
    } catch (Throwable throwable) {
        throwable.printStackTrace();
        if(LogUtils.isDebug())
            LogUtils.i(TAG,throwable.getMessage());
    }

    result.confirm();

    return true;
}
 
Example #5
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {

    LogUtils.i(TAG, message);
    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "onJsConfirm", "public boolean " + ChromePath + ".onJsConfirm", WebView.class, String.class, String.class, JsResult.class)) {

        return super.onJsConfirm(view, url, message, result);
    }
    showJsConfirm(message, result);
    return true; //
}
 
Example #6
Source File: X5WebChromeClient.java    From x5webview-cordova-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a javascript alert dialog.
 */
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
    dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() {
        @Override public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #7
Source File: X5WebChromeClient.java    From x5webview-cordova-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a confirm dialog to the user.
 */
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
    dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() {
        @Override
        public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #8
Source File: X5WebChromeClient.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a javascript alert dialog.
 */
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
    dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() {
        @Override public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #9
Source File: X5WebChromeClient.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a confirm dialog to the user.
 */
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
    dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() {
        @Override
        public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #10
Source File: X5WebChromeClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a javascript alert dialog.
 */
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
  dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() {
    @Override
    public void gotResult(boolean success, String value) {
      if (success) {
        result.confirm();
      } else {
        result.cancel();
      }
    }
  });
  return true;
}
 
Example #11
Source File: X5WebChromeClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a confirm dialog to the user.
 */
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
  dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() {
    @Override
    public void gotResult(boolean success, String value) {
      if (success) {
        result.confirm();
      } else {
        result.cancel();
      }
    }
  });
  return true;
}
 
Example #12
Source File: X5WebChromeClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a confirm dialog to the user.
 */
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
    dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() {
        @Override
        public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #13
Source File: X5WebChromeClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a javascript alert dialog.
 */
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
    dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() {
        @Override public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #14
Source File: WebChromeClientListener.java    From JsBridge with MIT License 4 votes vote down vote up
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
    return false;
}
 
Example #15
Source File: WebChromeClientListener.java    From JsBridge with MIT License 4 votes vote down vote up
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
    return false;
}
 
Example #16
Source File: WebChromeClientListener.java    From JsBridge with MIT License 4 votes vote down vote up
@Override
public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
    return false;
}
 
Example #17
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public boolean onJsConfirm(WebView view, String url, String message,
                           JsResult result) {
    if (this.mRealWebChromeClient != null)
        return this.mRealWebChromeClient.onJsConfirm(view, url, message, result);
    return super.onJsConfirm(view,url,message,result);
}
 
Example #18
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
private void toCancelJsresult(JsResult result) {
    if (result != null)
        result.cancel();
}
 
Example #19
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public boolean onJsBeforeUnload(WebView view, String url, String message,
                                JsResult result) {
    if (this.mRealWebChromeClient != null)
        return this.mRealWebChromeClient.onJsBeforeUnload(view, url, message, result);
    return super.onJsBeforeUnload(view,url,message,result);
}
 
Example #20
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public boolean onJsAlert(WebView view, String url, String message,
                         JsResult result) {
    if (this.mRealWebChromeClient != null)
        return this.mRealWebChromeClient.onJsAlert(view, url, message, result);
    return super.onJsAlert(view,url,message,result);
}
 
Example #21
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 3 votes vote down vote up
/**
 * 处理alert弹出框
 * 调用javascript的调试过程中,有时候需要使用onJsAlert来输出javascript方法的信息,以帮助进行问题定位。
 * onJsAlert方法即可,为什么onJsAlert只调用了一次
 * 发现onJsAlert只调用了一次,为什么呢,实际上,你可能忽略了一句调用.就是处理JsResult.
 * 需要调用result.confirm()或者result.cancel()来处理jsResult,否则会出问题.
 * @param webView                           view
 * @param s                                 s
 * @param s1                                s1
 * @param jsResult                          jsResult,用于处理底层JS发起的请求,为客户端提供一些方法指明应进行的操作,比如确认或取消。
 * @return
 */
@Override
public boolean onJsAlert(WebView webView, String s, String s1, JsResult jsResult) {
    // 这里处理交互逻辑
    // result.cancel(); 表示用户取消了操作(点击了取消按钮)
    // result.confirm(); 表示用户确认了操作(点击了确认按钮)
    // ...
    // 返回true表示自已处理,返回false表示由系统处理
    return super.onJsAlert(webView, s, s1, jsResult);
}
 
Example #22
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 2 votes vote down vote up
/**
 * 显示一个对话框让用户选择是否离开当前页面
 * @param webView                           view
 * @param s                                 s
 * @param s1                                s1
 * @param jsResult                          jsResult,用于处理底层JS发起的请求,为客户端提供一些方法指明应进行的操作,比如确认或取消。
 * @return
 */
@Override
public boolean onJsBeforeUnload(WebView webView, String s, String s1, JsResult jsResult) {
    return super.onJsBeforeUnload(webView, s, s1, jsResult);
}
 
Example #23
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 2 votes vote down vote up
/**
 * 处理confirm弹出框
 * result.confirm() 和 return true 一起用,才能保证弹框不会出现。
 * @param webView                           view
 * @param s                                 s
 * @param s1                                s1
 * @param jsResult                          jsResult,用于处理底层JS发起的请求,为客户端提供一些方法指明应进行的操作,比如确认或取消。
 * @return
 */
@Override
public boolean onJsConfirm(WebView webView, String s, String s1, JsResult jsResult) {
    return super.onJsConfirm(webView, s, s1, jsResult);
}
 
Example #24
Source File: OnWebChromeClientListener.java    From JsBridge with MIT License votes vote down vote up
boolean onJsAlert(WebView view, String url, String message, JsResult result); 
Example #25
Source File: OnWebChromeClientListener.java    From JsBridge with MIT License votes vote down vote up
boolean onJsConfirm(WebView view, String url, String message, JsResult result); 
Example #26
Source File: OnWebChromeClientListener.java    From JsBridge with MIT License votes vote down vote up
boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result);