Skip to content

简单易用的 Android WebView 和 Javascript 交互框架。

License

Notifications You must be signed in to change notification settings

czy1121/jsbridge

Repository files navigation

JSBridge

简单易用的 Android WebView 和 Javascript 交互框架。

使用

class MainActivity : AppCompatActivity(R.layout.layout_web) {

    private val bridge = JSBridge()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState) 

        // 添加模块
        bridge.addModule(TestModule()) 

        // 注入 WebView
        bridge.injectBridge(web)


        web.webViewClient = object : WebViewClient() {

            override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
                logE("onPageStarted => $url")
                // 注入模块
                bridge.injectModules()
                progress.visibility = View.VISIBLE
            }

            override fun onPageFinished(view: WebView, url: String?) {
                logE("onPageFinished => $url")
                // 注入模块
                bridge.injectModules()
                progress.visibility = View.GONE
            }

        }
    }
}

Gradle

repositories { 
    maven { url "https://gitee.com/ezy/repo/raw/cosmo/"}
} 
dependencies {
    implementation "me.reezy.cosmo:jsbridge:0.7.0"
}

LICENSE

The Component is open-sourced software licensed under the Apache license.

About

简单易用的 Android WebView 和 Javascript 交互框架。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published