diff options
author | Ilya Grechuhin <i.grechuhin@mapswithme.com> | 2015-06-24 16:13:24 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:52:53 +0300 |
commit | 090ba97c566b1fc99cc610a19eec832e5d69dbbf (patch) | |
tree | 12b29fac86da12c556417b5ddd1a7a773742d83c /iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton | |
parent | 965f1f038181a6f5bae6e441cff4357f0e4dde09 (diff) |
[ios] Workaround to fix location button animation crash.
Diffstat (limited to 'iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton')
-rw-r--r-- | iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm index 1c5a7b1dd4..3d5b687895 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm @@ -10,6 +10,8 @@ #import "MWMMapViewControlsCommon.h" #import "UIKitCategories.h" +#import "3party/Alohalytics/src/alohalytics_objc.h" + @interface MWMLocationButtonView() @property (nonatomic) CGRect defaultBounds; @@ -86,6 +88,7 @@ - (void)changeButtonFromState:(location::State::Mode)beginState toState:(location::State::Mode)endState { + NSAssert1(beginState != endState, @"MWMLocationButtonView::(changeButtonFromState:toState:) states must be different! state:%@", @(beginState)); [self setImageNamed:endState]; static NSDictionary const * const stateMap = @{@(location::State::UnknownPosition).stringValue : @"noposition", @(location::State::PendingPosition).stringValue : @"pending", @@ -96,7 +99,22 @@ static NSUInteger const animationImagesCount = 6; NSMutableArray * const animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; for (NSUInteger i = 0; i < animationImagesCount; ++i) - animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@", changeAnimation, @(i+1)]]; + { + NSString * imageName = [NSString stringWithFormat:@"%@%@", changeAnimation, @(i+1)]; + UIImage * image = [UIImage imageNamed:imageName]; + NSAssert1(image, @"MWMLocationButtonView::(changeButtonFromState:toState:) image is nil! imageName: %@", imageName); + if (image) + { + animationImages[i] = image; + } + else + { + // TODO(grechuhin): Temporary, check Alohalytics logs and clean implementation. + [Alohalytics logEvent:@"MWMLocationButtonViewChangeButtonFromStateToStateInvalidImageName" withValue:imageName]; + [self changeStateFinish]; + return; + } + } [self setAnimation:animationImages once:YES]; [self changeStateFinish]; } |