Address some Kotlin language warnings

(cherry picked from commit 3854995ef23df814da32ef7bc6522007e7882f35)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt
#	app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterRecognition.kt
This commit is contained in:
arkon 2021-06-01 17:53:51 -04:00 committed by Jobobby04
parent d5b72c3d3a
commit 65249a4ee7
8 changed files with 14 additions and 14 deletions

View File

@ -99,9 +99,9 @@ class LocalSource(private val context: Context) : CatalogueSource {
when (state?.index) {
0 -> {
mangaDirs = if (state.ascending) {
mangaDirs.sortedBy { it.name.toLowerCase(Locale.ENGLISH) }
mangaDirs.sortedBy { it.name.lowercase(Locale.ENGLISH) }
} else {
mangaDirs.sortedByDescending { it.name.toLowerCase(Locale.ENGLISH) }
mangaDirs.sortedByDescending { it.name.lowercase(Locale.ENGLISH) }
}
}
1 -> {
@ -294,7 +294,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
}
private fun isSupportedFile(extension: String): Boolean {
return extension.toLowerCase(Locale.ROOT) in SUPPORTED_ARCHIVE_TYPES
return extension.lowercase() in SUPPORTED_ARCHIVE_TYPES
}
fun getFormat(chapter: SChapter): Format {

View File

@ -83,7 +83,7 @@ abstract class HttpSource : CatalogueSource {
* Note the generated id sets the sign bit to 0.
*/
override val id by lazy {
val key = "${name.toLowerCase()}/$lang/$versionId"
val key = "${name.lowercase()}/$lang/$versionId"
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
(0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
}
@ -111,7 +111,7 @@ abstract class HttpSource : CatalogueSource {
/**
* Visible name of the source.
*/
override fun toString() = "$name (${lang.toUpperCase()})"
override fun toString() = "$name (${lang.uppercase()})"
/**
* Returns an observable containing a page with a list of manga. Normally it's not needed to

View File

@ -46,7 +46,7 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
extension.isNsfw && shouldLabelNsfw -> itemView.context.getString(R.string.ext_nsfw_short).plusRepo(extension)
else -> "".plusRepo(extension)
// SY <--
}.toUpperCase()
}.uppercase()
binding.image.clear()
if (extension is Extension.Available) {

View File

@ -114,7 +114,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
.forEach {
val preferenceBlock = {
it.value
.sortedWith(compareBy({ !it.isEnabled() }, { it.name.toLowerCase() }))
.sortedWith(compareBy({ !it.isEnabled() }, { it.name.lowercase() }))
.forEach { source ->
val sourcePrefs = mutableListOf<Preference>()

View File

@ -35,7 +35,7 @@ class MigrationSourcesPresenter(
val source = sourceManager.getOrStub(it.key)
SourceItem(source, it.value.size, header)
}
.sortedBy { it.source.name.toLowerCase() }
.sortedBy { it.source.name.lowercase() }
.toList()
}
}

View File

@ -181,7 +181,7 @@ class SourcePresenter(
return sourceManager.getVisibleCatalogueSources()
.filter { it.lang in languages }
.filterNot { it.id.toString() in disabledSourceIds }
.sortedBy { "(${it.lang}) ${it.name.toLowerCase()}" } +
.sortedBy { "(${it.lang}) ${it.name.lowercase()}" } +
sourceManager.get(LocalSource.ID) as LocalSource
}

View File

@ -106,7 +106,7 @@ open class GlobalSearchPresenter(
return sourceManager.getVisibleCatalogueSources()
.filter { it.lang in languages }
.filterNot { it.id.toString() in disabledSourceIds }
.sortedWith(compareBy({ it.id.toString() !in pinnedSourceIds }, { "${it.name.toLowerCase()} (${it.lang})" }))
.sortedWith(compareBy({ it.id.toString() !in pinnedSourceIds }, { "${it.name.lowercase()} (${it.lang})" }))
}
private fun getSourcesToQuery(): List<CatalogueSource> {
@ -187,7 +187,7 @@ open class GlobalSearchPresenter(
{ it.results.isNullOrEmpty() },
// Same as initial sort, i.e. pinned first then alphabetically
{ it.source.id.toString() !in pinnedSourceIds },
{ "${it.source.name.toLowerCase()} (${it.source.lang})" }
{ "${it.source.name.lowercase()} (${it.source.lang})" }
)
)
}

View File

@ -44,7 +44,7 @@ object ChapterRecognition {
}
// Get chapter title with lower case
var name = chapter.name.toLowerCase()
var name = chapter.name.lowercase()
// Remove comma's from chapter.
name = name.replace(',', '.')
@ -77,7 +77,7 @@ object ChapterRecognition {
}
// Remove manga title from chapter title.
val nameWithoutManga = name.replace(/* SY --> */ manga.originalTitle.toLowerCase()/* SY <-- */, "").trim()
val nameWithoutManga = name.replace(/* SY --> */ manga.originalTitle.lowercase()/* SY <-- */, "").trim()
// Check if first value is number after title remove.
if (updateChapter(withoutManga.find(nameWithoutManga), chapter)) {
@ -147,6 +147,6 @@ object ChapterRecognition {
* x.a -> x.1, x.b -> x.2, etc
*/
private fun parseAlphaPostFix(alpha: Char): Float {
return ("0." + (alpha.toInt() - 96).toString()).toFloat()
return ("0." + (alpha.code - 96).toString()).toFloat()
}
}