Update libraries, some lints (#4099)

* Update some plugins

* Fix some miscellaneous lints
This commit is contained in:
Taco 2020-12-08 22:21:08 -05:00 committed by GitHub
parent 08ab7f6aa0
commit c2b8fea291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 42 additions and 59 deletions

View File

@ -266,8 +266,7 @@ dependencies {
implementation "io.github.reactivecircus.flowbinding:flowbinding-viewpager:$flowbinding_version" implementation "io.github.reactivecircus.flowbinding:flowbinding-viewpager:$flowbinding_version"
// Licenses // Licenses
// NOTE: REMEMBER TO UPDATE GRADLE PLUGIN implementation "com.mikepenz:aboutlibraries:$BuildPluginsVersion.ABOUTLIB_PLUGIN"
implementation 'com.mikepenz:aboutlibraries:8.4.2'
// Tests // Tests
testImplementation 'junit:junit:4.13' testImplementation 'junit:junit:4.13'

View File

@ -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>>> { internal fun restoreChapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> {
return source.fetchChapterList(manga) return source.fetchChapterList(manga)
.map { syncChaptersWithSource(databaseHelper, it, manga, source) } .map { syncChaptersWithSource(databaseHelper, it, manga, source) }
.doOnNext { pair -> .doOnNext { (first) ->
if (pair.first.isNotEmpty()) { if (first.isNotEmpty()) {
chapters.forEach { it.manga_id = manga.id } chapters.forEach { it.manga_id = manga.id }
updateChapters(chapters) updateChapters(chapters)
} }

View File

@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.util.chapter.NoChaptersException import eu.kanade.tachiyomi.util.chapter.NoChaptersException
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import okio.source
import rx.Observable import rx.Observable
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File

View File

@ -128,7 +128,7 @@ class DownloadCache(
.orEmpty() .orEmpty()
.associate { it.name to SourceDirectory(it) } .associate { it.name to SourceDirectory(it) }
.mapNotNullKeys { entry -> .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 rootDir.files = sourceDirs

View File

@ -89,8 +89,8 @@ class DownloadPendingDeleter(context: Context) {
} }
lastAddedEntry = null lastAddedEntry = null
return entries.associate { entry -> return entries.associate { (chapters, manga) ->
entry.manga.toModel() to entry.chapters.map { it.toModel() } manga.toModel() to chapters.map { it.toModel() }
} }
} }

View File

@ -165,8 +165,7 @@ class LibraryUpdateNotifier(private val context: Context) {
// Per-manga notification // Per-manga notification
if (!preferences.hideNotificationContent()) { if (!preferences.hideNotificationContent()) {
updates.forEach { updates.forEach { (manga, chapters) ->
val (manga, chapters) = it
notify(manga.id.hashCode(), createNewChaptersNotification(manga, chapters)) notify(manga.id.hashCode(), createNewChaptersNotification(manga, chapters))
} }
} }

View File

@ -275,7 +275,7 @@ class LibraryUpdateService(
Pair(emptyList(), emptyList()) Pair(emptyList(), emptyList())
} }
// Filter out mangas without new chapters (or failed). // Filter out mangas without new chapters (or failed).
.filter { pair -> pair.first.isNotEmpty() } .filter { (first) -> first.isNotEmpty() }
.doOnNext { .doOnNext {
if (manga.shouldDownloadNewChapters(db, preferences)) { if (manga.shouldDownloadNewChapters(db, preferences)) {
downloadChapters(manga, it.first) 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>) { private fun downloadChapters(manga: Manga, chapters: List<Chapter>) {

View File

@ -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 saveCSRF(csrf: String) = preferences.trackToken(this).set(csrf)
private fun checkCookies(): Boolean { private fun checkCookies(): Boolean {
var ckCount = 0
val url = BASE_URL.toHttpUrlOrNull()!! val url = BASE_URL.toHttpUrlOrNull()!!
for (ck in networkService.cookieManager.get(url)) { val ckCount = networkService.cookieManager.get(url).count {
if (ck.name == USER_SESSION_COOKIE || ck.name == LOGGED_IN_COOKIE) { it.name == USER_SESSION_COOKIE || it.name == LOGGED_IN_COOKIE }
ckCount++
}
}
return ckCount == 2 return ckCount == 2
} }

View File

@ -1,8 +1,6 @@
package eu.kanade.tachiyomi.extension.api package eu.kanade.tachiyomi.extension.api
import android.content.Context 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.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.extension.model.LoadResult import eu.kanade.tachiyomi.extension.model.LoadResult

View File

@ -185,7 +185,7 @@ open class ExtensionController :
} }
private fun drawExtensions() { private fun drawExtensions() {
if (!query.isBlank()) { if (query.isNotBlank()) {
adapter?.updateDataSet( adapter?.updateDataSet(
extensions.filter { extensions.filter {
it.extension.name.contains(query, ignoreCase = true) it.extension.name.contains(query, ignoreCase = true)

View File

@ -24,7 +24,7 @@ class ExtensionDetailsPresenter(
extensionManager.getInstalledExtensionsObservable() extensionManager.getInstalledExtensionsObservable()
.skip(1) .skip(1)
.filter { extensions -> extensions.none { it.pkgName == pkgName } } .filter { extensions -> extensions.none { it.pkgName == pkgName } }
.map { Unit } .map { }
.take(1) .take(1)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeFirst({ view, _ -> .subscribeFirst({ view, _ ->

View File

@ -97,7 +97,7 @@ class SearchPresenter(
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking() val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
val maxChapterRead = prevMangaChapters val maxChapterRead = prevMangaChapters
.filter { it.read } .filter { it.read }
.maxBy { it.chapter_number }?.chapter_number .maxByOrNull { it.chapter_number }?.chapter_number
val bookmarkedChapters = prevMangaChapters val bookmarkedChapters = prevMangaChapters
.filter { it.bookmark && it.isRecognizedNumber } .filter { it.bookmark && it.isRecognizedNumber }
.map { it.chapter_number } .map { it.chapter_number }

View File

@ -27,9 +27,9 @@ class MigrationSourcesPresenter(
private fun findSourcesWithManga(library: List<Manga>): List<SourceItem> { private fun findSourcesWithManga(library: List<Manga>): List<SourceItem> {
val header = SelectionHeader() 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 } .mapNotNull { if (it != LocalSource.ID) sourceManager.getOrStub(it) else null }
.sortedBy { it.name.toLowerCase() } .sortedBy { it.name.toLowerCase() }
.map { SourceItem(it, header) } .map { SourceItem(it, header) }.toList()
} }
} }

View File

@ -13,7 +13,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.onStart
import rx.Observable import rx.Observable

View File

@ -264,7 +264,7 @@ open class BrowseSourceController(bundle: Bundle) :
searchView.maxWidth = Int.MAX_VALUE searchView.maxWidth = Int.MAX_VALUE
val query = presenter.query val query = presenter.query
if (!query.isBlank()) { if (query.isNotBlank()) {
searchItem.expandActionView() searchItem.expandActionView()
searchView.setQuery(query, true) searchView.setQuery(query, true)
searchView.clearFocus() searchView.clearFocus()

View File

@ -52,7 +52,7 @@ import java.util.Date
*/ */
open class BrowseSourcePresenter( open class BrowseSourcePresenter(
private val sourceId: Long, private val sourceId: Long,
private val searchQuery: String? = null, searchQuery: String? = null,
private val sourceManager: SourceManager = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(),
private val db: DatabaseHelper = Injekt.get(), private val db: DatabaseHelper = Injekt.get(),
private val prefs: PreferencesHelper = Injekt.get(), private val prefs: PreferencesHelper = Injekt.get(),
@ -153,9 +153,9 @@ open class BrowseSourcePresenter(
pagerSubscription?.let { remove(it) } pagerSubscription?.let { remove(it) }
pagerSubscription = pager.results() pagerSubscription = pager.results()
.observeOn(Schedulers.io()) .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) } .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()) .observeOn(AndroidSchedulers.mainThread())
.subscribeReplay( .subscribeReplay(
{ view, (page, mangas) -> { view, (page, mangas) ->

View File

@ -195,7 +195,7 @@ open class GlobalSearchController(
adapter?.updateDataSet(searchResult) 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) { if (progress < 1) {
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.progressBar.progress = (progress * 100).toInt() binding.progressBar.progress = (progress * 100).toInt()

View File

@ -222,9 +222,8 @@ open class GlobalSearchPresenter(
private fun initializeFetchImageSubscription() { private fun initializeFetchImageSubscription() {
fetchImageSubscription?.unsubscribe() fetchImageSubscription?.unsubscribe()
fetchImageSubscription = fetchImageSubject.observeOn(Schedulers.io()) fetchImageSubscription = fetchImageSubject.observeOn(Schedulers.io())
.flatMap { pair -> .flatMap { (first, source) ->
val source = pair.second Observable.from(first).filter { it.thumbnail_url == null && !it.initialized }
Observable.from(pair.first).filter { it.thumbnail_url == null && !it.initialized }
.map { Pair(it, source) } .map { Pair(it, source) }
.concatMap { getMangaDetailsObservable(it.first, it.second) } .concatMap { getMangaDetailsObservable(it.first, it.second) }
.map { Pair(source as CatalogueSource, it) } .map { Pair(source as CatalogueSource, it) }

View File

@ -52,7 +52,7 @@ class CategoryPresenter(
val cat = Category.create(name) val cat = Category.create(name)
// Set the new item in the last position. // 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. // Insert into database.
db.insertCategory(cat).asRxObservable().subscribe() db.insertCategory(cat).asRxObservable().subscribe()

View File

@ -101,11 +101,11 @@ class LibraryItem(val manga: LibraryManga, private val libraryDisplayMode: Prefe
private fun containsGenre(tag: String, genres: List<String>?): Boolean { private fun containsGenre(tag: String, genres: List<String>?): Boolean {
return if (tag.startsWith("-")) { return if (tag.startsWith("-")) {
genres?.find { genres?.find {
it.trim().toLowerCase() == tag.substringAfter("-").toLowerCase() it.trim().equals(tag.substringAfter("-"), ignoreCase = true)
} == null } == null
} else { } else {
genres?.find { genres?.find {
it.trim().toLowerCase() == tag.toLowerCase() it.trim().equals(tag, ignoreCase = true)
} != null } != null
} }
} }

View File

@ -409,9 +409,7 @@ class LibraryPresenter(
val mc = mutableListOf<MangaCategory>() val mc = mutableListOf<MangaCategory>()
for (manga in mangas) { for (manga in mangas) {
for (cat in categories) { categories.mapTo(mc) { MangaCategory.create(manga, it) }
mc.add(MangaCategory.create(manga, cat))
}
} }
db.setMangaCategories(mc, mangas) db.setMangaCategories(mc, mangas)

View File

@ -31,7 +31,7 @@ class SetTrackReadingDatesDialog<T> : DialogController
@Suppress("unused") @Suppress("unused")
constructor(bundle: Bundle) : super(bundle) { 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)!! val service = Injekt.get<TrackManager>().getService(track.sync_id)!!
item = TrackItem(track, service) item = TrackItem(track, service)
dateToUpdate = ReadingDate.Start dateToUpdate = ReadingDate.Start

View File

@ -4,7 +4,6 @@ import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.databinding.TrackItemBinding import eu.kanade.tachiyomi.databinding.TrackItemBinding
import eu.kanade.tachiyomi.util.view.inflate
class TrackAdapter(controller: TrackController) : RecyclerView.Adapter<TrackHolder>() { class TrackAdapter(controller: TrackController) : RecyclerView.Adapter<TrackHolder>() {

View File

@ -47,7 +47,7 @@ class TrackSearchAdapter(context: Context) :
binding.trackSearchTitle.text = track.title binding.trackSearchTitle.text = track.title
binding.trackSearchSummary.text = track.summary binding.trackSearchSummary.text = track.summary
GlideApp.with(view.context).clear(binding.trackSearchCover) GlideApp.with(view.context).clear(binding.trackSearchCover)
if (!track.cover_url.isEmpty()) { if (track.cover_url.isNotEmpty()) {
GlideApp.with(view.context) GlideApp.with(view.context)
.load(track.cover_url) .load(track.cover_url)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)

View File

@ -39,7 +39,7 @@ class ChapterLoadByNumber {
/** /**
* Load strategy using the chapter upload date. This ordering ignores scanlators * Load strategy using the chapter upload date. This ordering ignores scanlators
*/ */
class ChapterLoadByUploadDate() { class ChapterLoadByUploadDate {
fun get(allChapters: List<Chapter>): List<Chapter> { fun get(allChapters: List<Chapter>): List<Chapter> {
return allChapters.sortedBy { it.date_upload } return allChapters.sortedBy { it.date_upload }
} }

View File

@ -6,7 +6,6 @@ import android.widget.Spinner
import androidx.annotation.ArrayRes import androidx.annotation.ArrayRes
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.plusAssign
import androidx.core.widget.NestedScrollView import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.tfcporciuncula.flow.Preference import com.tfcporciuncula.flow.Preference

View File

@ -152,7 +152,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
// Initial opening - preload allowed // Initial opening - preload allowed
currentPage ?: return true 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 val nextChapter = (nextItem as? ChapterTransition.Next)?.to ?: (nextItem as? ReaderPage)?.chapter
// Allow preload for // Allow preload for

View File

@ -175,10 +175,10 @@ class EpubFile(file: File) : Closeable {
*/ */
private fun getPathSeparator(): String { private fun getPathSeparator(): String {
val meta = zip.getEntry("META-INF\\container.xml") val meta = zip.getEntry("META-INF\\container.xml")
if (meta != null) { return if (meta != null) {
return "\\" "\\"
} else { } else {
return "/" "/"
} }
} }
@ -206,10 +206,10 @@ class EpubFile(file: File) : Closeable {
*/ */
private fun getParentDirectory(path: String): String { private fun getParentDirectory(path: String): String {
val separatorIndex = path.lastIndexOf(pathSeparator) val separatorIndex = path.lastIndexOf(pathSeparator)
if (separatorIndex >= 0) { return if (separatorIndex >= 0) {
return path.substring(0, separatorIndex) path.substring(0, separatorIndex)
} else { } else {
return "" ""
} }
} }
} }

View File

@ -51,10 +51,7 @@ object ImageUtil {
} }
private fun ByteArray.compareWith(magic: ByteArray): Boolean { private fun ByteArray.compareWith(magic: ByteArray): Boolean {
for (i in magic.indices) { return magic.indices.none { this[it] != magic[it] }
if (this[i] != magic[i]) return false
}
return true
} }
private fun charByteArrayOf(vararg bytes: Int): ByteArray { private fun charByteArrayOf(vararg bytes: Int): ByteArray {

View File

@ -26,8 +26,8 @@ subprojects {
buildscript { buildscript {
dependencies { dependencies {
classpath("com.github.zellius:android-shortcut-gradle-plugin:0.1.2") classpath("com.github.zellius:android-shortcut-gradle-plugin:0.1.2")
classpath("com.google.gms:google-services:4.3.3") classpath("com.google.gms:google-services:4.3.4")
classpath("com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:8.3.0") classpath("com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:" + BuildPluginsVersion.ABOUTLIB_PLUGIN)
classpath(kotlin("serialization", version = BuildPluginsVersion.KOTLIN)) classpath(kotlin("serialization", version = BuildPluginsVersion.KOTLIN))
} }
repositories { repositories {

View File

@ -2,5 +2,6 @@ object BuildPluginsVersion {
const val AGP = "4.1.1" const val AGP = "4.1.1"
const val KOTLIN = "1.4.20" const val KOTLIN = "1.4.20"
const val KOTLINTER = "3.0.2" const val KOTLINTER = "3.0.2"
const val VERSIONS_PLUGIN = "0.33.0" const val VERSIONS_PLUGIN = "0.36.0"
const val ABOUTLIB_PLUGIN = "8.6.3"
} }