diff --git a/agronweb/src/main/java/cn/sovegetables/web/CommonWebActivity.kt b/agronweb/src/main/java/cn/sovegetables/web/CommonWebActivity.kt index 5f4a8cf..030046b 100644 --- a/agronweb/src/main/java/cn/sovegetables/web/CommonWebActivity.kt +++ b/agronweb/src/main/java/cn/sovegetables/web/CommonWebActivity.kt @@ -78,23 +78,23 @@ open class CommonWebActivity : BaseActivity() { webConfig = getWebConfig(this) super.onCreate(savedInstanceState) setContentView(R.layout.activity_common_web) - - val updater : TopBarItemUpdater = topBarAction.leftItemUpdater() - if(webConfig.withCloseIconAndClosePage){ - updater.iconRes(R.drawable.ic_agron_web_close_black) - }else{ - updater.iconRes(R.drawable.ic_delegate_arrow_back) - } - if(!webConfig.enableAutoTitle && !TextUtils.isEmpty(webConfig.title)){ - if(webConfig.isCenterTitle){ - topBarAction.topBarUpdater.title(webConfig.title) - .update() + if(webConfig.enable){ + val updater : TopBarItemUpdater = topBarAction.leftItemUpdater() + if(webConfig.withCloseIconAndClosePage){ + updater.iconRes(R.drawable.ic_agron_web_close_black) }else{ - updater.text(webConfig.title) + updater.iconRes(R.drawable.ic_delegate_arrow_back) } + if(!webConfig.enableAutoTitle && !TextUtils.isEmpty(webConfig.title)){ + if(webConfig.isCenterTitle){ + topBarAction.topBarUpdater.title(webConfig.title) + .update() + }else{ + updater.text(webConfig.title) + } + } + updater.update() } - updater.update() - val url = webConfig.url val downloadListener = sModule.downloadListenerModule() downloadListener?.attachWeb(web, this) @@ -111,6 +111,9 @@ open class CommonWebActivity : BaseActivity() { web.addWebChromeClient(videoFullScreenHandler) web.addWebChromeClient(object : WebChromeClientAdapter(){ override fun onReceivedTitle(view: WebView?, title: String?) { + if(!webConfig.enable){ + return + } if(webConfig.enableAutoTitle){ if(webConfig.isCenterTitle){ topBarAction.topBarUpdater.title(title) @@ -130,9 +133,11 @@ open class CommonWebActivity : BaseActivity() { val pageListener = object : IWebModule.WebProgressViewModuleAdapter(){ override fun onPageFinished(view: WebView?, url: String?) { - topBarAction.findRightItemUpdaterById(SHARE_TOP_ITEM_ID) - .visibility(View.VISIBLE) - .update() + if(webConfig.enable){ + topBarAction.findRightItemUpdaterById(SHARE_TOP_ITEM_ID) + .visibility(View.VISIBLE) + .update() + } } } web.addWebChromeClient(WebChromeClientCompat(pageListener)) diff --git a/app/src/main/java/cn/sovegetables/sample/MainActivity.kt b/app/src/main/java/cn/sovegetables/sample/MainActivity.kt index 262f02a..1a8c57b 100644 --- a/app/src/main/java/cn/sovegetables/sample/MainActivity.kt +++ b/app/src/main/java/cn/sovegetables/sample/MainActivity.kt @@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() { et_input.setText("http://134.175.132.191:18085") btn_go.setOnClickListener { - CommonWebActivity.start(this, WebConfig(url = et_input.text.toString(), statusColorInt = Color.BLUE, + CommonWebActivity.start(this, WebConfig(url = et_input.text.toString(), statusColorInt = Color.BLUE, enable = false, shareType = WebConfig.TYPE_SHARE_DEFAULT, enableAutoTitle = true, withCloseIconAndClosePage = false) )