forked from organicmaps/organicmaps
[MAPSME-5045] [ios] Added save/restore route points support.
This commit is contained in:
parent
c3e214a0a7
commit
fe2fbc1511
3 changed files with 32 additions and 0 deletions
|
@ -404,6 +404,8 @@ using namespace osm_auth_ios;
|
|||
}
|
||||
[self enableTTSForTheFirstTime];
|
||||
|
||||
[MWMRouter restoreRouteIfNeeded];
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
@ -524,6 +526,7 @@ using namespace osm_auth_ios;
|
|||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
[self.mapViewController onTerminate];
|
||||
[MWMRouter saveRouteIfNeeded];
|
||||
|
||||
#ifdef OMIM_PRODUCTION
|
||||
auto err = [[NSError alloc] initWithDomain:kMapsmeErrorDomain
|
||||
|
|
|
@ -47,6 +47,9 @@ typedef void (^MWMImageHeightBlock)(UIImage *, NSString *);
|
|||
+ (BOOL)hasRouteAltitude;
|
||||
+ (void)routeAltitudeImageForSize:(CGSize)size completion:(MWMImageHeightBlock)block;
|
||||
|
||||
+ (void)saveRouteIfNeeded;
|
||||
+ (void)restoreRouteIfNeeded;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMRouter (RouteManager)
|
||||
|
|
|
@ -645,4 +645,30 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType)
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Save / Load route points
|
||||
|
||||
+ (void)saveRouteIfNeeded
|
||||
{
|
||||
if ([self isRoutingActive])
|
||||
GetFramework().GetRoutingManager().SaveRoutePoints();
|
||||
}
|
||||
|
||||
+ (void)restoreRouteIfNeeded
|
||||
{
|
||||
if ([MapsAppDelegate theApp].isDrapeEngineCreated)
|
||||
{
|
||||
auto & rm = GetFramework().GetRoutingManager();
|
||||
if ([self isRoutingActive] || !rm.HasSavedRoutePoints())
|
||||
return;
|
||||
rm.LoadRoutePoints();
|
||||
[self rebuildWithBestRouter:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self restoreRouteIfNeeded];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Reference in a new issue