mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Update libraries, some lints (#4099)
* Update some plugins * Fix some miscellaneous lints
This commit is contained in:
		| @@ -41,8 +41,8 @@ abstract class AbstractBackupManager(protected val context: Context) { | ||||
|     internal fun restoreChapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> { | ||||
|         return source.fetchChapterList(manga) | ||||
|             .map { syncChaptersWithSource(databaseHelper, it, manga, source) } | ||||
|             .doOnNext { pair -> | ||||
|                 if (pair.first.isNotEmpty()) { | ||||
|             .doOnNext { (first) -> | ||||
|                 if (first.isNotEmpty()) { | ||||
|                     chapters.forEach { it.manga_id = manga.id } | ||||
|                     updateChapters(chapters) | ||||
|                 } | ||||
|   | ||||
| @@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.data.track.TrackManager | ||||
| import eu.kanade.tachiyomi.source.Source | ||||
| import eu.kanade.tachiyomi.util.chapter.NoChaptersException | ||||
| import kotlinx.coroutines.Job | ||||
| import okio.source | ||||
| import rx.Observable | ||||
| import uy.kohesive.injekt.injectLazy | ||||
| import java.io.File | ||||
|   | ||||
| @@ -128,7 +128,7 @@ class DownloadCache( | ||||
|             .orEmpty() | ||||
|             .associate { it.name to SourceDirectory(it) } | ||||
|             .mapNotNullKeys { entry -> | ||||
|                 onlineSources.find { provider.getSourceDirName(it).toLowerCase() == entry.key?.toLowerCase() }?.id | ||||
|                 onlineSources.find { provider.getSourceDirName(it).equals(entry.key, ignoreCase = true) }?.id | ||||
|             } | ||||
|  | ||||
|         rootDir.files = sourceDirs | ||||
|   | ||||
| @@ -89,8 +89,8 @@ class DownloadPendingDeleter(context: Context) { | ||||
|         } | ||||
|         lastAddedEntry = null | ||||
|  | ||||
|         return entries.associate { entry -> | ||||
|             entry.manga.toModel() to entry.chapters.map { it.toModel() } | ||||
|         return entries.associate { (chapters, manga) -> | ||||
|             manga.toModel() to chapters.map { it.toModel() } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -165,8 +165,7 @@ class LibraryUpdateNotifier(private val context: Context) { | ||||
|  | ||||
|             // Per-manga notification | ||||
|             if (!preferences.hideNotificationContent()) { | ||||
|                 updates.forEach { | ||||
|                     val (manga, chapters) = it | ||||
|                 updates.forEach { (manga, chapters) -> | ||||
|                     notify(manga.id.hashCode(), createNewChaptersNotification(manga, chapters)) | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -275,7 +275,7 @@ class LibraryUpdateService( | ||||
|                         Pair(emptyList(), emptyList()) | ||||
|                     } | ||||
|                     // Filter out mangas without new chapters (or failed). | ||||
|                     .filter { pair -> pair.first.isNotEmpty() } | ||||
|                     .filter { (first) -> first.isNotEmpty() } | ||||
|                     .doOnNext { | ||||
|                         if (manga.shouldDownloadNewChapters(db, preferences)) { | ||||
|                             downloadChapters(manga, it.first) | ||||
| @@ -317,7 +317,7 @@ class LibraryUpdateService( | ||||
|                     ) | ||||
|                 } | ||||
|             } | ||||
|             .map { manga -> manga.first } | ||||
|             .map { (first) -> first } | ||||
|     } | ||||
|  | ||||
|     private fun downloadChapters(manga: Manga, chapters: List<Chapter>) { | ||||
|   | ||||
| @@ -149,13 +149,9 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { | ||||
|     private fun saveCSRF(csrf: String) = preferences.trackToken(this).set(csrf) | ||||
|  | ||||
|     private fun checkCookies(): Boolean { | ||||
|         var ckCount = 0 | ||||
|         val url = BASE_URL.toHttpUrlOrNull()!! | ||||
|         for (ck in networkService.cookieManager.get(url)) { | ||||
|             if (ck.name == USER_SESSION_COOKIE || ck.name == LOGGED_IN_COOKIE) { | ||||
|                 ckCount++ | ||||
|             } | ||||
|         } | ||||
|         val ckCount = networkService.cookieManager.get(url).count { | ||||
|             it.name == USER_SESSION_COOKIE || it.name == LOGGED_IN_COOKIE } | ||||
|  | ||||
|         return ckCount == 2 | ||||
|     } | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| package eu.kanade.tachiyomi.extension.api | ||||
|  | ||||
| import android.content.Context | ||||
| import com.github.salomonbrys.kotson.get | ||||
| import com.github.salomonbrys.kotson.int | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.extension.model.Extension | ||||
| import eu.kanade.tachiyomi.extension.model.LoadResult | ||||
|   | ||||
| @@ -185,7 +185,7 @@ open class ExtensionController : | ||||
|     } | ||||
|  | ||||
|     private fun drawExtensions() { | ||||
|         if (!query.isBlank()) { | ||||
|         if (query.isNotBlank()) { | ||||
|             adapter?.updateDataSet( | ||||
|                 extensions.filter { | ||||
|                     it.extension.name.contains(query, ignoreCase = true) | ||||
|   | ||||
| @@ -24,7 +24,7 @@ class ExtensionDetailsPresenter( | ||||
|         extensionManager.getInstalledExtensionsObservable() | ||||
|             .skip(1) | ||||
|             .filter { extensions -> extensions.none { it.pkgName == pkgName } } | ||||
|             .map { Unit } | ||||
|             .map { } | ||||
|             .take(1) | ||||
|             .observeOn(AndroidSchedulers.mainThread()) | ||||
|             .subscribeFirst({ view, _ -> | ||||
|   | ||||
| @@ -97,7 +97,7 @@ class SearchPresenter( | ||||
|                 val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking() | ||||
|                 val maxChapterRead = prevMangaChapters | ||||
|                     .filter { it.read } | ||||
|                     .maxBy { it.chapter_number }?.chapter_number | ||||
|                     .maxByOrNull { it.chapter_number }?.chapter_number | ||||
|                 val bookmarkedChapters = prevMangaChapters | ||||
|                     .filter { it.bookmark && it.isRecognizedNumber } | ||||
|                     .map { it.chapter_number } | ||||
|   | ||||
| @@ -27,9 +27,9 @@ class MigrationSourcesPresenter( | ||||
|  | ||||
|     private fun findSourcesWithManga(library: List<Manga>): List<SourceItem> { | ||||
|         val header = SelectionHeader() | ||||
|         return library.map { it.source }.toSet() | ||||
|         return library.asSequence().map { it.source }.toSet() | ||||
|             .mapNotNull { if (it != LocalSource.ID) sourceManager.getOrStub(it) else null } | ||||
|             .sortedBy { it.name.toLowerCase() } | ||||
|             .map { SourceItem(it, header) } | ||||
|             .map { SourceItem(it, header) }.toList() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -13,7 +13,6 @@ import kotlinx.coroutines.delay | ||||
| import kotlinx.coroutines.flow.distinctUntilChanged | ||||
| import kotlinx.coroutines.flow.drop | ||||
| import kotlinx.coroutines.flow.launchIn | ||||
| import kotlinx.coroutines.flow.map | ||||
| import kotlinx.coroutines.flow.onEach | ||||
| import kotlinx.coroutines.flow.onStart | ||||
| import rx.Observable | ||||
|   | ||||
| @@ -264,7 +264,7 @@ open class BrowseSourceController(bundle: Bundle) : | ||||
|         searchView.maxWidth = Int.MAX_VALUE | ||||
|  | ||||
|         val query = presenter.query | ||||
|         if (!query.isBlank()) { | ||||
|         if (query.isNotBlank()) { | ||||
|             searchItem.expandActionView() | ||||
|             searchView.setQuery(query, true) | ||||
|             searchView.clearFocus() | ||||
|   | ||||
| @@ -52,7 +52,7 @@ import java.util.Date | ||||
|  */ | ||||
| open class BrowseSourcePresenter( | ||||
|     private val sourceId: Long, | ||||
|     private val searchQuery: String? = null, | ||||
|     searchQuery: String? = null, | ||||
|     private val sourceManager: SourceManager = Injekt.get(), | ||||
|     private val db: DatabaseHelper = Injekt.get(), | ||||
|     private val prefs: PreferencesHelper = Injekt.get(), | ||||
| @@ -153,9 +153,9 @@ open class BrowseSourcePresenter( | ||||
|         pagerSubscription?.let { remove(it) } | ||||
|         pagerSubscription = pager.results() | ||||
|             .observeOn(Schedulers.io()) | ||||
|             .map { pair -> pair.first to pair.second.map { networkToLocalManga(it, sourceId) } } | ||||
|             .map { (first, second) -> first to second.map { networkToLocalManga(it, sourceId) } } | ||||
|             .doOnNext { initializeMangas(it.second) } | ||||
|             .map { pair -> pair.first to pair.second.map { SourceItem(it, sourceDisplayMode) } } | ||||
|             .map { (first, second) -> first to second.map { SourceItem(it, sourceDisplayMode) } } | ||||
|             .observeOn(AndroidSchedulers.mainThread()) | ||||
|             .subscribeReplay( | ||||
|                 { view, (page, mangas) -> | ||||
|   | ||||
| @@ -195,7 +195,7 @@ open class GlobalSearchController( | ||||
|  | ||||
|         adapter?.updateDataSet(searchResult) | ||||
|  | ||||
|         val progress = searchResult.mapNotNull { it.results }.count().toDouble() / searchResult.size | ||||
|         val progress = searchResult.mapNotNull { it.results }.size.toDouble() / searchResult.size | ||||
|         if (progress < 1) { | ||||
|             binding.progressBar.isVisible = true | ||||
|             binding.progressBar.progress = (progress * 100).toInt() | ||||
|   | ||||
| @@ -222,9 +222,8 @@ open class GlobalSearchPresenter( | ||||
|     private fun initializeFetchImageSubscription() { | ||||
|         fetchImageSubscription?.unsubscribe() | ||||
|         fetchImageSubscription = fetchImageSubject.observeOn(Schedulers.io()) | ||||
|             .flatMap { pair -> | ||||
|                 val source = pair.second | ||||
|                 Observable.from(pair.first).filter { it.thumbnail_url == null && !it.initialized } | ||||
|             .flatMap { (first, source) -> | ||||
|                 Observable.from(first).filter { it.thumbnail_url == null && !it.initialized } | ||||
|                     .map { Pair(it, source) } | ||||
|                     .concatMap { getMangaDetailsObservable(it.first, it.second) } | ||||
|                     .map { Pair(source as CatalogueSource, it) } | ||||
|   | ||||
| @@ -52,7 +52,7 @@ class CategoryPresenter( | ||||
|         val cat = Category.create(name) | ||||
|  | ||||
|         // Set the new item in the last position. | ||||
|         cat.order = categories.map { it.order + 1 }.max() ?: 0 | ||||
|         cat.order = categories.map { it.order + 1 }.maxOrNull() ?: 0 | ||||
|  | ||||
|         // Insert into database. | ||||
|         db.insertCategory(cat).asRxObservable().subscribe() | ||||
|   | ||||
| @@ -101,11 +101,11 @@ class LibraryItem(val manga: LibraryManga, private val libraryDisplayMode: Prefe | ||||
|     private fun containsGenre(tag: String, genres: List<String>?): Boolean { | ||||
|         return if (tag.startsWith("-")) { | ||||
|             genres?.find { | ||||
|                 it.trim().toLowerCase() == tag.substringAfter("-").toLowerCase() | ||||
|                 it.trim().equals(tag.substringAfter("-"), ignoreCase = true) | ||||
|             } == null | ||||
|         } else { | ||||
|             genres?.find { | ||||
|                 it.trim().toLowerCase() == tag.toLowerCase() | ||||
|                 it.trim().equals(tag, ignoreCase = true) | ||||
|             } != null | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -409,9 +409,7 @@ class LibraryPresenter( | ||||
|         val mc = mutableListOf<MangaCategory>() | ||||
|  | ||||
|         for (manga in mangas) { | ||||
|             for (cat in categories) { | ||||
|                 mc.add(MangaCategory.create(manga, cat)) | ||||
|             } | ||||
|             categories.mapTo(mc) { MangaCategory.create(manga, it) } | ||||
|         } | ||||
|  | ||||
|         db.setMangaCategories(mc, mangas) | ||||
|   | ||||
| @@ -31,7 +31,7 @@ class SetTrackReadingDatesDialog<T> : DialogController | ||||
|  | ||||
|     @Suppress("unused") | ||||
|     constructor(bundle: Bundle) : super(bundle) { | ||||
|         val track = bundle.getSerializable(SetTrackReadingDatesDialog.KEY_ITEM_TRACK) as Track | ||||
|         val track = bundle.getSerializable(KEY_ITEM_TRACK) as Track | ||||
|         val service = Injekt.get<TrackManager>().getService(track.sync_id)!! | ||||
|         item = TrackItem(track, service) | ||||
|         dateToUpdate = ReadingDate.Start | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import android.view.LayoutInflater | ||||
| import android.view.ViewGroup | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import eu.kanade.tachiyomi.databinding.TrackItemBinding | ||||
| import eu.kanade.tachiyomi.util.view.inflate | ||||
|  | ||||
| class TrackAdapter(controller: TrackController) : RecyclerView.Adapter<TrackHolder>() { | ||||
|  | ||||
|   | ||||
| @@ -47,7 +47,7 @@ class TrackSearchAdapter(context: Context) : | ||||
|             binding.trackSearchTitle.text = track.title | ||||
|             binding.trackSearchSummary.text = track.summary | ||||
|             GlideApp.with(view.context).clear(binding.trackSearchCover) | ||||
|             if (!track.cover_url.isEmpty()) { | ||||
|             if (track.cover_url.isNotEmpty()) { | ||||
|                 GlideApp.with(view.context) | ||||
|                     .load(track.cover_url) | ||||
|                     .diskCacheStrategy(DiskCacheStrategy.RESOURCE) | ||||
|   | ||||
| @@ -39,7 +39,7 @@ class ChapterLoadByNumber { | ||||
| /** | ||||
|  * Load strategy using the chapter upload date. This ordering ignores scanlators | ||||
|  */ | ||||
| class ChapterLoadByUploadDate() { | ||||
| class ChapterLoadByUploadDate { | ||||
|     fun get(allChapters: List<Chapter>): List<Chapter> { | ||||
|         return allChapters.sortedBy { it.date_upload } | ||||
|     } | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import android.widget.Spinner | ||||
| import androidx.annotation.ArrayRes | ||||
| import androidx.core.view.isInvisible | ||||
| import androidx.core.view.isVisible | ||||
| import androidx.core.view.plusAssign | ||||
| import androidx.core.widget.NestedScrollView | ||||
| import com.google.android.material.bottomsheet.BottomSheetDialog | ||||
| import com.tfcporciuncula.flow.Preference | ||||
|   | ||||
| @@ -152,7 +152,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr | ||||
|         // Initial opening - preload allowed | ||||
|         currentPage ?: return true | ||||
|  | ||||
|         val nextItem = adapter.items.getOrNull(adapter.items.count() - 1) | ||||
|         val nextItem = adapter.items.getOrNull(adapter.items.size - 1) | ||||
|         val nextChapter = (nextItem as? ChapterTransition.Next)?.to ?: (nextItem as? ReaderPage)?.chapter | ||||
|  | ||||
|         // Allow preload for | ||||
|   | ||||
| @@ -175,10 +175,10 @@ class EpubFile(file: File) : Closeable { | ||||
|      */ | ||||
|     private fun getPathSeparator(): String { | ||||
|         val meta = zip.getEntry("META-INF\\container.xml") | ||||
|         if (meta != null) { | ||||
|             return "\\" | ||||
|         return if (meta != null) { | ||||
|             "\\" | ||||
|         } else { | ||||
|             return "/" | ||||
|             "/" | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -206,10 +206,10 @@ class EpubFile(file: File) : Closeable { | ||||
|      */ | ||||
|     private fun getParentDirectory(path: String): String { | ||||
|         val separatorIndex = path.lastIndexOf(pathSeparator) | ||||
|         if (separatorIndex >= 0) { | ||||
|             return path.substring(0, separatorIndex) | ||||
|         return if (separatorIndex >= 0) { | ||||
|             path.substring(0, separatorIndex) | ||||
|         } else { | ||||
|             return "" | ||||
|             "" | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -51,10 +51,7 @@ object ImageUtil { | ||||
|     } | ||||
|  | ||||
|     private fun ByteArray.compareWith(magic: ByteArray): Boolean { | ||||
|         for (i in magic.indices) { | ||||
|             if (this[i] != magic[i]) return false | ||||
|         } | ||||
|         return true | ||||
|         return magic.indices.none { this[it] != magic[it] } | ||||
|     } | ||||
|  | ||||
|     private fun charByteArrayOf(vararg bytes: Int): ByteArray { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user