StreamerNotification.kt 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  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 StreamerNotification(
  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. super.create(c)
  19. val date = Date() // given date
  20. val calendar = Calendar.getInstance() // creates a new calendar instance
  21. calendar.time = date // assigns calendar to given date
  22. val hours = calendar.get(Calendar.HOUR_OF_DAY) // gets hour in 24h format
  23. //val hours_american = calendar.get(Calendar.HOUR) // gets hour in 12h format
  24. val minutes = calendar.get(Calendar.MINUTE) // gets month number, NOTE this is zero based!
  25. builder.setContentTitle("${WorkerStore.instance.streamerName.value} started streaming!")
  26. builder.setContentText("Started at ${hours}:${if (minutes < 10) "0" else ""}${minutes}")
  27. builder.setAutoCancel(true)
  28. super.show()
  29. }
  30. }