From cf053ade5ae045022512da09c5477f197403d172 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Wed, 21 Dec 2022 18:19:12 +0000 Subject: [PATCH] Fix build warnings --- .../src/main/kotlin/AndroidHiltConventionPlugin.kt | 4 +++- .../core/domain/GetSaveableNewsResourcesUseCase.kt | 4 ++-- .../apps/nowinandroid/core/ui/NewsResourceCard.kt | 1 + .../apps/nowinandroid/feature/topic/TopicViewModel.kt | 11 +++++------ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt index 0ae7e60e0..772064942 100644 --- a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt @@ -27,8 +27,10 @@ class AndroidHiltConventionPlugin : Plugin { override fun apply(target: Project) { with(target) { with(pluginManager) { - apply("org.jetbrains.kotlin.kapt") apply("dagger.hilt.android.plugin") + // KAPT must go last to avoid build warnings. + // See: https://stackoverflow.com/questions/70550883/warning-the-following-options-were-not-recognized-by-any-processor-dagger-f + apply("org.jetbrains.kotlin.kapt") } val libs = extensions.getByType().named("libs") diff --git a/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt b/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt index 4bd2fc6c3..4f0cb62bc 100644 --- a/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt +++ b/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt @@ -56,10 +56,10 @@ class GetSaveableNewsResourcesUseCase @Inject constructor( } private fun Flow>.mapToSaveableNewsResources( - savedNewsResourceIds: Flow> + savedNewsResourceIdsStream: Flow> ): Flow> = filterNot { it.isEmpty() } - .combine(savedNewsResourceIds) { newsResources, savedNewsResourceIds -> + .combine(savedNewsResourceIdsStream) { newsResources, savedNewsResourceIds -> newsResources.map { newsResource -> SaveableNewsResource( newsResource = newsResource, diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt index 21ee1a7a8..728d808ab 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt @@ -213,6 +213,7 @@ fun NewsResourceMetaData( @Composable fun NewsResourceLink( + @Suppress("UNUSED_PARAMETER") newsResource: NewsResource ) { TODO() diff --git a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt index 17096ca88..2c5f76f63 100644 --- a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt +++ b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt @@ -45,7 +45,6 @@ class TopicViewModel @Inject constructor( stringDecoder: StringDecoder, private val userDataRepository: UserDataRepository, topicsRepository: TopicsRepository, - // newsRepository: NewsRepository, getSaveableNewsResources: GetSaveableNewsResourcesUseCase ) : ViewModel() { @@ -97,13 +96,13 @@ private fun topicUiState( .map { it.followedTopics } // Observe topic information - val topic: Flow = topicsRepository.getTopic( + val topicStream: Flow = topicsRepository.getTopic( id = topicId ) return combine( followedTopicIds, - topic, + topicStream, ::Pair ) .asResult() @@ -135,7 +134,7 @@ private fun newsUiState( userDataRepository: UserDataRepository, ): Flow { // Observe news - val news: Flow> = getSaveableNewsResources( + val newsStream: Flow> = getSaveableNewsResources( filterTopicIds = setOf(element = topicId), ) @@ -144,7 +143,7 @@ private fun newsUiState( .map { it.bookmarkedNewsResources } return combine( - news, + newsStream, bookmark, ::Pair ) @@ -152,7 +151,7 @@ private fun newsUiState( .map { newsToBookmarksResult -> when (newsToBookmarksResult) { is Result.Success -> { - val (news, bookmarks) = newsToBookmarksResult.data + val news = newsToBookmarksResult.data.first NewsUiState.Success(news) } is Result.Loading -> {