Using maxByOrNull in more places

needed for newer versions of kotlin
This commit is contained in:
Jays2Kings 2021-05-27 15:36:20 -04:00
parent 1f54bacb98
commit da8d6f3fa4
5 changed files with 5 additions and 5 deletions

View File

@ -73,7 +73,7 @@ class SmartSearchEngine(
} }
} }
return eligibleManga.maxBy { it.dist }?.manga return eligibleManga.maxByOrNull { it.dist }?.manga
} }
private fun removeTextInBrackets(text: String, readForward: Boolean): String { private fun removeTextInBrackets(text: String, readForward: Boolean): String {
val bracketPairs = listOf( val bracketPairs = listOf(

View File

@ -109,7 +109,7 @@ class MigrationPresenter(
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking() val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
val maxChapterRead = val maxChapterRead =
prevMangaChapters.filter { it.read }.maxBy { it.chapter_number }?.chapter_number prevMangaChapters.filter { it.read }.maxOfOrNull { it.chapter_number }
if (maxChapterRead != null) { if (maxChapterRead != null) {
val dbChapters = db.getChapters(manga).executeAsBlocking() val dbChapters = db.getChapters(manga).executeAsBlocking()
for (chapter in dbChapters) { for (chapter in dbChapters) {

View File

@ -204,7 +204,7 @@ class MigrationListController(bundle: Bundle? = null) :
} }
} }
} }
}.mapNotNull { it.await() }.maxBy { it.second }?.first }.mapNotNull { it.await() }.maxByOrNull { it.second }?.first
} else { } else {
validSources.forEachIndexed { index, source -> validSources.forEachIndexed { index, source ->
val searchResult = try { val searchResult = try {

View File

@ -159,7 +159,7 @@ class MigrationProcessHolder(
val mangaChapters = db.getChapters(manga).executeAsBlocking() val mangaChapters = db.getChapters(manga).executeAsBlocking()
unreadDownloadBadge.badgeView.setChapters(mangaChapters.size) unreadDownloadBadge.badgeView.setChapters(mangaChapters.size)
val latestChapter = mangaChapters.maxBy { it.chapter_number }?.chapter_number ?: -1f val latestChapter = mangaChapters.maxOfOrNull { it.chapter_number } ?: -1f
if (latestChapter > 0f) { if (latestChapter > 0f) {
subtitle.text = root.context.getString( subtitle.text = root.context.getString(

View File

@ -286,7 +286,7 @@ fun Context.openInBrowser(url: String, forceBrowser: Boolean): Boolean {
) )
.build() .build()
if (forceBrowser) { if (forceBrowser) {
val packages = getCustomTabsPackages().maxBy { it.preferredOrder } val packages = getCustomTabsPackages().maxByOrNull { it.preferredOrder }
val processName = packages?.activityInfo?.processName ?: return false val processName = packages?.activityInfo?.processName ?: return false
intent.intent.`package` = processName intent.intent.`package` = processName
} }