Replace elvis operators with .orEmpty where possible

This commit is contained in:
Jobobby04 2020-11-04 22:10:13 -05:00
parent 015c610205
commit 079dd953bd
23 changed files with 59 additions and 59 deletions

View File

@ -58,7 +58,7 @@ class CategoryGetResolver : DefaultGetResolver<Category>() {
// SY --> // SY -->
val orderString = cursor.getString(cursor.getColumnIndex(COL_MANGA_ORDER)) val orderString = cursor.getString(cursor.getColumnIndex(COL_MANGA_ORDER))
mangaOrder = orderString?.split("/")?.mapNotNull { it.toLongOrNull() } ?: emptyList() mangaOrder = orderString?.split("/")?.mapNotNull { it.toLongOrNull() }.orEmpty()
// SY <-- // SY <--
} }
} }

View File

@ -229,13 +229,13 @@ class DownloadManager(/* SY private */ val context: Context) {
* return the list of all manga folders * return the list of all manga folders
*/ */
fun getMangaFolders(source: Source): List<UniFile> { fun getMangaFolders(source: Source): List<UniFile> {
return provider.findSourceDir(source)?.listFiles()?.toList() ?: emptyList() return provider.findSourceDir(source)?.listFiles()?.toList().orEmpty()
} }
/** /**
* Deletes the directories of chapters that were read or have no match * Deletes the directories of chapters that were read or have no match
* *
* @param chapters the list of chapters to delete. * @param allChapters the list of chapters to delete.
* @param manga the manga of the chapters. * @param manga the manga of the chapters.
* @param source the source of the chapters. * @param source the source of the chapters.
*/ */

View File

@ -9,7 +9,7 @@ interface UrlImportableSource : Source {
val matchingHosts: List<String> val matchingHosts: List<String>
fun matchesUri(uri: Uri): Boolean { fun matchesUri(uri: Uri): Boolean {
return (uri.host ?: "").toLowerCase() in matchingHosts return uri.host.orEmpty().toLowerCase() in matchingHosts
} }
// This method is allowed to block for IO if necessary // This method is allowed to block for IO if necessary

View File

@ -90,7 +90,7 @@ class MergedSource : SuspendHttpSource() {
// TODO more chapter dedupe // TODO more chapter dedupe
return db.getChaptersByMergedMangaId(manga.id!!).asRxObservable() return db.getChaptersByMergedMangaId(manga.id!!).asRxObservable()
.map { chapterList -> .map { chapterList ->
val mangaReferences = runBlocking(Dispatchers.IO) { db.getMergedMangaReferences(manga.id!!).await() } ?: emptyList() val mangaReferences = runBlocking(Dispatchers.IO) { db.getMergedMangaReferences(manga.id!!).await().orEmpty() }
if (editScanlators) { if (editScanlators) {
val sources = mangaReferences.map { sourceManager.getOrStub(it.mangaSourceId) to it.mangaId } val sources = mangaReferences.map { sourceManager.getOrStub(it.mangaSourceId) to it.mangaId }
chapterList.onEach { chapter -> chapterList.onEach { chapter ->

View File

@ -71,7 +71,7 @@ class HBrowse(delegate: HttpSource, val context: Context) :
private fun parseIntoTables(doc: Document): Map<String, Map<String, Element>> { private fun parseIntoTables(doc: Document): Map<String, Map<String, Element>> {
return doc.select("#main > .listTable").map { ele -> return doc.select("#main > .listTable").map { ele ->
val tableName = ele.previousElementSibling()?.text()?.toLowerCase() ?: "" val tableName = ele.previousElementSibling()?.text()?.toLowerCase().orEmpty()
tableName to ele.select("tr").map { tableName to ele.select("tr").map {
it.child(0).text() to it.child(1) it.child(0).text() to it.child(1)
}.toMap() }.toMap()

View File

@ -31,7 +31,7 @@ class MigrationMangaDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
if (mangaSkipped > 0) " " + applicationContext?.getString(R.string.skipping_, mangaSkipped) if (mangaSkipped > 0) " " + applicationContext?.getString(R.string.skipping_, mangaSkipped)
else "" else ""
) )
) ?: "" ).orEmpty()
return MaterialDialog(activity!!) return MaterialDialog(activity!!)
.message(text = confirmString) .message(text = confirmString)
.positiveButton(if (copy) R.string.copy else R.string.migrate) { .positiveButton(if (copy) R.string.copy else R.string.migrate) {

View File

@ -109,7 +109,7 @@ class PreMigrationController(bundle: Bundle? = null) :
override fun startMigration(extraParam: String?) { override fun startMigration(extraParam: String?) {
val listOfSources = adapter?.items?.filter { val listOfSources = adapter?.items?.filter {
it.sourceEnabled it.sourceEnabled
}?.joinToString("/") { it.source.id.toString() } ?: "" }?.joinToString("/") { it.source.id.toString() }.orEmpty()
prefs.migrationSources().set(listOfSources) prefs.migrationSources().set(listOfSources)
router.replaceTopController( router.replaceTopController(

View File

@ -33,6 +33,7 @@ import eu.kanade.tachiyomi.ui.browse.migration.search.SearchController
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
import eu.kanade.tachiyomi.util.lang.await import eu.kanade.tachiyomi.util.lang.await
import eu.kanade.tachiyomi.util.lang.awaitSingle
import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
@ -50,7 +51,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit import kotlinx.coroutines.sync.withPermit
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import rx.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
@ -178,7 +178,7 @@ class MigrationListController(bundle: Bundle? = null) :
searchResult, searchResult,
source.id source.id
) )
val chapters = (if (source is EHentai) source.fetchChapterList(localManga, throttleManager::throttle) else source.fetchChapterList(localManga)).toSingle().await(Schedulers.io()) val chapters = (if (source is EHentai) source.fetchChapterList(localManga, throttleManager::throttle) else source.fetchChapterList(localManga)).awaitSingle()
try { try {
syncChaptersWithSource(db, chapters, localManga, source) syncChaptersWithSource(db, chapters, localManga, source)
} catch (e: Exception) { } catch (e: Exception) {
@ -210,7 +210,7 @@ class MigrationListController(bundle: Bundle? = null) :
if (searchResult != null) { if (searchResult != null) {
val localManga = smartSearchEngine.networkToLocalManga(searchResult, source.id) val localManga = smartSearchEngine.networkToLocalManga(searchResult, source.id)
val chapters = try { val chapters = try {
(if (source is EHentai) source.fetchChapterList(localManga, throttleManager::throttle) else source.fetchChapterList(localManga)).toSingle().await(Schedulers.io()) ?: emptyList() (if (source is EHentai) source.fetchChapterList(localManga, throttleManager::throttle) else source.fetchChapterList(localManga)).awaitSingle()
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
Timber.e(e) Timber.e(e)
emptyList() emptyList()
@ -240,7 +240,7 @@ class MigrationListController(bundle: Bundle? = null) :
if (result != null && result.thumbnail_url == null) { if (result != null && result.thumbnail_url == null) {
try { try {
val newManga = sourceManager.getOrStub(result.source).fetchMangaDetails(result).toSingle().await() val newManga = sourceManager.getOrStub(result.source).fetchMangaDetails(result).awaitSingle()
result.copyFrom(newManga) result.copyFrom(newManga)
db.insertManga(result).await() db.insertManga(result).await()
@ -345,7 +345,7 @@ class MigrationListController(bundle: Bundle? = null) :
val result = CoroutineScope(migratingManga.manga.migrationJob).async { val result = CoroutineScope(migratingManga.manga.migrationJob).async {
val localManga = smartSearchEngine.networkToLocalManga(manga, source.id) val localManga = smartSearchEngine.networkToLocalManga(manga, source.id)
try { try {
val chapters = source.fetchChapterList(localManga).toSingle().await(Schedulers.io()) val chapters = source.fetchChapterList(localManga).awaitSingle()
syncChaptersWithSource(db, chapters, localManga, source) syncChaptersWithSource(db, chapters, localManga, source)
} catch (e: Exception) { } catch (e: Exception) {
return@async null return@async null
@ -355,7 +355,7 @@ class MigrationListController(bundle: Bundle? = null) :
if (result != null) { if (result != null) {
try { try {
val newManga = sourceManager.getOrStub(result.source).fetchMangaDetails(result).toSingle().await() val newManga = sourceManager.getOrStub(result.source).fetchMangaDetails(result).awaitSingle()
result.copyFrom(newManga) result.copyFrom(newManga)
db.insertManga(result).await() db.insertManga(result).await()

View File

@ -24,7 +24,7 @@ class MigrationProcessAdapter(
val menuItemListener: MigrationProcessInterface = controller val menuItemListener: MigrationProcessInterface = controller
override fun updateDataSet(items: List<MigrationProcessItem>?) { override fun updateDataSet(items: List<MigrationProcessItem>?) {
this.items = items ?: emptyList() this.items = items.orEmpty()
super.updateDataSet(items) super.updateDataSet(items)
} }

View File

@ -111,9 +111,9 @@ open class IndexPresenter(
.asFlow() .asFlow()
.singleOrNull() .singleOrNull()
?.mangas ?.mangas
?.take(10) .orEmpty()
?.map { networkToLocalManga(it, source.id) } .take(10)
?: emptyList() .map { networkToLocalManga(it, source.id) }
} catch (e: Exception) { } catch (e: Exception) {
emptyList() emptyList()
} }
@ -139,9 +139,9 @@ open class IndexPresenter(
.asFlow() .asFlow()
.singleOrNull() .singleOrNull()
?.mangas ?.mangas
?.take(10) .orEmpty()
?.map { networkToLocalManga(it, source.id) } .take(10)
?: emptyList() .map { networkToLocalManga(it, source.id) }
} catch (e: Exception) { } catch (e: Exception) {
emptyList() emptyList()
} }

View File

@ -53,7 +53,7 @@ class LibraryCategoryAdapter(view: LibraryCategoryView, val controller: LibraryC
// Keep compatibility as searchText field was replaced when we upgraded FlexibleAdapter // Keep compatibility as searchText field was replaced when we upgraded FlexibleAdapter
var searchText var searchText
get() = getFilter(String::class.java) ?: "" get() = getFilter(String::class.java).orEmpty()
set(value) { set(value) {
setFilter(value) setFilter(value)
} }
@ -169,7 +169,7 @@ class LibraryCategoryAdapter(view: LibraryCategoryView, val controller: LibraryC
val mappedQueries = queries.groupBy { it.excluded } val mappedQueries = queries.groupBy { it.excluded }
val tracks = if (hasLoggedServices) db.getTracks(manga).await().toList() else null val tracks = if (hasLoggedServices) db.getTracks(manga).await().toList() else null
val source = sourceManager.get(manga.source) val source = sourceManager.get(manga.source)
val genre = if (checkGenre) manga.getGenres() else null val genre = if (checkGenre) manga.getGenres().orEmpty() else emptyList()
val hasNormalQuery = mappedQueries[false]?.all { queryComponent -> val hasNormalQuery = mappedQueries[false]?.all { queryComponent ->
when (queryComponent) { when (queryComponent) {
is Text -> { is Text -> {
@ -179,9 +179,9 @@ class LibraryCategoryAdapter(view: LibraryCategoryView, val controller: LibraryC
(manga.artist?.contains(query, true) == true) || (manga.artist?.contains(query, true) == true) ||
(source?.name?.contains(query, true) == true) || (source?.name?.contains(query, true) == true) ||
(hasLoggedServices && tracks != null && filterTracks(query, tracks)) || (hasLoggedServices && tracks != null && filterTracks(query, tracks)) ||
(genre != null && genre.any { it.contains(query, true) }) || (genre.any { it.contains(query, true) }) ||
(searchTags != null && searchTags.any { it.name.contains(query, true) }) || (searchTags.orEmpty().any { it.name.contains(query, true) }) ||
(searchTitles != null && searchTitles.any { it.title.contains(query, true) }) (searchTitles.orEmpty().any { it.title.contains(query, true) })
} }
is Namespace -> { is Namespace -> {
searchTags != null && searchTags.any { searchTags != null && searchTags.any {
@ -199,13 +199,13 @@ class LibraryCategoryAdapter(view: LibraryCategoryView, val controller: LibraryC
val query = queryComponent.asQuery() val query = queryComponent.asQuery()
query.isBlank() || ( query.isBlank() || (
(!manga.title.contains(query, true)) && (!manga.title.contains(query, true)) &&
(!(manga.author ?: "").contains(query, true)) && (!manga.author.orEmpty().contains(query, true)) &&
(!(manga.artist ?: "").contains(query, true)) && (!manga.artist.orEmpty().contains(query, true)) &&
(!(source?.name ?: "").contains(query, true)) && (!source?.name.orEmpty().contains(query, true)) &&
(!hasLoggedServices || hasLoggedServices && tracks == null || tracks != null && !filterTracks(query, tracks)) && (!hasLoggedServices || hasLoggedServices && tracks == null || tracks != null && !filterTracks(query, tracks)) &&
((genre ?: emptyList()).all { !it.contains(query, true) }) && (genre.none { it.contains(query, true) }) &&
((searchTags ?: emptyList()).all { !it.name.contains(query, true) }) && (searchTags.orEmpty().none { it.name.contains(query, true) }) &&
((searchTitles ?: emptyList()).all { !it.title.contains(query, true) }) (searchTitles.orEmpty().none { it.title.contains(query, true) })
) )
} }
is Namespace -> { is Namespace -> {

View File

@ -503,7 +503,7 @@ class LibraryPresenter(
val chapter = db.getChapters(manga).await().minByOrNull { it.source_order } val chapter = db.getChapters(manga).await().minByOrNull { it.source_order }
if (chapter != null && !chapter.read) listOf(chapter) else emptyList() if (chapter != null && !chapter.read) listOf(chapter) else emptyList()
} else if (manga.source == MERGED_SOURCE_ID) { } else if (manga.source == MERGED_SOURCE_ID) {
(sourceManager.getOrStub(MERGED_SOURCE_ID) as? MergedSource)?.getChaptersFromDB(manga)?.awaitSingleOrNull()?.filter { !it.read } ?: emptyList() (sourceManager.getOrStub(MERGED_SOURCE_ID) as? MergedSource)?.getChaptersFromDB(manga)?.awaitSingleOrNull()?.filter { !it.read }.orEmpty()
} else /* SY <-- */ db.getChapters(manga).executeAsBlocking() } else /* SY <-- */ db.getChapters(manga).executeAsBlocking()
.filter { !it.read } .filter { !it.read }
@ -558,7 +558,7 @@ class LibraryPresenter(
fun markReadStatus(mangas: List<Manga>, read: Boolean) { fun markReadStatus(mangas: List<Manga>, read: Boolean) {
mangas.forEach { manga -> mangas.forEach { manga ->
launchIO { launchIO {
val chapters = if (manga.source == MERGED_SOURCE_ID) (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource)?.getChaptersFromDB(manga)?.awaitSingleOrNull() ?: emptyList() else db.getChapters(manga).executeAsBlocking() val chapters = if (manga.source == MERGED_SOURCE_ID) (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource)?.getChaptersFromDB(manga)?.awaitSingleOrNull().orEmpty() else db.getChapters(manga).executeAsBlocking()
chapters.forEach { chapters.forEach {
it.read = read it.read = read
if (!read) { if (!read) {
@ -647,7 +647,7 @@ class LibraryPresenter(
// SY --> // SY -->
/** Returns first unread chapter of a manga */ /** Returns first unread chapter of a manga */
fun getFirstUnread(manga: Manga): Chapter? { fun getFirstUnread(manga: Manga): Chapter? {
val chapters = (if (manga.source == MERGED_SOURCE_ID) (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource).let { runBlocking { it?.getChaptersFromDB(manga)?.awaitSingleOrNull() } ?: emptyList() } else db.getChapters(manga).executeAsBlocking()) val chapters = (if (manga.source == MERGED_SOURCE_ID) (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource).let { runBlocking { it?.getChaptersFromDB(manga)?.awaitSingleOrNull().orEmpty() } } else db.getChapters(manga).executeAsBlocking())
return if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) { return if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
val chapter = chapters.sortedBy { it.source_order }.getOrNull(0) val chapter = chapters.sortedBy { it.source_order }.getOrNull(0)
if (chapter?.read == false) chapter else null if (chapter?.read == false) chapter else null

View File

@ -92,22 +92,22 @@ class EditMangaDialog : DialogController {
binding.title.append(manga.title) binding.title.append(manga.title)
} }
binding.title.hint = "${resources?.getString(R.string.title)}: ${manga.url}" binding.title.hint = "${resources?.getString(R.string.title)}: ${manga.url}"
binding.mangaAuthor.append(manga.author ?: "") binding.mangaAuthor.append(manga.author.orEmpty())
binding.mangaArtist.append(manga.artist ?: "") binding.mangaArtist.append(manga.artist.orEmpty())
binding.mangaDescription.append(manga.description ?: "") binding.mangaDescription.append(manga.description.orEmpty())
binding.mangaGenresTags.setChips(manga.getGenres()) binding.mangaGenresTags.setChips(manga.getGenres())
} else { } else {
if (manga.title != manga.originalTitle) { if (manga.title != manga.originalTitle) {
binding.title.append(manga.title) binding.title.append(manga.title)
} }
if (manga.author != manga.originalAuthor) { if (manga.author != manga.originalAuthor) {
binding.mangaAuthor.append(manga.author ?: "") binding.mangaAuthor.append(manga.author.orEmpty())
} }
if (manga.artist != manga.originalArtist) { if (manga.artist != manga.originalArtist) {
binding.mangaArtist.append(manga.artist ?: "") binding.mangaArtist.append(manga.artist.orEmpty())
} }
if (manga.description != manga.originalDescription) { if (manga.description != manga.originalDescription) {
binding.mangaDescription.append(manga.description ?: "") binding.mangaDescription.append(manga.description.orEmpty())
} }
binding.mangaGenresTags.setChips(manga.getGenres()) binding.mangaGenresTags.setChips(manga.getGenres())

View File

@ -118,7 +118,7 @@ class ReaderPresenter(
val meta = meta val meta = meta
val filteredScanlators = meta?.filteredScanlators?.let { MdUtil.getScanlators(it) } val filteredScanlators = meta?.filteredScanlators?.let { MdUtil.getScanlators(it) }
// SY <-- // SY <--
val dbChapters = /* SY --> */if (manga.source == MERGED_SOURCE_ID) runBlocking { (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource)?.getChaptersFromDB(manga)?.awaitSingleOrNull() ?: emptyList() } else /* SY <-- */ db.getChapters(manga).executeAsBlocking() val dbChapters = /* SY --> */if (manga.source == MERGED_SOURCE_ID) runBlocking { (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource)?.getChaptersFromDB(manga)?.awaitSingleOrNull().orEmpty() } else /* SY <-- */ db.getChapters(manga).executeAsBlocking()
val selectedChapter = dbChapters.find { it.id == chapterId } val selectedChapter = dbChapters.find { it.id == chapterId }
?: error("Requested chapter of id $chapterId not found in chapter list") ?: error("Requested chapter of id $chapterId not found in chapter list")

View File

@ -51,7 +51,7 @@ class AutoCompleteAdapter(context: Context, resource: Int, var objects: List<Str
override fun publishResults(constraint: CharSequence?, results: FilterResults) { override fun publishResults(constraint: CharSequence?, results: FilterResults) {
objects = if (results.values != null) { objects = if (results.values != null) {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
results.values as List<String>? ?: emptyList() (results.values as List<String>?).orEmpty()
} else { } else {
emptyList() emptyList()
} }

View File

@ -48,7 +48,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
val followsPageResult = try { val followsPageResult = try {
MdUtil.jsonParser.decodeFromString( MdUtil.jsonParser.decodeFromString(
FollowsPageResult.serializer(), FollowsPageResult.serializer(),
response.body?.string() ?: "" response.body?.string().orEmpty()
) )
} catch (e: Exception) { } catch (e: Exception) {
XLog.e("error parsing follows", e) XLog.e("error parsing follows", e)
@ -79,7 +79,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
val followsPageResult = try { val followsPageResult = try {
MdUtil.jsonParser.decodeFromString( MdUtil.jsonParser.decodeFromString(
FollowsPageResult.serializer(), FollowsPageResult.serializer(),
response.body?.string() ?: "" response.body?.string().orEmpty()
) )
} catch (e: Exception) { } catch (e: Exception) {
XLog.e("error parsing follows", e) XLog.e("error parsing follows", e)

View File

@ -20,8 +20,8 @@ fun OkHttpClient.Builder.injectPatches(sourceIdProducer: () -> Long): OkHttpClie
fun findAndApplyPatches(sourceId: Long): EHInterceptor { fun findAndApplyPatches(sourceId: Long): EHInterceptor {
// TODO make it so captcha doesnt auto open in manga eden while applying universal interceptors // TODO make it so captcha doesnt auto open in manga eden while applying universal interceptors
return if (Injekt.get<PreferencesHelper>().eh_autoSolveCaptchas().get()) ((EH_INTERCEPTORS[sourceId] ?: emptyList()) + (EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList())).merge() return if (Injekt.get<PreferencesHelper>().eh_autoSolveCaptchas().get()) ((EH_INTERCEPTORS[sourceId].orEmpty()) + (EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR].orEmpty())).merge()
else (EH_INTERCEPTORS[sourceId] ?: emptyList()).merge() else (EH_INTERCEPTORS[sourceId].orEmpty()).merge()
} }
fun List<EHInterceptor>.merge(): EHInterceptor { fun List<EHInterceptor>.merge(): EHInterceptor {

View File

@ -83,7 +83,7 @@ class MetadataViewController : NucleusController<MetadataViewControllerBinding,
fun onNextMangaInfo(meta: RaisedSearchMetadata?) { fun onNextMangaInfo(meta: RaisedSearchMetadata?) {
val context = view?.context ?: return val context = view?.context ?: return
data = meta?.getExtraInfoPairs(context) ?: emptyList() data = meta?.getExtraInfoPairs(context).orEmpty()
adapter?.update(data) adapter?.update(data)
} }
} }

View File

@ -54,7 +54,7 @@ class PururinDescriptionAdapter(
} ?: genre?.name ?: itemView.context.getString(R.string.unknown) } ?: genre?.name ?: itemView.context.getString(R.string.unknown)
} }
binding.uploader.text = meta.uploaderDisp ?: meta.uploader ?: "" binding.uploader.text = meta.uploaderDisp ?: meta.uploader.orEmpty()
binding.size.text = meta.fileSize ?: itemView.context.getString(R.string.unknown) binding.size.text = meta.fileSize ?: itemView.context.getString(R.string.unknown)
binding.size.bindDrawable(itemView.context, R.drawable.ic_outline_sd_card_24) binding.size.bindDrawable(itemView.context, R.drawable.ic_outline_sd_card_24)

View File

@ -32,7 +32,7 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartS
return binding.root return binding.root
} }
override fun getTitle() = source?.name ?: "" override fun getTitle() = source?.name.orEmpty()
override fun createPresenter() = SmartSearchPresenter(source, smartSearchConfig) override fun createPresenter() = SmartSearchPresenter(source, smartSearchConfig)

View File

@ -10,7 +10,7 @@ import uy.kohesive.injekt.api.get
fun Manga.isLewd(): Boolean { fun Manga.isLewd(): Boolean {
val sourceName = Injekt.get<SourceManager>().get(source)?.name val sourceName = Injekt.get<SourceManager>().get(source)?.name
val currentTags = getGenres() ?: emptyList() val currentTags = getGenres().orEmpty()
if (source == EH_SOURCE_ID || source == EXH_SOURCE_ID || source in nHentaiSourceIds) { if (source == EH_SOURCE_ID || source == EXH_SOURCE_ID || source in nHentaiSourceIds) {
return currentTags.none { tag -> isNonHentaiTag(tag) } return currentTags.none { tag -> isNonHentaiTag(tag) }

View File

@ -51,7 +51,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
"\"$fieldName\" == \"$value\"" + ( "\"$fieldName\" == \"$value\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }
@ -121,7 +121,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
)}] IN \"$fieldName\"" + ( )}] IN \"$fieldName\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }
@ -181,7 +181,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
"\"$fieldName\" != \"$value\"" + ( "\"$fieldName\" != \"$value\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }
@ -391,7 +391,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
"\"$fieldName\" CONTAINS \"$value\"" + ( "\"$fieldName\" CONTAINS \"$value\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }
@ -411,7 +411,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
"\"$fieldName\" BEGINS WITH \"$value\"" + ( "\"$fieldName\" BEGINS WITH \"$value\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }
@ -431,7 +431,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
"\"$fieldName\" ENDS WITH \"$value\"" + ( "\"$fieldName\" ENDS WITH \"$value\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }
@ -451,7 +451,7 @@ class LoggingRealmQuery<E : RealmModel>(val query: RealmQuery<E>) {
"\"$fieldName\" LIKE \"$value\"" + ( "\"$fieldName\" LIKE \"$value\"" + (
casing?.let { casing?.let {
" CASE ${casing.name}" " CASE ${casing.name}"
} ?: "" }.orEmpty()
) )
) )
} }

View File

@ -26,7 +26,7 @@ fun Manga.mangaType(context: Context): String {
*/ */
fun Manga.mangaType(): MangaType { fun Manga.mangaType(): MangaType {
val sourceName = Injekt.get<SourceManager>().getOrStub(source).name val sourceName = Injekt.get<SourceManager>().getOrStub(source).name
val currentTags = getGenres() ?: emptyList() val currentTags = getGenres().orEmpty()
return if (currentTags.any { tag -> isMangaTag(tag) }) { return if (currentTags.any { tag -> isMangaTag(tag) }) {
MangaType.TYPE_MANGA MangaType.TYPE_MANGA
} else if (currentTags.any { tag -> isWebtoonTag(tag) } || isWebtoonSource(sourceName)) { } else if (currentTags.any { tag -> isWebtoonTag(tag) } || isWebtoonSource(sourceName)) {