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_domainUnified: 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
)Content copied to clipboard