Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
16
iphone/Maps/Core/Storage/MWMStorage+UI.h
Normal file
16
iphone/Maps/Core/Storage/MWMStorage+UI.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#import <CoreApi/MWMStorage.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MWMStorage (UI)
|
||||
|
||||
- (void)downloadNode:(NSString *)countryId;
|
||||
- (void)downloadNode:(NSString *)countryId onSuccess:(nullable MWMVoidBlock)success;
|
||||
- (void)updateNode:(NSString *)countryId;
|
||||
- (void)updateNode:(NSString *)countryId onCancel:(nullable MWMVoidBlock)cancel;
|
||||
- (void)deleteNode:(NSString *)countryId;
|
||||
- (void)downloadNodes:(NSArray<NSString *> *)countryIds onSuccess:(nullable MWMVoidBlock)success;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
109
iphone/Maps/Core/Storage/MWMStorage+UI.m
Normal file
109
iphone/Maps/Core/Storage/MWMStorage+UI.m
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#import "MWMStorage+UI.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
|
||||
@implementation MWMStorage (UI)
|
||||
|
||||
- (void)handleError:(NSError *)error {
|
||||
if (error.code == kStorageNotEnoughSpace) {
|
||||
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
|
||||
} else if (error.code == kStorageNoConnection) {
|
||||
[[MWMAlertViewController activeAlertController] presentNoConnectionAlert];
|
||||
} else if (error.code == kStorageRoutingActive) {
|
||||
[[MWMAlertViewController activeAlertController] presentDeleteMapProhibitedAlert];
|
||||
} else {
|
||||
NSAssert(NO, @"Unknown error code");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadNode:(NSString *)countryId {
|
||||
[self downloadNode:countryId onSuccess:nil];
|
||||
}
|
||||
|
||||
- (void)downloadNode:(NSString *)countryId onSuccess:(MWMVoidBlock)success {
|
||||
NSError *error;
|
||||
[self downloadNode:countryId error:&error];
|
||||
if (error) {
|
||||
if (error.code == kStorageCellularForbidden) {
|
||||
__weak __typeof(self) ws = self;
|
||||
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
|
||||
[self enableCellularDownload:YES];
|
||||
[ws downloadNode:countryId];
|
||||
} andCancelBlock:nil];
|
||||
} else {
|
||||
[self handleError:error];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateNode:(NSString *)countryId {
|
||||
[self updateNode:countryId onCancel:nil];
|
||||
}
|
||||
|
||||
- (void)updateNode:(NSString *)countryId onCancel:(MWMVoidBlock)cancel {
|
||||
NSError *error;
|
||||
[self updateNode:countryId error:&error];
|
||||
if (error) {
|
||||
if (error.code == kStorageCellularForbidden) {
|
||||
__weak __typeof(self) ws = self;
|
||||
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
|
||||
[self enableCellularDownload:YES];
|
||||
[ws updateNode:countryId onCancel:cancel];
|
||||
} andCancelBlock:cancel];
|
||||
} else {
|
||||
[self handleError:error];
|
||||
if (cancel) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteNode:(NSString *)countryId {
|
||||
[self deleteNode:countryId ignoreUnsavedEdits:NO];
|
||||
}
|
||||
|
||||
- (void)deleteNode:(NSString *)countryId ignoreUnsavedEdits:(BOOL)force {
|
||||
NSError *error;
|
||||
[self deleteNode:countryId ignoreUnsavedEdits:force error:&error];
|
||||
if (error) {
|
||||
__weak __typeof(self) ws = self;
|
||||
if (error.code == kStorageCellularForbidden) {
|
||||
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
|
||||
[self enableCellularDownload:YES];
|
||||
[ws deleteNode:countryId];
|
||||
} andCancelBlock:nil];
|
||||
} else if (error.code == kStorageHaveUnsavedEdits) {
|
||||
[[MWMAlertViewController activeAlertController] presentUnsavedEditsAlertWithOkBlock:^ {
|
||||
[ws deleteNode:countryId ignoreUnsavedEdits:YES];
|
||||
}];
|
||||
} else {
|
||||
[self handleError:error];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadNodes:(NSArray<NSString *> *)countryIds onSuccess:(nullable MWMVoidBlock)success {
|
||||
NSError *error;
|
||||
[self downloadNodes:countryIds error:&error];
|
||||
if (error) {
|
||||
if (error.code == kStorageCellularForbidden) {
|
||||
__weak __typeof(self) ws = self;
|
||||
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
|
||||
[self enableCellularDownload:YES];
|
||||
[ws downloadNodes:countryIds onSuccess:success];
|
||||
} andCancelBlock:nil];
|
||||
} else {
|
||||
[self handleError:error];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Add a link
Reference in a new issue