Remove usage of .not() where possible

This commit is contained in:
AntsyLich 2024-01-21 18:56:17 +06:00
parent a024218410
commit 39407407f2
No known key found for this signature in database
14 changed files with 20 additions and 20 deletions

View File

@ -163,7 +163,7 @@ class SyncChaptersWithSource(
var updatedToAdd = newChapters.map { toAddItem -> var updatedToAdd = newChapters.map { toAddItem ->
var chapter = toAddItem.copy(dateFetch = nowMillis + itemCount--) 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( chapter = chapter.copy(
read = chapter.chapterNumber in deletedReadChapterNumbers, read = chapter.chapterNumber in deletedReadChapterNumbers,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -185,7 +185,7 @@ class Anilist(id: Long) : BaseTracker(id, "AniList"), DeletableTracker {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
val isRereading = track.status == REREADING 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) update(track)

View File

@ -104,7 +104,7 @@ class MyAnimeList(id: Long) : BaseTracker(id, "MyAnimeList"), DeletableTracker {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
val isRereading = track.status == REREADING 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) update(track)

View File

@ -72,7 +72,7 @@ class Shikimori(id: Long) : BaseTracker(id, "Shikimori"), DeletableTracker {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
val isRereading = track.status == REREADING 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) update(track)

View File

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

View File

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

View File

@ -20,7 +20,7 @@ class GetApplicationRelease(
val now = Instant.now() val now = Instant.now()
// Limit checks to once every 3 days at most // 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), Instant.ofEpochMilli(lastChecked.get()).plus(3, ChronoUnit.DAYS),
) )
) { ) {

View File

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