Minor cleanup, remove some usages of ArrayList

This commit is contained in:
arkon
2020-05-30 23:34:58 -04:00
parent 3e837f8781
commit bf5065d16b
12 changed files with 28 additions and 41 deletions

View File

@@ -78,15 +78,15 @@ class ExtensionPreferencesController(bundle: Bundle? = null) :
val multiSource = extension.sources.size > 1
for (source in extension.sources) {
if (source is ConfigurableSource) {
extension.sources
.filterIsInstance<ConfigurableSource>()
.forEach { source ->
try {
addPreferencesForSource(screen, source, multiSource)
} catch (e: AbstractMethodError) {
Timber.e("Source did not implement [addPreferencesForSource]: ${source.name}")
}
}
}
manager.setPreferences(screen)

View File

@@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.databinding.DownloadControllerBinding
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight
import java.util.HashMap
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@@ -39,7 +38,7 @@ class DownloadController :
/**
* Map of subscriptions for active downloads.
*/
private val progressSubscriptions by lazy { HashMap<Download, Subscription>() }
private val progressSubscriptions by lazy { mutableMapOf<Download, Subscription>() }
/**
* Whether the download queue is running or not.

View File

@@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.removeCovers
import eu.kanade.tachiyomi.util.updateCoverLastModified
import java.util.ArrayList
import java.util.Collections
import java.util.Comparator
import rx.Observable
@@ -348,7 +347,7 @@ class LibraryPresenter(
* @param mangas the list of manga to move.
*/
fun moveMangasToCategories(categories: List<Category>, mangas: List<Manga>) {
val mc = ArrayList<MangaCategory>()
val mc = mutableListOf<MangaCategory>()
for (manga in mangas) {
for (cat in categories) {

View File

@@ -24,9 +24,6 @@ import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
/**
* Presenter of [ChaptersController].
*/
class ChaptersPresenter(
val manga: Manga,
val source: Source,
@@ -47,8 +44,9 @@ class ChaptersPresenter(
/**
* Subject of list of chapters to allow updating the view without going to DB.
*/
val chaptersRelay: PublishRelay<List<ChapterItem>>
by lazy { PublishRelay.create<List<ChapterItem>>() }
private val chaptersRelay: PublishRelay<List<ChapterItem>> by lazy {
PublishRelay.create<List<ChapterItem>>()
}
/**
* Whether the chapter list has been requested to the source.
@@ -144,11 +142,9 @@ class ChaptersPresenter(
* @param chapters the list of chapter from the database.
*/
private fun setDownloadedChapters(chapters: List<ChapterItem>) {
for (chapter in chapters) {
if (downloadManager.isChapterDownloaded(chapter, manga)) {
chapter.status = Download.DOWNLOADED
}
}
chapters
.filter { downloadManager.isChapterDownloaded(it, manga) }
.forEach { it.status = Download.DOWNLOADED }
}
/**
@@ -222,7 +218,7 @@ class ChaptersPresenter(
* Called when a download for the active manga changes status.
* @param download the download whose status changed.
*/
fun onDownloadStatusChange(download: Download) {
private fun onDownloadStatusChange(download: Download) {
// Assign the download to the model object.
if (download.status == Download.QUEUE) {
chapters.find { it.id == download.chapter.id }?.let {

View File

@@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.inflate
import java.util.ArrayList
import kotlinx.android.synthetic.main.track_search_item.view.track_search_cover
import kotlinx.android.synthetic.main.track_search_item.view.track_search_start
import kotlinx.android.synthetic.main.track_search_item.view.track_search_start_result
@@ -22,7 +21,7 @@ import kotlinx.android.synthetic.main.track_search_item.view.track_search_type
import kotlinx.android.synthetic.main.track_search_item.view.track_search_type_result
class TrackSearchAdapter(context: Context) :
ArrayAdapter<TrackSearch>(context, R.layout.track_search_item, ArrayList<TrackSearch>()) {
ArrayAdapter<TrackSearch>(context, R.layout.track_search_item, mutableListOf<TrackSearch>()) {
override fun getView(position: Int, view: View?, parent: ViewGroup): View {
var v = view