Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import javax.annotation.Nullable;

public class OrientationModule extends ReactContextBaseJavaModule implements LifecycleEventListener{
public class OrientationModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
final BroadcastReceiver receiver;

public OrientationModule(ReactApplicationContext reactContext) {
Expand All @@ -44,8 +44,8 @@ public void onReceive(Context context, Intent intent) {
params.putString("orientation", orientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("orientationDidChange", params);
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("orientationDidChange", params);
}
}
};
Expand Down Expand Up @@ -116,7 +116,9 @@ public void unlockAllOrientations() {
}

@Override
public @Nullable Map<String, Object> getConstants() {
public
@Nullable
Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>();
int orientationInt = getReactApplicationContext().getResources().getConfiguration().orientation;

Expand Down Expand Up @@ -145,32 +147,25 @@ private String getOrientationString(int orientation) {
@Override
public void onHostResume() {
final Activity activity = getCurrentActivity();

assert activity != null;
if (activity == null) {
FLog.e(ReactConstants.TAG, "no activity to register receiver");
return;
}
activity.registerReceiver(receiver, new IntentFilter("onConfigurationChanged"));
}

@Override
public void onHostPause() {
final Activity activity = getCurrentActivity();
if (activity == null) return;
try
{
try {
activity.unregisterReceiver(receiver);
}
catch (java.lang.IllegalArgumentException e) {
} catch (java.lang.IllegalArgumentException e) {
FLog.e(ReactConstants.TAG, "receiver already unregistered", e);
}
}

@Override
public void onHostDestroy() {
final Activity activity = getCurrentActivity();
if (activity == null) return;
try
{
activity.unregisterReceiver(receiver);
}
catch (java.lang.IllegalArgumentException e) {
FLog.e(ReactConstants.TAG, "receiver already unregistered", e);
}}
}
}
6 changes: 6 additions & 0 deletions iOS/RCTOrientation/Orientation.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
#elif __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#elif __has_include("React/RCTBridgeModule.h")
#import "React/RCTBridgeModule.h" // Required when used as a Pod in a Swift project
#endif

@interface Orientation : NSObject <RCTBridgeModule>
+ (void)setOrientation: (UIInterfaceOrientationMask)orientation;
Expand Down
7 changes: 7 additions & 0 deletions iOS/RCTOrientation/Orientation.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
//

#import "Orientation.h"

#if __has_include(<React/RCTEventDispatcher.h>)
#import <React/RCTEventDispatcher.h>
#elif __has_include("RCTEventDispatcher.h")
#import "RCTEventDispatcher.h"
#elif __has_include("React/RCTEventDispatcher.h")
#import "React/RCTEventDispatcher.h" // Required when used as a Pod in a Swift project
#endif

@implementation Orientation
@synthesize bridge = _bridge;
Expand Down