pull/871/head
gedoor 4 years ago
parent 18fa459547
commit d30c5d49a2
  1. 49
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt

@ -305,16 +305,35 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
request: WebResourceRequest?
): Boolean {
request?.let {
if (it.url.scheme == "http" || it.url.scheme == "https") {
return shouldOverrideUrlLoading(it.url)
}
return true
}
@Suppress("DEPRECATION")
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
url?.let {
return shouldOverrideUrlLoading(Uri.parse(it))
}
return true
}
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
upWebViewTheme()
}
private fun shouldOverrideUrlLoading(url: Uri): Boolean {
if (url.scheme == "http" || url.scheme == "https") {
return false
} else if (it.url.scheme == "yuedu") {
when (it.url.host) {
} else if (url.scheme == "yuedu") {
when (url.host) {
"booksource" -> {
val intent = Intent(
this@ReadRssActivity,
ImportBookSourceActivity::class.java
)
intent.data = it.url
intent.data = url
startActivity(intent)
}
"rsssource" -> {
@ -322,7 +341,7 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
this@ReadRssActivity,
ImportRssSourceActivity::class.java
)
intent.data = it.url
intent.data = url
startActivity(intent)
}
"replace" -> {
@ -330,32 +349,18 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
this@ReadRssActivity,
ImportReplaceRuleActivity::class.java
)
intent.data = it.url
intent.data = url
startActivity(intent)
}
}
return true
}
openUrl(it.url)
}
return true
}
@Suppress("DEPRECATION")
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
if (url?.startsWith("http", true) == true) {
return false
}
url?.let {
openUrl(it)
binding.root.longSnackbar("跳转其它应用", "确认") {
openUrl(url)
}
return true
}
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
upWebViewTheme()
}
}
}

Loading…
Cancel
Save