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


Scala TextUtils类代码示例

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


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

示例1: AlarmBroadcastReceiver

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

import android.app.{Notification, NotificationManager, PendingIntent}
import android.content.{BroadcastReceiver, Context, Intent}
import android.support.v4.app.NotificationCompat
import android.text.TextUtils
import com.android.perrier1034.post_it_note.db.dao.{PageStore, NoteStore}
import com.android.perrier1034.post_it_note.model.NoteRealm
import com.android.perrier1034.post_it_note.ui.PageManager
import com.android.perrier1034.post_it_note.util.AlarmUtil
import com.android.perrier1034.post_it_note.{App, R}

object AlarmBroadcastReceiver {
  val KEY_INTENT_ALARM_USUAL = "KEY_INTENT_USUAL"
  val KEY_INTENT_PAGE_ORDER = "KEY_INTENT_PAGE_ORDER"
}

class AlarmBroadcastReceiver extends BroadcastReceiver {
  override def onReceive(context: Context, receivedIntent: Intent) {
    receivedIntent.getAction match {
      case Intent.ACTION_PACKAGE_REPLACED | Intent.ACTION_BOOT_COMPLETED =>
        NoteStore.rebootAlarmsRealm()

      case AlarmBroadcastReceiver.KEY_INTENT_ALARM_USUAL =>
        val id = receivedIntent.getLongExtra(AlarmUtil.alarmIntentDataKey, -1)
        val note = NoteStore.findByIdRealm(id)
        val pageOrder = PageStore .getPageOrderById(note.parentId)
        if (note.inRubbish != 1) {
          val nm = App.getInstance.getSystemService(Context.NOTIFICATION_SERVICE).asInstanceOf[NotificationManager]
          val notif = makeNotification(note, pageOrder)
          nm.notify(id.asInstanceOf[Int], notif)
        }
        NoteStore.clearAlarmRealm(id)
      case _ =>
    }
  }

  private def makeNotification(note: NoteRealm, pageOrder: Int): Notification = {
    val in = new Intent(App.getInstance, classOf[PageManager])
    in.putExtra(AlarmBroadcastReceiver.KEY_INTENT_PAGE_ORDER, pageOrder)
    val pi = PendingIntent.getActivity(App.getInstance, 0, in, PendingIntent.FLAG_UPDATE_CURRENT)
    val builder = new NotificationCompat.Builder(App.getInstance)
    val content = if (TextUtils.isEmpty(note.checkItems)) "(check list)" else note.content
    builder
      .setSmallIcon(R.drawable.ic_launcher)
      .setTicker(content)
      .setContentText(content)
      .setWhen(System.currentTimeMillis).setAutoCancel(true)
      .setContentIntent(pi)
      .setContentTitle(if (TextUtils.isEmpty(note.title)) "No title" else note.title)
      .build()
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:54,代码来源:AlarmBroadcastReceiver.scala


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