FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(Android): a crash on application restart after livesync changes (… · NativeScript/NativeScript@1f1d722 · GitHub

Commit 1f1d722

Browse files
authored andcommitted
fix(Android): a crash on application restart after livesync changes (#6756)
``` An uncaught Exception occurred on "main" thread. com.tns.NativeScriptException: Calling js method run failed TypeError: Cannot read property 'getRootView' of undefined File: file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/frame/frame.js, line: 56, column:29 ```
1 parent 3a8c3fc commit 1f1d722

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

‎tns-core-modules/ui/frame/frame.android.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ function getAttachListener(): android.view.View.OnAttachStateChangeListener {
8585
export function reloadPage(): void {
8686
const activity = application.android.foregroundActivity;
8787
const callbacks: AndroidActivityCallbacks = activity[CALLBACKS];
88-
const rootView: View = callbacks.getRootView();
88+
if (callbacks) {
89+
const rootView: View = callbacks.getRootView();
8990

90-
if (!rootView || !rootView._onLivesync()) {
91-
callbacks.resetActivityContent(activity);
91+
if (!rootView || !rootView._onLivesync()) {
92+
callbacks.resetActivityContent(activity);
93+
}
94+
} else {
95+
traceError(`${activity}[CALLBACKS] is null or undefined`);
9296
}
9397
}
9498

@@ -469,19 +473,19 @@ export class Frame extends FrameBase {
469473
switch (this.actionBarVisibility) {
470474
case "never":
471475
return false;
472-
476+
473477
case "always":
474478
return true;
475-
479+
476480
default:
477481
if (page.actionBarHidden !== undefined) {
478482
return !page.actionBarHidden;
479483
}
480-
484+
481485
if (this._android && this._android.showActionBar !== undefined) {
482486
return this._android.showActionBar;
483487
}
484-
488+
485489
return true;
486490
}
487491
}
@@ -530,15 +534,15 @@ function restoreAnimatorState(entry: BackstackEntry, snapshot: AnimatorState): v
530534
if (snapshot.enterAnimator) {
531535
expandedEntry.enterAnimator = snapshot.enterAnimator;
532536
}
533-
537+
534538
if (snapshot.exitAnimator) {
535539
expandedEntry.exitAnimator = snapshot.exitAnimator;
536540
}
537541

538542
if (snapshot.popEnterAnimator) {
539543
expandedEntry.popEnterAnimator = snapshot.popEnterAnimator;
540544
}
541-
545+
542546
if (snapshot.popExitAnimator) {
543547
expandedEntry.popExitAnimator = snapshot.popExitAnimator;
544548
}
@@ -858,7 +862,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
858862
// parent while its supposed parent believes it properly removed its children; in order to "force" the child to
859863
// lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass)
860864
const nativeView = page.nativeViewProtected;
861-
if (nativeView != null) {
865+
if (nativeView != null) {
862866
const parentView = nativeView.getParent();
863867
if (parentView instanceof android.view.ViewGroup) {
864868
if (parentView.getChildCount() === 0) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL