From a48529872d2166775c412058db25fdde9e2c4566 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Sat, 31 Oct 2020 15:57:49 -0400 Subject: [PATCH] Fix a few Kotlin style issues --- .../java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt | 2 +- .../org/schabi/newpipe/local/feed/service/FeedLoadService.kt | 4 ++-- .../local/subscription/dialog/FeedGroupDialogViewModel.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt index d319c9fa3..f77e13f69 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt @@ -50,7 +50,7 @@ class FeedDatabaseManager(context: Context) { return streams.map> { val items = ArrayList(it.size) - for (streamEntity in it) items.add(streamEntity.toStreamInfoItem()) + it.mapTo(items) { it.toStreamInfoItem() } return@map items } } diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt b/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt index 0181f2711..556c215d9 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt @@ -161,8 +161,8 @@ class FeedLoadService : Service() { companion object { fun wrapList(subscriptionId: Long, info: ListInfo): List { val toReturn = ArrayList(info.errors.size) - for (error in info.errors) { - toReturn.add(RequestException(subscriptionId, info.serviceId.toString() + ":" + info.url, error)) + info.errors.mapTo(toReturn) { + RequestException(subscriptionId, info.serviceId.toString() + ":" + info.url, it) } return toReturn } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialogViewModel.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialogViewModel.kt index e9a7e4eb7..4b1a4df5e 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialogViewModel.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialogViewModel.kt @@ -37,8 +37,8 @@ class FeedGroupDialogViewModel( BiFunction { t1: String, t2: Boolean -> Filter(t1, t2) } ) .distinctUntilChanged() - .switchMap { filter -> - subscriptionManager.getSubscriptions(groupId, filter.query, filter.showOnlyUngrouped) + .switchMap { (query, showOnlyUngrouped) -> + subscriptionManager.getSubscriptions(groupId, query, showOnlyUngrouped) }.map { list -> list.map { PickerSubscriptionItem(it) } } private val mutableGroupLiveData = MutableLiveData()