import net.pterodactylus.sone.data.*
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.notify.*
-import net.pterodactylus.util.notify.*
import java.util.concurrent.Executors.*
import java.util.function.*
import javax.inject.*
bind<SoneLockedOnStartupHandler>().asSingleton()
bind<NewSoneHandler>().asSingleton()
bind<NewRemotePostHandler>().asSingleton()
+ bind<SoneLockedHandler>().asSingleton()
}
@Provides
ListNotification<Sone>("sones-locked-notification", "sones", loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"), dismissable = true)
@Provides
- @Singleton
- fun getSoneLockedHandler(notificationManager: NotificationManager, @Named("soneLocked") soneLockedNotification: ListNotification<Sone>) =
- SoneLockedHandler(notificationManager, soneLockedNotification, newScheduledThreadPool(1))
+ fun getScheduledExecutorService() =
+ newScheduledThreadPool(1)
private inline fun <reified T> bind(): AnnotatedBindingBuilder<T> = bind(T::class.java)
private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java)
import net.pterodactylus.util.notify.*
import java.util.concurrent.*
import java.util.concurrent.atomic.*
+import javax.inject.*
/**
* Handler for [SoneLockedEvent]s and [SoneUnlockedEvent]s that can schedule notifications after
* a certain timeout.
*/
-class SoneLockedHandler(private val notificationManager: NotificationManager, private val notification: ListNotification<Sone>, private val executor: ScheduledExecutorService) {
+class SoneLockedHandler @Inject constructor(
+ private val notificationManager: NotificationManager,
+ @Named("soneLocked") private val notification: ListNotification<Sone>,
+ private val executor: ScheduledExecutorService) {
private val future: AtomicReference<ScheduledFuture<*>> = AtomicReference()