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"
// Licenses
// NOTE: REMEMBER TO UPDATE GRADLE PLUGIN
implementation 'com.mikepenz:aboutlibraries:8.4.2'
implementation "com.mikepenz:aboutlibraries:$BuildPluginsVersion.ABOUTLIB_PLUGIN"
// Tests
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>>> {
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)
}

View file

@ -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

View 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

View file

@ -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() }
}
}

View file

@ -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))
}
}

View file

@ -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>) {

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 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
}

View file

@ -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

View file

@ -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)

View file

@ -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, _ ->

View file

@ -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 }

View file

@ -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()
}
}

View file

@ -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

View file

@ -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()

View file

@ -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) ->

View file

@ -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()

View file

@ -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) }

View file

@ -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()

View file

@ -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
}
}

View file

@ -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)

View file

@ -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

View file

@ -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>() {

View file

@ -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)

View file

@ -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 }
}

View file

@ -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

View file

@ -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

View file

@ -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 ""
""
}
}
}

View file

@ -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 {

View file

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

View file

@ -2,5 +2,6 @@ object BuildPluginsVersion {
const val AGP = "4.1.1"
const val KOTLIN = "1.4.20"
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"
}