@@ -937,18 +937,21 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
937
937
938
938
@profile
939
939
public onDestroyView ( fragment : org . nativescript . widgets . FragmentBase , superFunc : Function ) : void {
940
- if ( traceEnabled ( ) ) {
941
- traceWrite ( `${ fragment } .onDestroyView()` , traceCategories . NativeLifecycle ) ;
942
- }
940
+ try {
941
+ if ( traceEnabled ( ) ) {
942
+ traceWrite ( `${ fragment } .onDestroyView()` , traceCategories . NativeLifecycle ) ;
943
+ }
943
944
944
- const hasRemovingParent = fragment . getRemovingParentFragment ( ) ;
945
+ const hasRemovingParent = fragment . getRemovingParentFragment ( ) ;
945
946
946
- if ( hasRemovingParent ) {
947
- const bitmapDrawable = new android . graphics . drawable . BitmapDrawable ( application . android . context . getResources ( ) , this . backgroundBitmap ) ;
948
- this . frame . nativeViewProtected . setBackgroundDrawable ( bitmapDrawable ) ;
949
- this . backgroundBitmap = null ;
947
+ if ( hasRemovingParent ) {
948
+ const bitmapDrawable = new android . graphics . drawable . BitmapDrawable ( application . android . context . getResources ( ) , this . backgroundBitmap ) ;
949
+ this . frame . nativeViewProtected . setBackgroundDrawable ( bitmapDrawable ) ;
950
+ this . backgroundBitmap = null ;
951
+ }
952
+ } finally {
953
+ superFunc . call ( fragment ) ;
950
954
}
951
- superFunc . call ( fragment ) ;
952
955
}
953
956
954
957
@profile
@@ -982,14 +985,17 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
982
985
983
986
@profile
984
987
public onPause ( fragment : org . nativescript . widgets . FragmentBase , superFunc : Function ) : void {
985
- // Get view as bitmap and set it as background. This is workaround for the disapearing nested fragments.
986
- // TODO: Consider removing it when update to androidx.fragment:1.2.0
987
- const hasRemovingParent = fragment . getRemovingParentFragment ( ) ;
988
+ try {
989
+ // Get view as bitmap and set it as background. This is workaround for the disapearing nested fragments.
990
+ // TODO: Consider removing it when update to androidx.fragment:1.2.0
991
+ const hasRemovingParent = fragment . getRemovingParentFragment ( ) ;
988
992
989
- if ( hasRemovingParent ) {
990
- this . backgroundBitmap = this . loadBitmapFromView ( this . frame . nativeViewProtected ) ;
993
+ if ( hasRemovingParent ) {
994
+ this . backgroundBitmap = this . loadBitmapFromView ( this . frame . nativeViewProtected ) ;
995
+ }
996
+ } finally {
997
+ superFunc . call ( fragment ) ;
991
998
}
992
- superFunc . call ( fragment ) ;
993
999
}
994
1000
995
1001
@profile
@@ -1154,19 +1160,21 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
1154
1160
1155
1161
@profile
1156
1162
public onDestroy ( activity : any , superFunc : Function ) : void {
1157
- if ( traceEnabled ( ) ) {
1158
- traceWrite ( "NativeScriptActivity.onDestroy();" , traceCategories . NativeLifecycle ) ;
1159
- }
1160
-
1161
- const rootView = this . _rootView ;
1162
- if ( rootView ) {
1163
- rootView . _tearDownUI ( true ) ;
1164
- }
1163
+ try {
1164
+ if ( traceEnabled ( ) ) {
1165
+ traceWrite ( "NativeScriptActivity.onDestroy();" , traceCategories . NativeLifecycle ) ;
1166
+ }
1165
1167
1166
- const exitArgs = { eventName : application . exitEvent , object : application . android , android : activity } ;
1167
- application . notify ( exitArgs ) ;
1168
+ const rootView = this . _rootView ;
1169
+ if ( rootView ) {
1170
+ rootView . _tearDownUI ( true ) ;
1171
+ }
1168
1172
1169
- superFunc . call ( activity ) ;
1173
+ const exitArgs = { eventName : application . exitEvent , object : application . android , android : activity } ;
1174
+ application . notify ( exitArgs ) ;
1175
+ } finally {
1176
+ superFunc . call ( activity ) ;
1177
+ }
1170
1178
}
1171
1179
1172
1180
@profile
0 commit comments