From 51379a249db820fac375ac8c793285a36300861e Mon Sep 17 00:00:00 2001 From: gururani-abhishek Date: Sun, 30 Apr 2023 14:04:15 +0530 Subject: [PATCH 1/3] fix #614 : removed unused onItemClick parameter from NewsResourceCardList.kt 1. removed the unused onItemClick parameter 2. removed now redundant variables it used 3. removed its description from the comments. --- .../apps/nowinandroid/core/ui/NewsResourceCardList.kt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt index 5cf7d7313..4d04ea620 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt @@ -31,23 +31,18 @@ import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource * [UserNewsResource]s. * * [onToggleBookmark] defines the action invoked when a user wishes to bookmark an item - * [onItemClick] optional parameter for action to be performed when the card is clicked. The - * default action launches an intent matching the card. + * Default action launches an intent matching the card. */ fun LazyListScope.userNewsResourceCardItems( items: List, onToggleBookmark: (item: UserNewsResource) -> Unit, onNewsResourceViewed: (String) -> Unit, - onItemClick: ((item: UserNewsResource) -> Unit)? = null, onTopicClick: (String) -> Unit, itemModifier: Modifier = Modifier, ) = items( items = items, key = { it.id }, itemContent = { userNewsResource -> - val resourceUrl = Uri.parse(userNewsResource.url) - val backgroundColor = MaterialTheme.colorScheme.background.toArgb() - val context = LocalContext.current val analyticsHelper = LocalAnalyticsHelper.current NewsResourceCardExpanded( @@ -59,10 +54,6 @@ fun LazyListScope.userNewsResourceCardItems( analyticsHelper.logNewsResourceOpened( newsResourceId = userNewsResource.id, ) - when (onItemClick) { - null -> launchCustomChromeTab(context, resourceUrl, backgroundColor) - else -> onItemClick(userNewsResource) - } onNewsResourceViewed(userNewsResource.id) }, onTopicClick = onTopicClick, From bbc80bb0e2b836981e3d335a6e457d910375fd3a Mon Sep 17 00:00:00 2001 From: gururani-abhishek Date: Wed, 3 May 2023 16:40:36 +0530 Subject: [PATCH 2/3] added back launchCustomChromeTab() --- .../samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt index 4d04ea620..81a5b9c4a 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt @@ -43,6 +43,9 @@ fun LazyListScope.userNewsResourceCardItems( items = items, key = { it.id }, itemContent = { userNewsResource -> + val resourceUrl = Uri.parse(userNewsResource.url) + val backgroundColor = MaterialTheme.colorScheme.background.toArgb() + val context = LocalContext.current val analyticsHelper = LocalAnalyticsHelper.current NewsResourceCardExpanded( @@ -54,6 +57,7 @@ fun LazyListScope.userNewsResourceCardItems( analyticsHelper.logNewsResourceOpened( newsResourceId = userNewsResource.id, ) + launchCustomChromeTab(context, resourceUrl, backgroundColor) onNewsResourceViewed(userNewsResource.id) }, onTopicClick = onTopicClick, From f6bdba08d9f3f65acc27777f97e0fcda38bf8961 Mon Sep 17 00:00:00 2001 From: gururani-abhishek Date: Wed, 3 May 2023 22:39:50 +0530 Subject: [PATCH 3/3] added comment to document what happens on tapping news resource card. --- .../samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt index 81a5b9c4a..ea1c09d01 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt @@ -31,7 +31,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource * [UserNewsResource]s. * * [onToggleBookmark] defines the action invoked when a user wishes to bookmark an item - * Default action launches an intent matching the card. + * When a news resource card is tapped it will open the news resource URL in a Chrome Custom Tab. */ fun LazyListScope.userNewsResourceCardItems( items: List,