mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-20 13:38:34 +01:00
using generic list for the circular cache instead of a fixed string array
This commit is contained in:
parent
10b753ad61
commit
84b44f6093
@ -19,14 +19,14 @@ package im.vector.app.features.notifications
|
||||
/**
|
||||
* A FIFO circular buffer of strings
|
||||
*/
|
||||
class CircularStringCache(cacheSize: Int) {
|
||||
class CircularCache<T>(cacheSize: Int) {
|
||||
|
||||
private val cache = Array(cacheSize) { "" }
|
||||
private val cache = ArrayList<T>(initialCapacity = cacheSize)
|
||||
private var writeIndex = 0
|
||||
|
||||
fun contains(key: String): Boolean = cache.contains(key)
|
||||
fun contains(key: T): Boolean = cache.contains(key)
|
||||
|
||||
fun put(key: String) {
|
||||
fun put(key: T) {
|
||||
if (writeIndex == cache.size - 1) {
|
||||
writeIndex = 0
|
||||
}
|
@ -89,7 +89,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
||||
* Acts as a notification debouncer to stop already dismissed push notifications from
|
||||
* displaying again when the /sync response is delayed.
|
||||
*/
|
||||
private val seenEventIds = CircularStringCache(cacheSize = 25)
|
||||
private val seenEventIds = CircularCache<String>(cacheSize = 25)
|
||||
|
||||
/**
|
||||
Should be called as soon as a new event is ready to be displayed.
|
||||
|
Loading…
Reference in New Issue
Block a user