mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix: check is disposed fragment is in the FragmentManager (#8201)
This commit is contained in:
committed by
GitHub
parent
d1858f81b7
commit
4b00376957
@@ -155,6 +155,8 @@ function initializeDialogFragment() {
|
||||
const ownerId = this.getArguments().getInt(DOMID);
|
||||
const options = getModalOptions(ownerId);
|
||||
this.owner = options.owner;
|
||||
// Set owner._dialogFragment to this in case the DialogFragment was recreated after app suspend
|
||||
this.owner._dialogFragment = this;
|
||||
this._fullscreen = options.fullscreen;
|
||||
this._animated = options.animated;
|
||||
this._cancelable = options.cancelable;
|
||||
|
||||
@@ -264,13 +264,13 @@ export class Frame extends FrameBase {
|
||||
!this._currentEntry.fragment.isAdded()) {
|
||||
return;
|
||||
}
|
||||
const fragment: androidx.fragment.app.Fragment = this._currentEntry.fragment;
|
||||
const fragmentManager: androidx.fragment.app.FragmentManager = fragment.getFragmentManager();
|
||||
|
||||
const manager: androidx.fragment.app.FragmentManager = this._getFragmentManager();
|
||||
const transaction = manager.beginTransaction();
|
||||
const fragment = this._currentEntry.fragment;
|
||||
const transaction = fragmentManager.beginTransaction();
|
||||
const fragmentExitTransition = fragment.getExitTransition();
|
||||
|
||||
// Reset animation to its initial state to prevent mirrorered effect when restore current fragment transitions
|
||||
// Reset animation to its initial state to prevent mirrored effect when restore current fragment transitions
|
||||
if (fragmentExitTransition && fragmentExitTransition instanceof org.nativescript.widgets.CustomTransition) {
|
||||
fragmentExitTransition.setResetOnTransitionEnd(true);
|
||||
}
|
||||
@@ -637,7 +637,7 @@ function clearEntry(entry: BackstackEntry): void {
|
||||
entry.recreated = false;
|
||||
entry.fragment = null;
|
||||
const page = entry.resolvedPage;
|
||||
if (page._context) {
|
||||
if (page && page._context) {
|
||||
entry.resolvedPage._tearDownUI(true);
|
||||
}
|
||||
}
|
||||
@@ -1032,6 +1032,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
}
|
||||
|
||||
private loadBitmapFromView(view: android.view.View): android.graphics.Bitmap {
|
||||
// Don't try to creat bitmaps with no dimensions as this causes a crash
|
||||
// This might happen when showing and closing dialogs fast.
|
||||
if (!(view && view.getWidth() > 0 && view.getHeight() > 0)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Another way to get view bitmap. Test performance vs setDrawingCacheEnabled
|
||||
// const width = view.getWidth();
|
||||
// const height = view.getHeight();
|
||||
@@ -1041,7 +1047,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
// view.draw(canvas);
|
||||
|
||||
view.setDrawingCacheEnabled(true);
|
||||
const bitmap = android.graphics.Bitmap.createBitmap(view.getDrawingCache());
|
||||
const drawCache = view.getDrawingCache();
|
||||
const bitmap = android.graphics.Bitmap.createBitmap(drawCache);
|
||||
view.setDrawingCacheEnabled(false);
|
||||
|
||||
return bitmap;
|
||||
|
||||
Reference in New Issue
Block a user