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

Scala R类代码示例

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

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



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

示例1: UndoSnackbarManager

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

import android.support.design.widget.Snackbar
import android.view.View
import com.github.shadowsocks.R

import scala.collection.mutable.ArrayBuffer


class UndoSnackbarManager[T](view: View, undo: Iterator[(Int, T)] => Unit,
                             commit: Iterator[(Int, T)] => Unit = null) {
  private val recycleBin = new ArrayBuffer[(Int, T)]
  private val removedCallback = new Snackbar.Callback {
    override def onDismissed(snackbar: Snackbar, event: Int) = {
      event match {
        case Snackbar.Callback.DISMISS_EVENT_SWIPE | Snackbar.Callback.DISMISS_EVENT_MANUAL |
             Snackbar.Callback.DISMISS_EVENT_TIMEOUT =>
          if (commit != null) commit(recycleBin.iterator)
          recycleBin.clear
        case _ =>
      }
      last = null
    }
  }
  private var last: Snackbar = _

  def remove(index: Int, item: T) = {
    recycleBin.append((index, item))
    val count = recycleBin.length
    last = Snackbar
      .make(view, view.getResources.getQuantityString(R.plurals.removed, count, count: Integer), Snackbar.LENGTH_LONG)
      .setCallback(removedCallback).setAction(R.string.undo, (_ => {
      undo(recycleBin.reverseIterator)
      recycleBin.clear
    }): View.OnClickListener)
    last.show
  }

  def flush = if (last != null) last.dismiss
} 
开发者ID:mmmyc,项目名称:ssr-android,代码行数:41,代码来源:UndoSnackbarManager.scala


示例2: NumberPickerPreference

//设置package包名称以及导入依赖的类
package be.mygod.preference

import android.content.Context
import android.content.res.TypedArray
import android.support.v7.preference.DialogPreference
import android.util.AttributeSet
import android.view.ContextThemeWrapper
import android.widget.NumberPicker
import com.github.shadowsocks.R

class NumberPickerPreference(private val context: Context, attrs: AttributeSet = null)
  extends DialogPreference(context, attrs) with SummaryPreference {
  private[preference] val picker = new NumberPicker(new ContextThemeWrapper(context, R.style.NumberPickerStyle))
  private var value: Int = _

  {
    val a: TypedArray = context.obtainStyledAttributes(attrs, R.styleable.NumberPickerPreference)
    setMin(a.getInt(R.styleable.NumberPickerPreference_min, 0))
    setMax(a.getInt(R.styleable.NumberPickerPreference_max, Int.MaxValue - 1))
    a.recycle
  }

  def getValue = value
  def getMin = if (picker == null) 0 else picker.getMinValue
  def getMax = picker.getMaxValue
  def setValue(i: Int) {
    if (i == value) return
    picker.setValue(i)
    value = picker.getValue
    persistInt(value)
    notifyChanged
  }
  def setMin(value: Int) = picker.setMinValue(value)
  def setMax(value: Int) = picker.setMaxValue(value)

  override protected def onGetDefaultValue(a: TypedArray, index: Int): AnyRef =
    a.getInt(index, getMin).asInstanceOf[AnyRef]
  override protected def onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any) {
    val default = defaultValue.asInstanceOf[Int]
    setValue(if (restorePersistedValue) getPersistedInt(default) else default)
  }
  protected def getSummaryValue: AnyRef = getValue.asInstanceOf[AnyRef]
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:44,代码来源:NumberPickerPreference.scala


示例3: PreferenceGroupAdapter

//设置package包名称以及导入依赖的类
package be.mygod.preference

import java.lang.reflect.Field
import java.util.List

import android.os.Build
import android.support.v4.content.ContextCompat
import android.support.v4.view.ViewCompat
import android.support.v7.preference.{PreferenceGroup, PreferenceViewHolder, PreferenceGroupAdapter => Old}
import android.view.{LayoutInflater, View, ViewGroup}
import com.github.shadowsocks.R


object PreferenceGroupAdapter {
  private var preferenceLayoutsField: Field = _
  private var fieldResId: Field = _
  private var fieldWidgetResId: Field = _
  private val preferenceViewHolderConstructor = classOf[PreferenceViewHolder].getDeclaredConstructor(classOf[View])

  {
    val oldClass = classOf[Old]
    preferenceLayoutsField = oldClass.getDeclaredField("mPreferenceLayouts")
    preferenceLayoutsField.setAccessible(true)
    val c = oldClass.getDeclaredClasses.filter(c => c.getSimpleName == "PreferenceLayout").head
    fieldResId = c.getDeclaredField("resId")
    fieldResId.setAccessible(true)
    fieldWidgetResId = c.getDeclaredField("widgetResId")
    fieldWidgetResId.setAccessible(true)
    preferenceViewHolderConstructor.setAccessible(true)
  }
}

class PreferenceGroupAdapter(group: PreferenceGroup) extends Old(group) {
  import PreferenceGroupAdapter._

  protected lazy val preferenceLayouts = preferenceLayoutsField.get(this).asInstanceOf[List[AnyRef]]

  override def onCreateViewHolder(parent: ViewGroup, viewType: Int) = if (Build.VERSION.SDK_INT < 21) {
    val context = parent.getContext
    val inflater = LayoutInflater.from(context)
    val pl = preferenceLayouts.get(viewType)
    val view = inflater.inflate(fieldResId.get(pl).asInstanceOf[Int], parent, false)
    if (view.getBackground == null) {
      val array = context.obtainStyledAttributes(null, R.styleable.BackgroundStyle)
      var background = array.getDrawable(R.styleable.BackgroundStyle_android_selectableItemBackground)
      if (background == null)
        background = ContextCompat.getDrawable(context, android.R.drawable.list_selector_background)
      array.recycle
      val (s, t, e, b) = (ViewCompat.getPaddingStart(view), view.getPaddingTop,
        ViewCompat.getPaddingEnd(view), view.getPaddingBottom)
      view.setBackground(background)
      ViewCompat.setPaddingRelative(view, s, t, e, b)
    }
    val widgetFrame = view.findViewById(android.R.id.widget_frame).asInstanceOf[ViewGroup]
    if (widgetFrame != null) {
      val widgetResId = fieldWidgetResId.get(pl).asInstanceOf[Int]
      if (widgetResId != 0) inflater.inflate(widgetResId, widgetFrame) else widgetFrame.setVisibility(View.GONE)
    }
    preferenceViewHolderConstructor.newInstance(view)
  } else super.onCreateViewHolder(parent, viewType)
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:62,代码来源:PreferenceGroupAdapter.scala


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


示例5: WebViewFragment

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

import android.os.Bundle
import android.view.{LayoutInflater, View, ViewGroup}
import android.webkit.WebView
import com.github.shadowsocks.{R, ToolbarFragment}

class WebViewFragment(titleId: Int, url: String) extends ToolbarFragment {
  override def onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle): View =
    inflater.inflate(R.layout.layout_webview, container, false)

  override def onViewCreated(view: View, savedInstanceState: Bundle) {
    super.onViewCreated(view, savedInstanceState)
    val title = getString(titleId)
    toolbar.setTitle(title)
    val web = view.findViewById(R.id.web_view).asInstanceOf[WebView]
    val settings = web.getSettings()
    settings.setJavaScriptEnabled(true)
    web.setWebViewClient(new RalletsWebClient(getActivity, title))
    web.loadUrl(url)
  }
} 
开发者ID:rallets-network,项目名称:rallets-android,代码行数:23,代码来源:WebViewFragment.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala WebView类代码示例发布时间:2022-05-23
下一篇:
Scala Color类代码示例发布时间: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