Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<a name="5.0.4"></a>
## [5.0.4](https://github.com/NativeScript/NativeScript/compare/5.0.3...5.0.4) (2018-11-26)


### Bug Fixes

* **android-fragment:** child already has a parent ([#6589](https://github.com/NativeScript/NativeScript/issues/6589)) ([5b9b335](https://github.com/NativeScript/NativeScript/commit/5b9b335))
* **back-navigation:** app freeze on going back in parent frame with states ([#6595](https://github.com/NativeScript/NativeScript/issues/6595)) ([fc1f8c1](https://github.com/NativeScript/NativeScript/commit/fc1f8c1))



<a name="5.0.3"></a>
## [5.0.3](https://github.com/NativeScript/NativeScript/compare/5.0.2...5.0.3) (2018-11-20)

Expand Down
2 changes: 1 addition & 1 deletion tns-core-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tns-core-modules",
"description": "Telerik NativeScript Core Modules",
"version": "5.0.3",
"version": "5.0.4",
"homepage": "https://www.nativescript.org",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion tns-core-modules/ui/frame/frame-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export function goBack(): boolean {
if (parentFrame && parentFrame.canGoBack()) {
parentFrameCanGoBack = true;
} else {
parentFrame = <FrameBase>getAncestor(top, "Frame");
parentFrame = <FrameBase>getAncestor(parentFrame, "Frame");
}
}

Expand Down
36 changes: 18 additions & 18 deletions tns-core-modules/ui/frame/frame.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,24 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
entry.viewSavedState = null;
}

// fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'.
// on app resume in nested frame scenarios with support library version greater than 26.0.0
// HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent
// right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a
// parent while its supposed parent believes it properly removed its children; in order to "force" the child to
// lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass)
const nativeView = page.nativeViewProtected;
if (nativeView != null) {
const parentView = nativeView.getParent();
if (parentView instanceof android.view.ViewGroup) {
if (parentView.getChildCount() === 0) {
parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams());
}

parentView.removeView(nativeView);
}
}

return page.nativeViewProtected;
}

Expand Down Expand Up @@ -873,24 +891,6 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
traceError(`${fragment}.onDestroy: entry has no resolvedPage`);
return null;
}

// fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'.
// on app resume in nested frame scenarios with support library version greater than 26.0.0
// HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent
// right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a
// parent while its supposed parent believes it properly removed its children; in order to "force" the child to
// lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass)
const nativeView = page.nativeViewProtected;
if (nativeView != null) {
const parentView = nativeView.getParent();
if (parentView instanceof android.view.ViewGroup) {
if (parentView.getChildCount() === 0) {
parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams());
}

parentView.removeView(nativeView);
}
}
}

@profile
Expand Down
2 changes: 1 addition & 1 deletion tns-platform-declarations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tns-platform-declarations",
"version": "5.0.3",
"version": "5.0.4",
"description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects",
"main": "",
"scripts": {
Expand Down