Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一个问题 #5

Open
liatsineam opened this issue Dec 2, 2014 · 1 comment
Open

请教一个问题 #5

liatsineam opened this issue Dec 2, 2014 · 1 comment

Comments

@liatsineam
Copy link

您好,能请教一下,你的这种实现方式比在shouldOverrideUrlLoading拦截js再去处理的优势在哪儿吗

@pedant
Copy link
Owner

pedant commented Dec 2, 2014

首先表明立场,不建议在shouldOverrideUrlLoading上去做层协议来发起js调用,暂时能想到的原因有:

  • 试想一下页面端如果要任何时候发起调用,都必须"模拟"一个链接跳转事件而java端才能收到通知。这样的模拟在页面端比较耗时(我曾经做webapp时尝试过)。
  • 另外,页面端一般是同步调用执行java方法,执行完成后有时需要返回各个类型的结果,而在shouldOverrideUrlLoading中不能做到多种类型的结果的【同步】返回。
  • 还有种情况,假设页面存在一个正常链接在需要点击完成reload的同时又需要调用java方法怎么办,这两处都会执行都会跑到shouldOverrideUrlLoading中来,使其内部又掺杂业务又掺杂js调用框架,本质上更复杂难以维护。

综合上面对比下safe-java-js-webview-bridge原理就知道优势了。

欢迎探讨补充。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants