diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2019-06-28 15:02:09 -0700 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2019-07-09 15:03:39 -0700 |
commit | db94c9c964bfb2454373fd1f5dd5472a6b679de0 (patch) | |
tree | c144d4a612384a8719ff3df1e7ef3d0a94d28ea3 | |
parent | b58e766ca68a41f582b85111c0eacd53a16ce341 (diff) | |
download | qtlocation-mapboxgl-db94c9c964bfb2454373fd1f5dd5472a6b679de0.tar.gz |
[ios] finished invalidateOfflineRegionForPack
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.h | 1 | ||||
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 41 |
2 files changed, 10 insertions, 32 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.h b/platform/darwin/src/MGLOfflineStorage.h index 0b355e2fc6..d646e77583 100644 --- a/platform/darwin/src/MGLOfflineStorage.h +++ b/platform/darwin/src/MGLOfflineStorage.h @@ -303,6 +303,7 @@ MGL_EXPORT */ - (void)removePack:(MGLOfflinePack *)pack withCompletionHandler:(nullable MGLOfflinePackRemovalCompletionHandler)completion; +- (void)invalidateOfflineRegionForPack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion; /** Forcibly, asynchronously reloads the `packs` property. At some point after this method is called, the pointer values of the `MGLOfflinePack` objects in the diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 60b4dccba7..6a6df0e480 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -447,46 +447,23 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio } - (void)invalidateOfflineRegionForPack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion { - const mbgl::OfflineRegion *region = pack.mbglOfflineRegion; - const mbgl::OfflineRegion&& regionRef = &pack.mbglOfflineRegion; + + if (!completion) { return; } + mbgl::OfflineRegion& region = *pack.mbglOfflineRegion; NSError *error; - if (!region) { + if (!pack.mbglOfflineRegion) { completion(nil); return; } - _mbglFileSource->invalidateOfflineRegion(regionRef, [&, completion](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> mbglOfflineRegion) { - if (mbglOfflineRegion) { + + _mbglFileSource->invalidateOfflineRegion(region, [&](std::exception_ptr exception) { + if (exception) { error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{ - + NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()), }]; } }); - } -//- (void)invalidateOfflineRegion:(id <MGLOfflineRegion>)region withCompletionHandler:(void (^)(NSError * _Nullable))completion { -// if (!completion) { return; } -// -// if (![region conformsToProtocol:@protocol(MGLOfflineRegion_Private)]) { -// [NSException raise:MGLUnsupportedRegionTypeException -// format:@"Regions of type %@ are unsupported.", NSStringFromClass([region class])]; -// return; -// } -// -//// const mbgl::OfflineRegionDefinition regionDefinition = [(id <MGLOfflineRegion_Private>)region offlineRegionDefinition]; -//// _mbglFileSource->createOfflineRegion(regionDefinition, nil, [&, completion](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> mbglOfflineRegion) { -//// }); -//// // JK - I need to convert the MGLOfflineRegion to an OfflineRegion. :ohno: -//// mbgl::OfflineRegion offlineRegion = const_cast<mbgl::OfflineRegion>(region); -// MGLShapeOfflineRegion *weakCopy = region; -// -// _mbglFileSource->invalidateOfflineRegion(weakCopy, [&, completion](std::exception_ptr exception) { -// NSError *error; -// if (error) { -// error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{ -// -// }]; -// } -// }); -//} + - (void)reloadPacks { MGLLogInfo(@"Reloading packs."); [self getPacksWithCompletionHandler:^(NSArray<MGLOfflinePack *> *packs, __unused NSError * _Nullable error) { |