SearchResultItem

data class SearchResultItem(val id: String, val title: String, val subtitle: String?, val latitude: Double, val longitude: Double, val isFavorite: Boolean = false)

Represents a search result item for Android Auto display.

This is a clean data class with no dependencies on app-side modules, making it suitable for inclusion in the MSDK. It provides a unified representation for both autocomplete suggestions and favorite addresses.

Purpose

  • Abstraction: Decouples Android Auto search UI from specific data types

  • MSDK-ready: No dependencies on app-side modules like favorites_address_domain

  • Unified: Single type for both suggestions and favorites

Usage

The app's SearchProvider implementation converts its internal types (e.g., AutocompleteResult, FavoriteAddress) to this class:

fun AutocompleteResult.toSearchResultItem() = SearchResultItem(
id = "search_${coordinate.latitude}_${coordinate.longitude}",
title = place,
subtitle = addressLabel,
latitude = coordinate.latitude(),
longitude = coordinate.longitude(),
isFavorite = false
)

See also

Constructors

Link copied to clipboard
constructor(id: String, title: String, subtitle: String?, latitude: Double, longitude: Double, isFavorite: Boolean = false)

Properties

Link copied to clipboard
val id: String

Unique identifier for deduplication (e.g., "search_lat_lon" or "fav_id")

Link copied to clipboard

Whether this result is from the user's saved favorites

Link copied to clipboard

Latitude coordinate of the location

Link copied to clipboard

Longitude coordinate of the location

Link copied to clipboard

Secondary display text (full address label), nullable

Link copied to clipboard

Primary display text (place name)