• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala DialogInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了DialogInterface类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: KcpCliPreferenceDialogFragment

//设置package包名称以及导入依赖的类
package com.github.shadowsocks.preferences

import android.app.AlertDialog
import android.content.DialogInterface
import eu.chainfire.libsuperuser.Shell
import be.mygod.preference.EditTextPreferenceDialogFragment

import scala.collection.JavaConverters._


class KcpCliPreferenceDialogFragment extends EditTextPreferenceDialogFragment {
  override def onPrepareDialogBuilder(builder: AlertDialog.Builder) {
    super.onPrepareDialogBuilder(builder)
    builder.setNeutralButton("?", ((_, _) => new AlertDialog.Builder(builder.getContext)
      .setTitle("?")
      .setMessage(Shell.SH.run(builder.getContext.getApplicationInfo.dataDir + "/kcptun --help")
        .asScala
        .dropWhile(line => line != "GLOBAL OPTIONS:")
        .drop(1)
        .takeWhile(line => line.length() > 3)
        .filter(line =>
          !line.startsWith("   --localaddr ") &&
          !line.startsWith("   --remoteaddr ") &&
          !line.startsWith("   --path ") &&
          !line.startsWith("   --help,") &&
          !line.startsWith("   --version,"))
        .mkString("\n")
        .replaceAll(" {2,}", "\n")
        .substring(1))  // remove 1st \n
      .show()): DialogInterface.OnClickListener)
  }
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:33,代码来源:KcpCliPreferenceDialogFragment.scala


示例2: ConfirmDialog

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.dialog

import java.io.Serializable

import android.app.{Dialog, DialogFragment}
import android.content.DialogInterface
import android.content.DialogInterface.OnClickListener
import android.os.Bundle
import android.support.v7.app.AlertDialog

object ConfirmDialog {

  def newInstance(title: Option[String], msg: String, iconResId: Option[Int], lis: ClickListener) = {
    val instance = new ConfirmDialog
    val bun = new Bundle
    bun.putString("msg", msg)
    bun.putSerializable("listener", lis)
    title foreach { bun.putString("title", _) }
    iconResId foreach { bun.putInt("icon", _)}
    instance.setArguments(bun)
    instance
  }

  trait ClickListener extends Serializable {
    def onClick()
  }

}

class ConfirmDialog extends DialogFragment {

  override def onCreateDialog(savedInstanceState: Bundle): Dialog = {

    val builder = new AlertDialog.Builder(getActivity)
      .setMessage(getArguments.getString("msg"))
      .setPositiveButton("OK", new OnClickListener {
      override def onClick(dialogInterface: DialogInterface, i: Int) =
        getArguments.getSerializable("listener").asInstanceOf[ConfirmDialog.ClickListener].onClick()
    })

    Option(getArguments.getString("title")) foreach { builder.setTitle(_) }
    val icon = getArguments.getInt("icon", 0)
    if (icon > 0) builder.setIcon(icon)

    builder.create
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:48,代码来源:ConfirmDialog.scala


示例3: 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


示例4: 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


示例5: DescriptionAddDialog

//设置package包名称以及导入依赖的类
package ru.wordmetrix.dreamcrammer


import android.app.{ Activity, Dialog, AlertDialog }
import android.os.{ Bundle }
import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._
import android.content.{ Context, DialogInterface }
import android.view.{ LayoutInflater, ViewGroup }
import android.widget.{ EditText }
import android.support.v4.app.DialogFragment


object DescriptionAddDialog {
    abstract trait Listener {
        def publish(word: Word): Unit
    }
}

class DescriptionAddDialog(word: Word) extends DialogFragment {
    var activity: DescriptionAddDialog.Listener = null

     override def onAttach(activity: Activity) {
        super.onAttach(activity)
        this.activity = activity.asInstanceOf[DescriptionAddDialog.Listener]
    }

    override def onCreateDialog(savedInstanceState: Bundle): Dialog = {
        val viewgroup = getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE).asInstanceOf[LayoutInflater].inflate(R.layout.descriptiondialog, null).asInstanceOf[ViewGroup]
        log("edit : %s", viewgroup.findViewById(R.id.description_value).asInstanceOf[EditText])

        new AlertDialog.Builder(getActivity())
            .setTitle("Add description")
            .setView(viewgroup)
            .setPositiveButton("Add", new DialogInterface.OnClickListener() {
                def onClick(dialog: DialogInterface, id: Int) {
                    log("Add description")
                    word.addDescription(viewgroup.findViewById(R.id.description_value).asInstanceOf[EditText].getText().toString)
                    activity.publish(word.refresh())
                }
            })
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                def onClick(dialog: DialogInterface, id: Int) {
                    log("Cancel changes")
                }
            }).create()
    }

} 
开发者ID:electricmind,项目名称:dreamcrammer,代码行数:50,代码来源:descriptionedit.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala TraceContext类代码示例发布时间:2022-05-23
下一篇:
Scala PreferConsistent类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap