Extract source api from app module (#8014)
* Extract source api from app module
* Extract source online api from app module
(cherry picked from commit 86fe850794)
# Conflicts:
# app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt
# core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
# source-api/src/main/java/eu/kanade/tachiyomi/source/Source.kt
# source-api/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
package exh.util
|
||||
|
||||
fun <C : Collection<R>, R> C.nullIfEmpty() = ifEmpty { null }
|
||||
@@ -0,0 +1,3 @@
|
||||
package exh.util
|
||||
|
||||
operator fun StringBuilder.plusAssign(other: String) { append(other) }
|
||||
@@ -0,0 +1,20 @@
|
||||
package exh.util
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
fun Collection<String>.trimAll() = map { it.trim() }
|
||||
fun Collection<String>.dropBlank() = filter { it.isNotBlank() }
|
||||
fun Collection<String>.dropEmpty() = filter { it.isNotEmpty() }
|
||||
|
||||
private val articleRegex by lazy { "^(an|a|the) ".toRegex(RegexOption.IGNORE_CASE) }
|
||||
|
||||
fun String.removeArticles(): String {
|
||||
return replace(articleRegex, "")
|
||||
}
|
||||
|
||||
fun String.trimOrNull() = trim().nullIfBlank()
|
||||
|
||||
fun String.nullIfBlank(): String? = ifBlank { null }
|
||||
|
||||
fun String.capitalize(locale: Locale = Locale.getDefault()) =
|
||||
replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }
|
||||
Reference in New Issue
Block a user