mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Format classes with ktlint
This commit is contained in:
@@ -33,13 +33,19 @@ open class MidnightTimer @Inject constructor() {
|
||||
private val listeners: MutableList<MidnightListener> = LinkedList()
|
||||
private lateinit var executor: ScheduledExecutorService
|
||||
|
||||
@Synchronized fun addListener(listener: MidnightListener) {
|
||||
@Synchronized
|
||||
fun addListener(listener: MidnightListener) {
|
||||
this.listeners.add(listener)
|
||||
}
|
||||
|
||||
@Synchronized fun onPause(): MutableList<Runnable>? = executor.shutdownNow()
|
||||
@Synchronized
|
||||
fun onPause(): MutableList<Runnable>? = executor.shutdownNow()
|
||||
|
||||
@Synchronized fun onResume(delayOffsetInMillis: Long = DateUtils.SECOND_LENGTH, testExecutor: ScheduledExecutorService? = null) {
|
||||
@Synchronized
|
||||
fun onResume(
|
||||
delayOffsetInMillis: Long = DateUtils.SECOND_LENGTH,
|
||||
testExecutor: ScheduledExecutorService? = null
|
||||
) {
|
||||
executor = testExecutor ?: Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate(
|
||||
{ notifyListeners() },
|
||||
@@ -49,9 +55,11 @@ open class MidnightTimer @Inject constructor() {
|
||||
)
|
||||
}
|
||||
|
||||
@Synchronized fun removeListener(listener: MidnightListener) = this.listeners.remove(listener)
|
||||
@Synchronized
|
||||
fun removeListener(listener: MidnightListener) = this.listeners.remove(listener)
|
||||
|
||||
@Synchronized private fun notifyListeners() {
|
||||
@Synchronized
|
||||
private fun notifyListeners() {
|
||||
for (l in listeners) {
|
||||
l.atMidnight()
|
||||
}
|
||||
|
||||
@@ -22,7 +22,16 @@ class MidnightTimerTest : BaseUnitTest() {
|
||||
|
||||
withContext(dispatcher) {
|
||||
DateUtils.setFixedTimeZone(TimeZone.getTimeZone("GMT"))
|
||||
DateUtils.setFixedLocalTime(unixTime(2017, Calendar.JANUARY, 1, 23, 59, DateUtils.MINUTE_LENGTH - 1))
|
||||
DateUtils.setFixedLocalTime(
|
||||
unixTime(
|
||||
2017,
|
||||
Calendar.JANUARY,
|
||||
1,
|
||||
23,
|
||||
59,
|
||||
DateUtils.MINUTE_LENGTH - 1
|
||||
)
|
||||
)
|
||||
|
||||
val suspendedListener = suspendCoroutine<Boolean> { continuation ->
|
||||
MidnightTimer().apply {
|
||||
|
||||
Reference in New Issue
Block a user