webview 限制跳转到系统浏览器
This commit is contained in:
parent
ac41cdf3f0
commit
dc4871c8b0
|
|
@ -40,7 +40,7 @@ object VidiConst {
|
|||
|
||||
|
||||
const val URL_DISCORD: String = "https://discord.gg/qAZaaN8uaU"
|
||||
const val URL_GAME: String = "https://s.gamifyspace.com/tml?pid=20057&appk=ZPfHlw7v5plM1N2moiiaDzixPszLSxIl&did={%s}"
|
||||
const val URL_GAME: String = "https://s.gamifyspace.com/tml?pid=20057&appk=ZPfHlw7v5plM1N2moiiaDzixPszLSxIl&did=%s"
|
||||
const val URL_PRIVACY: String = "https://rsappinc.com/privacy.html"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
package com.gamedog.vididin.features.game
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.LayoutInflater
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.viewModels
|
||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||
import com.ama.core.architecture.ext.toast
|
||||
import com.ama.core.architecture.util.AndroidUtil
|
||||
import com.gamedog.vididin.VidiConst
|
||||
import com.viddin.videos.free.R
|
||||
|
|
@ -22,17 +28,53 @@ class GameCenterActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(),
|
|||
override val mViewModel: ViewModel by viewModels()
|
||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun ViewBinding.initViews() {
|
||||
|
||||
with(binding) {
|
||||
titlebar.setBackIconColor(R.color.black)
|
||||
titlebar.setTitleText(R.string.game_center, R.color.black)
|
||||
|
||||
|
||||
onBackPressedDispatcher.addCallback(this@GameCenterActivity) {
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
with(webView) {
|
||||
settings.javaScriptEnabled = true
|
||||
|
||||
webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest
|
||||
): Boolean {
|
||||
request.url?.let { url ->
|
||||
view?.loadUrl(url.toString())
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@Deprecated("For API level < 24")
|
||||
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||
if (!url.isNullOrBlank()) {
|
||||
view?.loadUrl(url)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
webView.loadUrl(String.format(VidiConst.URL_GAME, AndroidUtil.getGaid()))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun ViewBinding.initWindowInsets() {
|
||||
setImmerseRootView(contentRoot)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue