class SoneLockedHandler @Inject constructor(
private val notificationManager: NotificationManager,
@Named("soneLocked") private val notification: ListNotification<Sone>,
class SoneLockedHandler @Inject constructor(
private val notificationManager: NotificationManager,
@Named("soneLocked") private val notification: ListNotification<Sone>,
private val future: AtomicReference<ScheduledFuture<*>> = AtomicReference()
@Subscribe
fun soneLocked(soneLockedEvent: SoneLockedEvent) {
synchronized(future) {
private val future: AtomicReference<ScheduledFuture<*>> = AtomicReference()
@Subscribe
fun soneLocked(soneLockedEvent: SoneLockedEvent) {
synchronized(future) {
- future.get()?.also { cancelPreviousFuture(it, soneLockedEvent.sone) }
- future.set(executor.schedule(showNotification(soneLockedEvent.sone), 5, TimeUnit.MINUTES))
+ notification.add(soneLockedEvent.sone)
+ future.get()?.also(this::cancelPreviousFuture)
+ future.set(executor.schedule(::showNotification, 5, TimeUnit.MINUTES))