Loading...
Searching...
No Matches
LocationListManager Directory Reference

Directories

 dart
 
 java
 
 kotlin
 
 objc
 
 swift
 

Detailed Description

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:

Key Components

LocationListManager

The main class for managing location list operations:

LocationListListener

Interface for receiving location list notifications:

LocationInfo

Represents basic information about a location:

Platform-Specific Files

Dart/Flutter

Java

Kotlin

Objective-C

Swift

Key Documentation Tags

LocationListManager Methods

LocationListListener Methods

LocationInfo Properties

Common Usage Patterns

1. Initialization

// Get SDK instance and managers
NavigineSdk sdk = NavigineSdk.getInstance();
LocationListManager locationListManager = sdk.getLocationListManager();

2. Setting up Location List Listener

LocationListListener listener = LocationListListener(
onLocationListLoaded: (locationInfos) {
// Handle loaded location list
},
onLocationListFailed: (error) {
// Handle download failure
},
);
locationListManager.addLocationListListener(listener);

3. Updating Location List

// Force reload location list from server
locationListManager.updateLocationList();
// Get current cached location list
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}");
// Implement retry logic or user notification
}

6. Cleanup

// Remove listener when no longer needed
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:

// Add multiple listeners
LocationListListener listener1 = LocationListListener(...);
LocationListListener listener2 = LocationListListener(...);
locationListManager.addLocationListListener(listener1);
locationListManager.addLocationListListener(listener2);
// All listeners will receive the same notifications
locationListManager.updateLocationList();

Listener Management

Proper listener management is crucial to prevent memory leaks:

// Always remove listeners when they're no longer needed
locationListManager.removeLocationListListener(listener1);
locationListManager.removeLocationListListener(listener2);

Simulated Data

The examples include simulation features for testing:

// Simulate location list updates
Map<int, LocationInfo> simulatedLocations = {
1001: LocationInfo(1001, 1, "Shopping Mall"),
1002: LocationInfo(1002, 2, "Office Building"),
// ...
};

Notes