diff options
author | Ilya Grechuhin <i.grechuhin@mapswithme.com> | 2015-08-13 15:08:49 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:14 +0300 |
commit | 8d2b61e4f49f98c74432e1e6e334f3c0082cf401 (patch) | |
tree | f0fcc9d8e6a6db4a665cdcafe918bc8d9fcafe36 /iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton | |
parent | c5b52c35a4371a3a7384765d134e61c9da9fe5fd (diff) |
[ios] Revert 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 | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm index 3d5b687895..cab2965328 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm @@ -10,8 +10,6 @@ #import "MWMMapViewControlsCommon.h" #import "UIKitCategories.h" -#import "3party/Alohalytics/src/alohalytics_objc.h" - @interface MWMLocationButtonView() @property (nonatomic) CGRect defaultBounds; @@ -54,21 +52,22 @@ [self setPendingPositionAnimation]; else { - static NSDictionary const * const stateMap = @{@(location::State::UnknownPosition).stringValue : @"btn_white_unknow_position", - @(location::State::NotFollow).stringValue : @"btn_white_target_off_1", - @(location::State::Follow).stringValue : @"btn_white_target_on", - @(location::State::RotateAndFollow).stringValue : @"btn_white_direction"}; + static NSDictionary * stateMap = @{@(location::State::UnknownPosition).stringValue : @"btn_white_unknow_position", + @(location::State::NotFollow).stringValue : @"btn_white_target_off_1", + @(location::State::Follow).stringValue : @"btn_white_target_on", + @(location::State::RotateAndFollow).stringValue : @"btn_white_direction"}; [self.imageView stopAnimating]; NSString * const imageName = stateMap[@(state).stringValue]; self.highlighted = NO; [self setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal]; - [self setImage:[UIImage imageNamed:[imageName stringByAppendingString:@"_pressed"]] forState:UIControlStateHighlighted]; + [self setImage:[UIImage imageNamed:[imageName stringByAppendingString:@"_pressed"]] + forState:UIControlStateHighlighted]; } } - (void)setAnimation:(NSArray *)animationImages once:(BOOL)once { - UIImageView const * const animationIV = self.imageView; + UIImageView * animationIV = self.imageView; animationIV.animationImages = animationImages; animationIV.animationDuration = framesDuration(animationImages.count); animationIV.animationRepeatCount = once ? 1 : 0; @@ -77,10 +76,10 @@ - (void)setPendingPositionAnimation { - NSString const * const imageName = @"btn_white_loading_"; + NSString * imageName = @"btn_white_loading_"; [self setImage:[UIImage imageNamed:[imageName stringByAppendingString:@"1"]] forState:UIControlStateNormal]; - static NSUInteger const animationImagesCount = 18; - NSMutableArray * const animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; + NSUInteger const animationImagesCount = 18; + NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; for (NSUInteger i = 0; i < animationImagesCount; ++i) animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@", imageName, @(i+1)]]; [self setAnimation:animationImages once:NO]; @@ -88,33 +87,18 @@ - (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", - @(location::State::NotFollow).stringValue : @"notfollow", - @(location::State::Follow).stringValue : @"follow", - @(location::State::RotateAndFollow).stringValue : @"followandrotate"}; - NSString const * const changeAnimation = [NSString stringWithFormat:@"%@_to_%@_", stateMap[@(beginState).stringValue], stateMap[@(endState).stringValue]]; - static NSUInteger const animationImagesCount = 6; - NSMutableArray * const animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; + static NSDictionary * stateMap = @{@(location::State::UnknownPosition).stringValue : @"noposition", + @(location::State::PendingPosition).stringValue : @"pending", + @(location::State::NotFollow).stringValue : @"notfollow", + @(location::State::Follow).stringValue : @"follow", + @(location::State::RotateAndFollow).stringValue : @"followandrotate"}; + NSString * changeAnimation = [NSString stringWithFormat:@"%@_to_%@_", + stateMap[@(beginState).stringValue], stateMap[@(endState).stringValue]]; + NSUInteger const animationImagesCount = 6; + NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; for (NSUInteger i = 0; i < animationImagesCount; ++i) - { - 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; - } - } + animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@", changeAnimation, @(i+1)]]; [self setAnimation:animationImages once:YES]; [self changeStateFinish]; } |