| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -834,6 +834,24 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { | |||
| 834 | 834 | entry.viewSavedState = null; | |
| 835 | 835 | } | |
| 836 | 836 | ||
| 837 | + // fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'. | ||
| 838 | + // on app resume in nested frame scenarios with support library version greater than 26.0.0 | ||
| 839 | + // HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent | ||
| 840 | + // right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a | ||
| 841 | + // parent while its supposed parent believes it properly removed its children; in order to "force" the child to | ||
| 842 | + // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass) | ||
| 843 | + const nativeView = page.nativeViewProtected; | ||
| 844 | + if (nativeView != null) { | ||
| 845 | + const parentView = nativeView.getParent(); | ||
| 846 | + if (parentView instanceof android.view.ViewGroup) { | ||
| 847 | + if (parentView.getChildCount() === 0) { | ||
| 848 | + parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams()); | ||
| 849 | + } | ||
| 850 | + | ||
| 851 | + parentView.removeView(nativeView); | ||
| 852 | + } | ||
| 853 | + } | ||
| 854 | + | ||
| 837 | 855 | return page.nativeViewProtected; | |
| 838 | 856 | } | |
| 839 | 857 | ||
@@ -873,24 +891,6 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { | |||
| 873 | 891 | traceError(`${fragment}.onDestroy: entry has no resolvedPage`); | |
| 874 | 892 | return null; | |
| 875 | 893 | } | |
| 876 | - | ||
| 877 | - // fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'. | ||
| 878 | - // on app resume in nested frame scenarios with support library version greater than 26.0.0 | ||
| 879 | - // HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent | ||
| 880 | - // right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a | ||
| 881 | - // parent while its supposed parent believes it properly removed its children; in order to "force" the child to | ||
| 882 | - // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass) | ||
| 883 | - const nativeView = page.nativeViewProtected; | ||
| 884 | - if (nativeView != null) { | ||
| 885 | - const parentView = nativeView.getParent(); | ||
| 886 | - if (parentView instanceof android.view.ViewGroup) { | ||
| 887 | - if (parentView.getChildCount() === 0) { | ||
| 888 | - parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams()); | ||
| 889 | - } | ||
| 890 | - | ||
| 891 | - parentView.removeView(nativeView); | ||
| 892 | - } | ||
| 893 | - } | ||
| 894 | 894 | } | |
| 895 | 895 | ||
| 896 | 896 | @profile | |
| Back | FazBrowse Home | New Git URL |
0 commit comments