|
|
@ -31,14 +31,12 @@ import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
|
|
|
|
* [UserNewsResource]s.
|
|
|
|
* [UserNewsResource]s.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* [onToggleBookmark] defines the action invoked when a user wishes to bookmark an item
|
|
|
|
* [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
|
|
|
|
* When a news resource card is tapped it will open the news resource URL in a Chrome Custom Tab.
|
|
|
|
* default action launches an intent matching the card.
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
fun LazyListScope.userNewsResourceCardItems(
|
|
|
|
fun LazyListScope.userNewsResourceCardItems(
|
|
|
|
items: List<UserNewsResource>,
|
|
|
|
items: List<UserNewsResource>,
|
|
|
|
onToggleBookmark: (item: UserNewsResource) -> Unit,
|
|
|
|
onToggleBookmark: (item: UserNewsResource) -> Unit,
|
|
|
|
onNewsResourceViewed: (String) -> Unit,
|
|
|
|
onNewsResourceViewed: (String) -> Unit,
|
|
|
|
onItemClick: ((item: UserNewsResource) -> Unit)? = null,
|
|
|
|
|
|
|
|
onTopicClick: (String) -> Unit,
|
|
|
|
onTopicClick: (String) -> Unit,
|
|
|
|
itemModifier: Modifier = Modifier,
|
|
|
|
itemModifier: Modifier = Modifier,
|
|
|
|
) = items(
|
|
|
|
) = items(
|
|
|
@ -59,10 +57,7 @@ fun LazyListScope.userNewsResourceCardItems(
|
|
|
|
analyticsHelper.logNewsResourceOpened(
|
|
|
|
analyticsHelper.logNewsResourceOpened(
|
|
|
|
newsResourceId = userNewsResource.id,
|
|
|
|
newsResourceId = userNewsResource.id,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
when (onItemClick) {
|
|
|
|
launchCustomChromeTab(context, resourceUrl, backgroundColor)
|
|
|
|
null -> launchCustomChromeTab(context, resourceUrl, backgroundColor)
|
|
|
|
|
|
|
|
else -> onItemClick(userNewsResource)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onNewsResourceViewed(userNewsResource.id)
|
|
|
|
onNewsResourceViewed(userNewsResource.id)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onTopicClick = onTopicClick,
|
|
|
|
onTopicClick = onTopicClick,
|
|
|
|