当前位置: 首页>>代码示例>>Scala>>正文


Scala ProgressDialog类代码示例

本文整理汇总了Scala中android.app.ProgressDialog的典型用法代码示例。如果您正苦于以下问题:Scala ProgressDialog类的具体用法?Scala ProgressDialog怎么用?Scala ProgressDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ProgressDialog类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例2: cw

//设置package包名称以及导入依赖的类
package app.bitrader.helpers

import android.app.ProgressDialog
import android.content.DialogInterface
import android.content.DialogInterface.OnClickListener
import app.bitrader.helpers.UiThreading
import macroid.FullDsl._
import macroid.{ContextWrapper, Ui}


trait Dialogs extends UiThreading{
  protected[this] implicit def cw: ContextWrapper

  def showToast(t: String) = Ui.run(toast(t)(cw) <~ fry)

  def showLongToast(t: String) = Ui.run(toast(t)(cw) <~ long <~ fry)

  def spinner(t: String): Unit = spinnerDialog(t, null)

  def spinner(): Unit = spinner("?????????...")

  @inline def spinnerDialog(title: CharSequence, message: CharSequence) =
    runOnUiThread(ProgressDialog.show(cw.bestAvailable, title, message, true))

  // alerts

  def action(doAction: => Unit): DialogInterface.OnClickListener = {
    new OnClickListener {
      override def onClick(dialog: DialogInterface, which: Int): Unit = doAction
    }
  }

  @inline def confirm(t: String, yes: => Unit, no: => Unit = () => ()) = {
    Ui.run {
      dialog(t) <~
        positiveYes(action(yes)) <~
        negativeNo(action(no)) <~
        speak
    }
  }

  @inline def alert(t: String, d: String, yes: => Unit = () => ()) = {
    Ui.run {
      dialog(t + " " + d) <~
        positiveYes(action(yes)) <~
        speak
    }
  }

} 
开发者ID:aafa,项目名称:bitrader,代码行数:51,代码来源:Dialogs.scala


注:本文中的android.app.ProgressDialog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。