Merge branch 'devel' into feature/nextgen
This commit is contained in:
@@ -14,8 +14,8 @@ android {
|
||||
applicationId 'org.koitharu.kotatsu'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 32
|
||||
versionCode 415
|
||||
versionName '3.4.3'
|
||||
versionCode 416
|
||||
versionName '3.4.4'
|
||||
generatedDensities = []
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -80,11 +80,11 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation('com.github.nv95:kotatsu-parsers:c5c84c8630') {
|
||||
implementation('com.github.nv95:kotatsu-parsers:6af8cec134') {
|
||||
exclude group: 'org.json', module: 'json'
|
||||
}
|
||||
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.8.0'
|
||||
implementation 'androidx.activity:activity-ktx:1.5.0'
|
||||
@@ -121,21 +121,21 @@ dependencies {
|
||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
||||
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||
|
||||
implementation 'ch.acra:acra-mail:5.9.3'
|
||||
implementation 'ch.acra:acra-dialog:5.9.3'
|
||||
implementation 'ch.acra:acra-mail:5.9.5'
|
||||
implementation 'ch.acra:acra-dialog:5.9.5'
|
||||
|
||||
debugImplementation 'org.jsoup:jsoup:1.15.1'
|
||||
debugImplementation 'org.jsoup:jsoup:1.15.2'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.3'
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||
|
||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||
androidTestImplementation 'androidx.test:rules:1.4.0'
|
||||
androidTestImplementation 'androidx.test:core-ktx:1.4.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
|
||||
|
||||
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.3'
|
||||
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||
androidTestImplementation 'io.insert-koin:koin-test:3.2.0'
|
||||
androidTestImplementation 'io.insert-koin:koin-test-junit4:3.2.0'
|
||||
|
||||
|
||||
@@ -89,26 +89,25 @@ class MultiSearchViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun searchImpl(q: String) {
|
||||
private suspend fun searchImpl(q: String) = coroutineScope {
|
||||
val sources = settings.getMangaSources(includeHidden = false)
|
||||
val dispatcher = Dispatchers.Default.limitedParallelism(MAX_PARALLELISM)
|
||||
val deferredList = coroutineScope {
|
||||
sources.map { source ->
|
||||
async(dispatcher) {
|
||||
runCatching {
|
||||
val list = MangaRepository(source).getList(offset = 0, query = q)
|
||||
.toUi(ListMode.GRID)
|
||||
if (list.isNotEmpty()) {
|
||||
MultiSearchListModel(source, list.size > MIN_HAS_MORE_ITEMS, list)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}.onFailure {
|
||||
it.printStackTraceDebug()
|
||||
val deferredList = sources.map { source ->
|
||||
async(dispatcher) {
|
||||
runCatching {
|
||||
val list = MangaRepository(source).getList(offset = 0, query = q)
|
||||
.toUi(ListMode.GRID)
|
||||
if (list.isNotEmpty()) {
|
||||
MultiSearchListModel(source, list.size > MIN_HAS_MORE_ITEMS, list)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}.onFailure {
|
||||
it.printStackTraceDebug()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val errors = ArrayList<Throwable>()
|
||||
for (deferred in deferredList) {
|
||||
deferred.await()
|
||||
@@ -120,13 +119,12 @@ class MultiSearchViewModel(
|
||||
errors.add(it)
|
||||
}
|
||||
}
|
||||
if (listData.value.isNotEmpty()) {
|
||||
return
|
||||
}
|
||||
when (errors.size) {
|
||||
0 -> Unit
|
||||
1 -> throw errors[0]
|
||||
else -> throw CompositeException(errors)
|
||||
if (listData.value.isEmpty()) {
|
||||
when (errors.size) {
|
||||
0 -> Unit
|
||||
1 -> throw errors[0]
|
||||
else -> throw CompositeException(errors)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user