Remove usage of .not() where possible

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Secozzi 2024-05-14 08:08:37 +02:00
parent d1645e0290
commit 98633df396
No known key found for this signature in database
GPG key ID: 71E9C97D8DDC2662
22 changed files with 37 additions and 37 deletions

View file

@ -23,7 +23,7 @@ class GetAnimeExtensionSources(
AnimeExtensionSourceItem(
source = source,
enabled = source.isEnabled(),
labelAsName = isMultiSource && isMultiLangSingleSource.not(),
labelAsName = isMultiSource && !isMultiLangSingleSource,
)
}
}

View file

@ -22,9 +22,9 @@ class GetAnimeExtensionsByType(
extensionManager.availableExtensionsFlow,
) { _activeLanguages, _installed, _untrusted, _available ->
val (updates, installed) = _installed
.filter { (showNsfwSources || it.isNsfw.not()) }
.filter { (showNsfwSources || !it.isNsfw) }
.sortedWith(
compareBy<AnimeExtension.Installed> { it.isObsolete.not() }
compareBy<AnimeExtension.Installed> { !it.isObsolete }
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name },
)
.partition { it.hasUpdate }
@ -36,7 +36,7 @@ class GetAnimeExtensionsByType(
.filter { extension ->
_installed.none { it.pkgName == extension.pkgName } &&
_untrusted.none { it.pkgName == extension.pkgName } &&
(showNsfwSources || extension.isNsfw.not())
(showNsfwSources || !extension.isNsfw)
}
.flatMap { ext ->
if (ext.sources.isEmpty()) {

View file

@ -23,7 +23,7 @@ class GetExtensionSources(
MangaExtensionSourceItem(
source = source,
enabled = source.isEnabled(),
labelAsName = isMultiSource && isMultiLangSingleSource.not(),
labelAsName = isMultiSource && !isMultiLangSingleSource,
)
}
}

View file

@ -22,9 +22,9 @@ class GetMangaExtensionsByType(
extensionManager.availableExtensionsFlow,
) { _activeLanguages, _installed, _untrusted, _available ->
val (updates, installed) = _installed
.filter { (showNsfwSources || it.isNsfw.not()) }
.filter { (showNsfwSources || !it.isNsfw) }
.sortedWith(
compareBy<MangaExtension.Installed> { it.isObsolete.not() }
compareBy<MangaExtension.Installed> { !it.isObsolete }
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name },
)
.partition { it.hasUpdate }
@ -36,7 +36,7 @@ class GetMangaExtensionsByType(
.filter { extension ->
_installed.none { it.pkgName == extension.pkgName } &&
_untrusted.none { it.pkgName == extension.pkgName } &&
(showNsfwSources || extension.isNsfw.not())
(showNsfwSources || !extension.isNsfw)
}
.flatMap { ext ->
if (ext.sources.isEmpty()) {

View file

@ -173,7 +173,7 @@ class SyncChaptersWithSource(
var updatedToAdd = newChapters.map { toAddItem ->
var chapter = toAddItem.copy(dateFetch = nowMillis + itemCount--)
if (chapter.isRecognizedNumber.not() || chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
if (!chapter.isRecognizedNumber || chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
chapter = chapter.copy(
read = chapter.chapterNumber in deletedReadChapterNumbers,

View file

@ -173,7 +173,7 @@ class SyncEpisodesWithSource(
var updatedToAdd = newEpisodes.map { toAddItem ->
var episode = toAddItem.copy(dateFetch = nowMillis + itemCount--)
if (episode.isRecognizedNumber.not() || episode.episodeNumber !in deletedEpisodeNumbers) return@map episode
if (!episode.isRecognizedNumber || episode.episodeNumber !in deletedEpisodeNumbers) return@map episode
episode = episode.copy(
seen = episode.episodeNumber in deletedSeenEpisodeNumbers,

View file

@ -35,15 +35,15 @@ class GetAnimeSourcesWithFavoriteCount(
when (sorting) {
SetMigrateSorting.Mode.ALPHABETICAL -> {
when {
a.first.isStub && b.first.isStub.not() -> -1
b.first.isStub && a.first.isStub.not() -> 1
a.first.isStub && !b.first.isStub -> -1
b.first.isStub && !a.first.isStub -> 1
else -> a.first.name.lowercase().compareToWithCollator(b.first.name.lowercase())
}
}
SetMigrateSorting.Mode.TOTAL -> {
when {
a.first.isStub && b.first.isStub.not() -> -1
b.first.isStub && a.first.isStub.not() -> 1
a.first.isStub && !b.first.isStub -> -1
b.first.isStub && !a.first.isStub -> 1
else -> a.second.compareTo(b.second)
}
}

View file

@ -35,15 +35,15 @@ class GetMangaSourcesWithFavoriteCount(
when (sorting) {
SetMigrateSorting.Mode.ALPHABETICAL -> {
when {
a.first.isStub && b.first.isStub.not() -> -1
b.first.isStub && a.first.isStub.not() -> 1
a.first.isStub && !b.first.isStub -> -1
b.first.isStub && !a.first.isStub -> 1
else -> a.first.name.lowercase().compareToWithCollator(b.first.name.lowercase())
}
}
SetMigrateSorting.Mode.TOTAL -> {
when {
a.first.isStub && b.first.isStub.not() -> -1
b.first.isStub && a.first.isStub.not() -> 1
a.first.isStub && !b.first.isStub -> -1
b.first.isStub && !a.first.isStub -> 1
else -> a.second.compareTo(b.second)
}
}

View file

@ -29,7 +29,7 @@ fun AnimeTrack.toDbTrack(): DbAnimeTrack = DbAnimeTrack.create(trackerId).also {
}
fun DbAnimeTrack.toDomainTrack(idRequired: Boolean = true): AnimeTrack? {
val trackId = id ?: if (idRequired.not()) -1 else return null
val trackId = id ?: if (!idRequired) -1 else return null
return AnimeTrack(
id = trackId,
animeId = anime_id,

View file

@ -29,7 +29,7 @@ fun MangaTrack.toDbTrack(): DbMangaTrack = DbMangaTrack.create(trackerId).also {
}
fun DbMangaTrack.toDomainTrack(idRequired: Boolean = true): MangaTrack? {
val trackId = id ?: if (idRequired.not()) -1 else return null
val trackId = id ?: if (!idRequired) -1 else return null
return MangaTrack(
id = trackId,
mangaId = manga_id,

View file

@ -365,13 +365,13 @@ class AnimeDownloadManager(
val capitalizationChanged = oldFolder.name.equals(newName, ignoreCase = true)
if (capitalizationChanged) {
val tempName = newName + AnimeDownloader.TMP_DIR_SUFFIX
if (oldFolder.renameTo(tempName).not()) {
if (!oldFolder.renameTo(tempName)) {
logcat(LogPriority.ERROR) { "Failed to rename source download folder: ${oldFolder.name}" }
return
}
}
if (oldFolder.renameTo(newName).not()) {
if (!oldFolder.renameTo(newName)) {
logcat(LogPriority.ERROR) { "Failed to rename source download folder: ${oldFolder.name}" }
}
}

View file

@ -135,7 +135,7 @@ class AnimeDownloadProvider(
val newEpisodeName = sanitizeEpisodeName(episodeName)
return DiskUtil.buildValidFilename(
when {
episodeScanlator.isNullOrBlank().not() -> "${episodeScanlator}_$newEpisodeName"
!episodeScanlator.isNullOrBlank() -> "${episodeScanlator}_$newEpisodeName"
else -> newEpisodeName
},
)

View file

@ -357,13 +357,13 @@ class MangaDownloadManager(
val capitalizationChanged = oldFolder.name.equals(newName, ignoreCase = true)
if (capitalizationChanged) {
val tempName = newName + MangaDownloader.TMP_DIR_SUFFIX
if (oldFolder.renameTo(tempName).not()) {
if (!oldFolder.renameTo(tempName)) {
logcat(LogPriority.ERROR) { "Failed to rename source download folder: ${oldFolder.name}" }
return
}
}
if (oldFolder.renameTo(newName).not()) {
if (!oldFolder.renameTo(newName)) {
logcat(LogPriority.ERROR) { "Failed to rename source download folder: ${oldFolder.name}" }
}
}

View file

@ -135,7 +135,7 @@ class MangaDownloadProvider(
val newChapterName = sanitizeChapterName(chapterName)
return DiskUtil.buildValidFilename(
when {
chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$newChapterName"
!chapterScanlator.isNullOrBlank() -> "${chapterScanlator}_$newChapterName"
else -> newChapterName
},
)

View file

@ -275,7 +275,7 @@ class Anilist(id: Long) :
if (track.status != COMPLETED) {
val isRereading = track.status == REPEATING
track.status = if (isRereading.not() && hasReadChapters) READING else track.status
track.status = if (!isRereading && hasReadChapters) READING else track.status
}
update(track)
@ -295,7 +295,7 @@ class Anilist(id: Long) :
if (track.status != COMPLETED) {
val isRereading = track.status == REPEATING_ANIME
track.status = if (isRereading.not() && hasReadChapters) WATCHING else track.status
track.status = if (!isRereading && hasReadChapters) WATCHING else track.status
}
update(track)

View file

@ -168,7 +168,7 @@ class MyAnimeList(id: Long) :
if (track.status != COMPLETED) {
val isRereading = track.status == REREADING
track.status = if (isRereading.not() && hasReadChapters) READING else track.status
track.status = if (!isRereading && hasReadChapters) READING else track.status
}
update(track)
@ -188,7 +188,7 @@ class MyAnimeList(id: Long) :
if (track.status != COMPLETED) {
val isRewatching = track.status == REWATCHING
track.status = if (isRewatching.not() && hasSeenEpisodes) WATCHING else track.status
track.status = if (!isRewatching && hasSeenEpisodes) WATCHING else track.status
}
update(track)

View file

@ -116,7 +116,7 @@ class Shikimori(id: Long) :
if (track.status != COMPLETED) {
val isRereading = track.status == REREADING
track.status = if (isRereading.not() && hasReadChapters) READING else track.status
track.status = if (!isRereading && hasReadChapters) READING else track.status
}
update(track)
@ -136,7 +136,7 @@ class Shikimori(id: Long) :
if (track.status != COMPLETED) {
val isRereading = track.status == REREADING
track.status = if (isRereading.not() && hasReadChapters) READING else track.status
track.status = if (!isRereading && hasReadChapters) READING else track.status
}
update(track)

View file

@ -90,7 +90,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : Viewer {
pager.addOnPageChangeListener(
object : ViewPager.SimpleOnPageChangeListener() {
override fun onPageSelected(position: Int) {
if (activity.isScrollingThroughPages.not()) {
if (!activity.isScrollingThroughPages) {
activity.hideMenu()
}
onPageChange(position)

View file

@ -89,7 +89,7 @@ internal class RateLimitInterceptor(
while (requestQueue.size >= permits) { // queue is full, remove expired entries
val periodStart = SystemClock.elapsedRealtime() - rateLimitMillis
var hasRemovedExpired = false
while (requestQueue.isEmpty().not() && requestQueue.first <= periodStart) {
while (!requestQueue.isEmpty() && requestQueue.first <= periodStart) {
requestQueue.removeFirst()
hasRemovedExpired = true
}

View file

@ -20,7 +20,7 @@ class GetApplicationRelease(
val now = Instant.now()
// Limit checks to once every 3 days at most
if (arguments.forceCheck.not() && now.isBefore(
if (!arguments.forceCheck && now.isBefore(
Instant.ofEpochMilli(lastChecked.get()).plus(3, ChronoUnit.DAYS),
)
) {

View file

@ -24,7 +24,7 @@ class StubAnimeSource(
throw AnimeSourceNotInstalledException()
override fun toString(): String =
if (isInvalid.not()) "$name (${lang.uppercase()})" else id.toString()
if (!isInvalid) "$name (${lang.uppercase()})" else id.toString()
companion object {
fun from(source: AnimeSource): StubAnimeSource {

View file

@ -24,7 +24,7 @@ class StubMangaSource(
throw SourceNotInstalledException()
override fun toString(): String =
if (isInvalid.not()) "$name (${lang.uppercase()})" else id.toString()
if (!isInvalid) "$name (${lang.uppercase()})" else id.toString()
companion object {
fun from(source: MangaSource): StubMangaSource {