LzSdkManager
object LzSdkManagerMain entry point and data manager for the Lazarillo SDK.
This singleton object serves as the central hub for SDK operations, managing:
- SDK initialization and configuration
- API authentication and state
- Data caching (places, routes, beacons)
- Location and routing data coordination
Why this class exists: The SDK needs a centralized manager to coordinate between different components (maps, location providers, repositories) and maintain shared state like API keys, cached data, and current routes. This singleton pattern ensures consistent state across the entire SDK without requiring view references, making it suitable for use in ViewModels and other non-UI components.
Important: This class should not contain view references. It acts as a data layer that can be consumed by ViewModels or other business logic components.
Properties
USER_VELOCITY
const val USER_VELOCITY: Double = 1.5Functions
clearRoute
fun clearRoute()Clears the currently displayed route.
clearSubPlacesCache
fun clearSubPlacesCache(parentPlaceId: String? = null)Clears the sub-places cache for a specific place or all places.
distanceBetweenTwoMessagePoints
suspend fun distanceBetweenTwoMessagePoints(parentPaceId: String, messagePoint1: String, messagePoint2: String): Int?Calculates the distance between two message points.
getBeaconsIds
fun getBeaconsIds(): List<String>?Gets the currently set simulated beacon IDs.
getCachedSubPlaces
fun getCachedSubPlaces(): List<SdkPlace>Types: SdkPlace
Retrieves cached sub-places synchronously without making API calls.
getConfiguration
suspend fun getConfiguration(placeId: String): ConfigurationResponse?Types: ConfigurationResponse
Fetch the configuration for a place, with caching. Returns the configuration response or null if the request fails.
getCurrentShowingRoute
fun getCurrentShowingRoute(): SdkRoute?Types: SdkRoute
Gets the currently set route.
getMessagePointDistances
suspend fun getMessagePointDistances(targetPlace: String): MessagePointDistancesDTO?Retrieves message point distance matrix for a place.
getParentPlace
fun getParentPlace(): String?Gets the currently set parent place ID.
getParentPlaces
suspend fun getParentPlaces(apiKey: String? = null): Response<List<SdkPlace>>Types: SdkPlace
Retrieves the list of available parent places for an API key.
getPlace
suspend fun getPlace(placeId: String): Response<SdkPlace>Types: SdkPlace
Retrieves place information from cache or the backend API.
getPublicPlace
suspend fun getPublicPlace(placeId: String, apiKey: String?): Response<SdkPlace>Types: SdkPlace
Retrieves public place information (may not require authentication).
getRawRoute
suspend fun getRawRoute(initialPos: LzLocation, finalPos: LzLocation, initialFloor: String?, finalFloor: String?, place: String?, preferAccessibleRoute: Boolean = false, language: String = "en", announceFormat: AnnounceFormat? = DEFAULT_ANNOUNCE_FORMAT, unitSystem: UnitSystem? = DEFAULT_UNIT_SYSTEM): Response<ResponseBody>?Types: LzLocation, AnnounceFormat, UnitSystem
Retrieves raw route data as ResponseBody (advanced use case).
getRoute
fun getRoute(): SdkRoute?
suspend fun getRoute(initialLocation: Any, finalLocation: Any, preferAccessibleRoute: Boolean = false, language: String = "en", announceFormat: AnnounceFormat? = DEFAULT_ANNOUNCE_FORMAT, unitSystem: UnitSystem? = DEFAULT_UNIT_SYSTEM): Response<List<SdkRoute>>Types: SdkRoute, AnnounceFormat, UnitSystem
Calculates a route between two locations using the backend routing service.
getSubPlaces
suspend fun getSubPlaces(): List<SdkPlace>
suspend fun getSubPlaces(parentPlaceId: String): List<SdkPlace>Types: SdkPlace
Retrieves sub-places for the currently set parent place.
Retrieves sub-places for a specific parent place with intelligent caching.
initialize
fun initialize(context: Context, apiKey: String?, targetParentPlaceId: String? = null, validateWithBackend: Boolean = false, enableLogging: Boolean = false)Initializes the SDK with the provided configuration.
isLoggingEnabled
fun isLoggingEnabled(): BooleanCheck if logging is currently enabled.
isSdkActive
fun isSdkActive(): BooleanChecks if the SDK is currently active (initialized with valid API key).
loadCacheForLocationUpdates
suspend fun loadCacheForLocationUpdates(parentPlaceId: String?)Pre-loads location-related cache data (beacons and message points) for a place.
setBeaconsIds
fun setBeaconsIds(targetIds: List<String>)Sets beacon IDs for location simulation (testing/development only).
setCurrentShowingRoute
fun setCurrentShowingRoute(targetRoute: SdkRoute)Types: SdkRoute
Sets the currently displayed route in the SDK.
setLoggingEnabled
fun setLoggingEnabled(enabled: Boolean)Enable or disable SDK logging. By default, logging is disabled to reduce noise in production.
setParentPlace
fun setParentPlace(targetParentPlaceId: String)Sets the parent place ID for the SDK.
setRoute
fun setRoute(targetRoute: SdkRoute)Types: SdkRoute
setUpManager
fun setUpManager(apiKey: String?, targetParentPlaceId: String? = null, targetSimulatedIds: List<String>? = null, context: Context)Main method to initialize the sdk. Should be called at the beginning of the interaction with the sdk to make things work properly. Optional parameters could be passed after the initialization as well.