This directory contains comprehensive examples demonstrating the usage of the Navigine SDK's LocationListManager across all supported platforms.
Overview
The LocationListManager is responsible for downloading and managing the list of available locations from the server. It provides functionality for:
- Location List Management: Downloading and managing available locations
- Real-time Updates: Receiving notifications when location lists are updated
- Location Information: Accessing basic information about each location
- Error Handling: Managing download failures and network issues
Key Components
LocationListManager
The main class for managing location list operations:
addLocationListListener()
/ removeLocationListListener()
- Manage location list listeners
updateLocationList()
- Force reload location list from server
getLocationList()
- Get current cached location list
LocationListListener
Interface for receiving location list notifications:
onLocationListLoaded()
- Called when location list is successfully downloaded
onLocationListFailed()
- Called when location list download fails
LocationInfo
Represents basic information about a location:
id
- Unique location identifier
version
- Current location version
name
- Location name
Platform-Specific Files
Dart/Flutter
Java
Kotlin
Objective-C
Swift
Key Documentation Tags
LocationListManager Methods
[platform_LocationListManager_addLocationListListener]
- Adding location list listeners
[platform_LocationListManager_removeLocationListListener]
- Removing location list listeners
[platform_LocationListManager_updateLocationList]
- Force reloading location list
[platform_LocationListManager_getLocationList]
- Getting current location list
LocationListListener Methods
[platform_LocationListListener_onLocationListLoaded]
- Location list loaded callbacks
[platform_LocationListListener_onLocationListFailed]
- Location list failed callbacks
LocationInfo Properties
[platform_LocationInfo_getId]
- Getting location ID
[platform_LocationInfo_getVersion]
- Getting location version
[platform_LocationInfo_getName]
- Getting location name
Common Usage Patterns
1. Initialization
NavigineSdk sdk = NavigineSdk.getInstance();
LocationListManager locationListManager = sdk.getLocationListManager();
2. Setting up Location List Listener
LocationListListener listener = LocationListListener(
onLocationListLoaded: (locationInfos) {
},
onLocationListFailed: (error) {
},
);
locationListManager.addLocationListListener(listener);
3. Updating Location List
locationListManager.updateLocationList();
Map<int, LocationInfo> currentList = locationListManager.getLocationList();
4. Processing Location Information
void onLocationListLoaded(Map<int, LocationInfo> locationInfos) {
locationInfos.forEach((locationId, locationInfo) {
print("Location ${locationInfo.id}: ${locationInfo.name} (v${locationInfo.version})");
});
}
5. Error Handling
void onLocationListFailed(Error error) {
print("Failed to load location list: ${error.message}");
}
6. Cleanup
locationListManager.removeLocationListListener(listener);
Running Examples
Dart/Flutter
cd examples/LocationListManager/dart
dart location_list_manager_example.dart
Java
cd examples/LocationListManager/java
javac LocationListManagerExample.java
java LocationListManagerExample
Kotlin
cd examples/LocationListManager/kotlin
kotlinc LocationListManagerExample.kt -include-runtime -d LocationListManagerExample.jar
java -jar LocationListManagerExample.jar
Objective-C
cd examples/LocationListManager/objc
clang -framework Foundation LocationListManagerExample.m -o LocationListManagerExample
./LocationListManagerExample
Swift
cd examples/LocationListManager/swift
swift LocationListManagerExample.swift
Advanced Features
Multiple Listeners
The examples demonstrate how to add multiple listeners to the same LocationListManager:
LocationListListener listener1 = LocationListListener(...);
LocationListListener listener2 = LocationListListener(...);
locationListManager.addLocationListListener(listener1);
locationListManager.addLocationListListener(listener2);
locationListManager.updateLocationList();
Listener Management
Proper listener management is crucial to prevent memory leaks:
locationListManager.removeLocationListListener(listener1);
locationListManager.removeLocationListListener(listener2);
Simulated Data
The examples include simulation features for testing:
Map<int, LocationInfo> simulatedLocations = {
1001: LocationInfo(1001, 1, "Shopping Mall"),
1002: LocationInfo(1002, 2, "Office Building"),
};
Notes
- All examples demonstrate the same functionality across platforms
- Location lists are downloaded from the server and cached locally
- Listeners should be properly removed to prevent memory leaks
- The
updateLocationList()
method forces a fresh download from the server
- Location IDs are unique integers assigned by the server
- Location versions help track updates and determine if local data is stale
- Error handling is important for network connectivity issues
- The location list is typically used as a first step before loading specific locations