com.deque.axe.android.wrappers.AxeEventStream.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axe-devtools-android-core Show documentation
Show all versions of axe-devtools-android-core Show documentation
The Axe Devtools Android Core Library
package com.deque.axe.android.wrappers
import com.deque.axe.android.AxeEvent
import com.deque.axe.android.constants.AxeEventType
import java.util.*
class AxeEventStream : LinkedList() {
@AxeEventType
private val applicableEvents: MutableSet = HashSet()
/**
* Add a new event to the stream.
* @param axeEvent An event.
* @return true if the event was added successfully.
*/
fun addEvent(axeEvent: AxeEvent): Boolean {
if (axeEvent.isViewChangeEvent) {
clear()
}
if (applicableEvents.isNotEmpty()
&& !applicableEvents.contains(axeEvent.eventType)
) {
return false
}
if (this.size == MAX_SIZE) {
removeAt(0)
}
this.add(axeEvent)
return true
}
fun addApplicableEventType(@AxeEventType axeEventType: Int): AxeEventStream {
applicableEvents.add(axeEventType)
return this
}
companion object {
private const val MAX_SIZE = 100
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy