Compare commits

...

3 Commits

Author SHA1 Message Date
865f335b25 Fix lint errors 2023-03-25 16:26:24 +02:00
6b1e89eda8 Update parsers 2023-03-25 16:04:57 +02:00
0dbaf919e2 Remove pages duplicates #309 2023-03-25 15:48:39 +02:00
4 changed files with 24 additions and 9 deletions

View File

@@ -15,8 +15,8 @@ android {
applicationId 'org.koitharu.kotatsu'
minSdkVersion 21
targetSdkVersion 33
versionCode 522
versionName '4.4.6'
versionCode 523
versionName '4.4.7'
generatedDensities = []
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -59,7 +59,7 @@ android {
]
}
lint {
abortOnError false
abortOnError true
disable 'MissingTranslation', 'PrivateResource', 'NotifyDataSetChanged'
}
testOptions {
@@ -79,7 +79,7 @@ afterEvaluate {
}
dependencies {
//noinspection GradleDependency
implementation('com.github.KotatsuApp:kotatsu-parsers:cc418570d5') {
implementation('com.github.KotatsuApp:kotatsu-parsers:a3ffecc00f') {
exclude group: 'org.json', module: 'json'
}

View File

@@ -1,5 +1,6 @@
package org.koitharu.kotatsu.core.parser
import android.util.Log
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -9,6 +10,7 @@ import kotlinx.coroutines.currentCoroutineContext
import okhttp3.Headers
import okhttp3.Interceptor
import okhttp3.Response
import org.koitharu.kotatsu.BuildConfig
import org.koitharu.kotatsu.core.cache.ContentCache
import org.koitharu.kotatsu.core.cache.SafeDeferred
import org.koitharu.kotatsu.core.prefs.SourceSettings
@@ -77,7 +79,7 @@ class RemoteMangaRepository(
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
cache.getPages(source, chapter.url)?.let { return it }
val pages = asyncSafe {
parser.getPages(chapter)
parser.getPages(chapter).distinctById()
}
cache.putPages(source, chapter.url, pages)
return pages.await()
@@ -108,4 +110,20 @@ class RemoteMangaRepository(
},
)
}
private fun List<MangaPage>.distinctById(): List<MangaPage> {
if (isEmpty()) {
return emptyList()
}
val result = ArrayList<MangaPage>(size)
val set = HashSet<Long>(size)
for (page in this) {
if (set.add(page.id)) {
result.add(page)
} else if (BuildConfig.DEBUG) {
Log.w(null, "Duplicate page: $page")
}
}
return result
}
}

View File

@@ -4,5 +4,4 @@
<dimen name="grid_spacing_outer">2dp</dimen>
<dimen name="preferred_grid_width">140dp</dimen>
<dimen name="bottom_sheet_width">420dp</dimen>
<dimen name="fragment_horizontal_margin">48dp</dimen>
</resources>
</resources>

View File

@@ -405,8 +405,6 @@
<string name="show_suspicious_content">显示可疑内容</string>
<string name="theme_name_dynamic">动态</string>
<string name="color_theme">颜色方案</string>
<string name="theme_name_mint">薄荷绿</string>
<string name="theme_name_october">October</string>
<string name="show_in_grid_view">用网格视图显示</string>
<string name="theme_name_miku">Miku</string>
<string name="theme_name_asuka">Asuka</string>