Fix crash for unsupported device orientation events

Reviewed By: mmmulani

Differential Revision: D5507716

fbshipit-source-id: 061a3060a5ea216028b1fbae81256d17db7f4b2f
This commit is contained in:
Pieter De Baets 2017-07-28 02:57:35 -07:00 committed by Facebook Github Bot
parent 6a4fb5edf2
commit 2444c54654
1 changed files with 10 additions and 3 deletions

View File

@ -206,7 +206,10 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
degrees = @90;
isLandscape = YES;
break;
default:
case UIDeviceOrientationFaceDown:
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationUnknown:
// Unsupported
return nil;
}
return @{
@ -218,11 +221,15 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
- (void)namedOrientationDidChange
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation);
if (!orientationEvent) {
return;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[_bridge.eventDispatcher sendDeviceEventWithName:@"namedOrientationDidChange"
body:deviceOrientationEventBody(deviceOrientation)];
body:orientationEvent];
#pragma clang diagnostic pop
}
#endif