ServiceNotification.kt 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package io.r_a_d.radio2.streamerNotificationService
  2. import android.content.Context
  3. import io.r_a_d.radio2.BaseNotification
  4. import java.util.*
  5. class ServiceNotification(
  6. notificationChannelId: String,
  7. notificationChannel : Int,
  8. notificationId: Int,
  9. notificationImportance: Int
  10. ) : BaseNotification
  11. (
  12. notificationChannelId,
  13. notificationChannel,
  14. notificationId,
  15. notificationImportance
  16. ){
  17. override fun create(c: Context)
  18. {
  19. super.create(c)
  20. update()
  21. }
  22. fun update()
  23. {
  24. val date = Date() // given date
  25. val calendar = Calendar.getInstance() // creates a new calendar instance
  26. calendar.time = date // assigns calendar to given date
  27. val hours = calendar.get(Calendar.HOUR_OF_DAY) // gets hour in 24h format
  28. //val hours_american = calendar.get(Calendar.HOUR) // gets hour in 12h format
  29. val minutes = calendar.get(Calendar.MINUTE)
  30. val seconds = calendar.get(Calendar.SECOND)
  31. builder.setContentTitle("Never miss a stream! Current: ${WorkerStore.instance.streamerName.value}")
  32. builder.setContentText("Last update: ${hours}:${minutes}:${seconds}")
  33. notification = builder.build()
  34. }
  35. }