CB-10562 hide() not working in latest splashscreen plug in 3.1.0 in iOS

This commit is contained in:
daserge 2016-03-10 15:38:32 +03:00
parent 9ca15db91a
commit 41d9ae94ff
2 changed files with 26 additions and 15 deletions

View File

@ -36,6 +36,7 @@ typedef struct {
UIImageView* _imageView; UIImageView* _imageView;
NSString* _curImageName; NSString* _curImageName;
BOOL _visible; BOOL _visible;
BOOL _destroyed;
} }
- (void)show:(CDVInvokedUrlCommand*)command; - (void)show:(CDVInvokedUrlCommand*)command;

View File

@ -41,7 +41,7 @@
- (void)hide:(CDVInvokedUrlCommand*)command - (void)hide:(CDVInvokedUrlCommand*)command
{ {
[self setVisible:NO]; [self setVisible:NO andForce:YES];
} }
- (void)pageDidLoad - (void)pageDidLoad
@ -120,6 +120,7 @@
[parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil]; [parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil];
[self updateImage]; [self updateImage];
_destroyed = NO;
} }
- (void)hideViews - (void)hideViews
@ -130,6 +131,7 @@
- (void)destroyViews - (void)destroyViews
{ {
_destroyed = YES;
[(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]]; [(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]];
[_imageView removeFromSuperview]; [_imageView removeFromSuperview];
@ -376,7 +378,12 @@
- (void)setVisible:(BOOL)visible - (void)setVisible:(BOOL)visible
{ {
if (visible != _visible) [self setVisible:visible andForce:NO];
}
- (void)setVisible:(BOOL)visible andForce:(BOOL)force
{
if (visible != _visible || force)
{ {
_visible = visible; _visible = visible;
@ -433,13 +440,15 @@
__weak __typeof(self) weakSelf = self; __weak __typeof(self) weakSelf = self;
float effectiveSplashDuration; float effectiveSplashDuration;
if (!autoHideSplashScreen) { // [CB-10562] AutoHideSplashScreen may be "true" but we should still be able to hide the splashscreen manually.
if (!autoHideSplashScreen || force) {
effectiveSplashDuration = (fadeDuration) / 1000; effectiveSplashDuration = (fadeDuration) / 1000;
} else { } else {
effectiveSplashDuration = (splashDuration - fadeDuration) / 1000; effectiveSplashDuration = (splashDuration - fadeDuration) / 1000;
} }
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) {
if (!_destroyed) {
[UIView transitionWithView:self.viewController.view [UIView transitionWithView:self.viewController.view
duration:(fadeDuration / 1000) duration:(fadeDuration / 1000)
options:UIViewAnimationOptionTransitionNone options:UIViewAnimationOptionTransitionNone
@ -447,12 +456,13 @@
[weakSelf hideViews]; [weakSelf hideViews];
} }
completion:^(BOOL finished) { completion:^(BOOL finished) {
if (finished) { if (finished && !_destroyed) {
[weakSelf destroyViews]; [weakSelf destroyViews];
// TODO: It might also be nice to have a js event happen here -jm // TODO: It might also be nice to have a js event happen here -jm
} }
} }
]; ];
}
}))); })));
} }
} }