diff --git a/app/build.gradle b/app/build.gradle index b65af9ece..9db761d08 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,8 +16,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdk = 21 targetSdk = 34 - versionCode = 626 - versionName = '6.7.4' + versionCode = 627 + versionName = '6.7.5' generatedDensities = [] testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' ksp { @@ -82,7 +82,7 @@ afterEvaluate { } dependencies { //noinspection GradleDependency - implementation('com.github.KotatsuApp:kotatsu-parsers:103f578c61') { + implementation('com.github.KotatsuApp:kotatsu-parsers:b7613606c0') { exclude group: 'org.json', module: 'json' } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/domain/ChapterPages.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/domain/ChapterPages.kt index 7175f53f2..c86159033 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/domain/ChapterPages.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/domain/ChapterPages.kt @@ -14,6 +14,7 @@ class ChapterPages private constructor(private val pages: ArrayDeque val chaptersSize: Int get() = indices.size() + @Synchronized fun removeFirst() { val chapterId = pages.first().chapterId indices.remove(chapterId) @@ -25,6 +26,7 @@ class ChapterPages private constructor(private val pages: ArrayDeque shiftIndices(delta) } + @Synchronized fun removeLast() { val chapterId = pages.last().chapterId indices.remove(chapterId) @@ -33,17 +35,28 @@ class ChapterPages private constructor(private val pages: ArrayDeque } } - fun addLast(id: Long, newPages: List) { + @Synchronized + fun addLast(id: Long, newPages: List): Boolean { + if (id in indices) { + return false + } indices.put(id, pages.size until (pages.size + newPages.size)) pages.addAll(newPages) + return true } - fun addFirst(id: Long, newPages: List) { + @Synchronized + fun addFirst(id: Long, newPages: List): Boolean { + if (id in indices) { + return false + } shiftIndices(newPages.size) indices.put(id, newPages.indices) pages.addAll(0, newPages) + return true } + @Synchronized fun clear() { indices.clear() pages.clear() @@ -58,7 +71,7 @@ class ChapterPages private constructor(private val pages: ArrayDeque return pages.subList(range.first, range.last + 1) } - operator fun contains(chapterId: Long) = indices.contains(chapterId) + operator fun contains(chapterId: Long) = chapterId in indices private fun shiftIndices(delta: Int) { for (i in 0 until indices.size()) {