Skip to content

Commit e152e38

Browse files
committed
fix-next(android): check for root view on configuration changed
A Playground and Preview apps scenario.
1 parent 430c616 commit e152e38

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tns-core-modules/application/application.android.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,14 @@ function initComponentCallbacks() {
413413
}),
414414

415415
onConfigurationChanged: profile("onConfigurationChanged", function (newConfiguration: android.content.res.Configuration) {
416+
const rootView = getRootView();
416417
const newOrientation = getOrientationValue(newConfiguration);
417418

418419
if (androidApp.orientation !== newOrientation) {
419420
androidApp.orientation = newOrientation;
420-
orientationChanged(getRootView(), newOrientation);
421+
if (rootView) {
422+
orientationChanged(rootView, newOrientation);
423+
}
421424

422425
notify(<OrientationChangedEventData>{
423426
eventName: orientationChangedEvent,
@@ -433,7 +436,9 @@ function initComponentCallbacks() {
433436

434437
if (androidApp.systemAppearance !== newSystemAppearance) {
435438
androidApp.systemAppearance = newSystemAppearance;
436-
systemAppearanceChanged(getRootView(), newSystemAppearance);
439+
if (rootView) {
440+
systemAppearanceChanged(rootView, newSystemAppearance);
441+
}
437442

438443
notify(<SystemAppearanceChangedEventData>{
439444
eventName: systemAppearanceChangedEvent,

0 commit comments

Comments
 (0)