本文整理汇总了Scala中android.webkit.WebViewClient类的典型用法代码示例。如果您正苦于以下问题:Scala WebViewClient类的具体用法?Scala WebViewClient怎么用?Scala WebViewClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebViewClient类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: RalletsWebClient
//设置package包名称以及导入依赖的类
package com.rallets
import android.app.{Activity, AlertDialog, ProgressDialog}
import android.content.DialogInterface
import android.webkit.{WebView, WebViewClient}
import android.widget.Toast
import com.github.shadowsocks.R
class RalletsWebClient(activity: Activity, title: String) extends WebViewClient {
val alertDialog = new AlertDialog.Builder(activity).create()
val progressBar = ProgressDialog.show(activity, title, activity.getString(R.string.loading))
override def onReceivedSslError(view: _root_.android.webkit.WebView, handler: _root_.android.webkit.SslErrorHandler, error: _root_.android.net.http.SslError): Unit = {
import android.content.DialogInterface
val builder = new AlertDialog.Builder(activity)
builder.setMessage(R.string.ssl_error_alert)
builder.setPositiveButton(R.string.continue_browse, new DialogInterface.OnClickListener() {
override def onClick(dialog: DialogInterface, which: Int): Unit = {
handler.proceed
}
})
builder.setNegativeButton(R.string.cancel_browse, new DialogInterface.OnClickListener() {
override def onClick(dialog: DialogInterface, which: Int): Unit = {
handler.cancel
}
})
val dialog = builder.create
dialog.show()
}
override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean = {
view.loadUrl(url)
return false
}
override def onPageFinished(view: WebView, url: String): Unit = {
RUtils.log("Finished loading URL: " + url)
if (progressBar.isShowing()) {
progressBar.dismiss()
}
}
override def onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String): Unit = {
RUtils.log("Error: " + description)
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show()
alertDialog.setTitle("Error")
alertDialog.setMessage(description)
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
def onClick(dialog: DialogInterface, which: Int) {}
})
alertDialog.show()
}
}
开发者ID:rallets-network,项目名称:rallets-android,代码行数:54,代码来源:RalletsWebClient.scala
注:本文中的android.webkit.WebViewClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论