mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +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 ownerId = this.getArguments().getInt(DOMID);
|
||||||
const options = getModalOptions(ownerId);
|
const options = getModalOptions(ownerId);
|
||||||
this.owner = options.owner;
|
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._fullscreen = options.fullscreen;
|
||||||
this._animated = options.animated;
|
this._animated = options.animated;
|
||||||
this._cancelable = options.cancelable;
|
this._cancelable = options.cancelable;
|
||||||
|
@ -264,13 +264,13 @@ export class Frame extends FrameBase {
|
|||||||
!this._currentEntry.fragment.isAdded()) {
|
!this._currentEntry.fragment.isAdded()) {
|
||||||
return;
|
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 = fragmentManager.beginTransaction();
|
||||||
const transaction = manager.beginTransaction();
|
|
||||||
const fragment = this._currentEntry.fragment;
|
|
||||||
const fragmentExitTransition = fragment.getExitTransition();
|
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) {
|
if (fragmentExitTransition && fragmentExitTransition instanceof org.nativescript.widgets.CustomTransition) {
|
||||||
fragmentExitTransition.setResetOnTransitionEnd(true);
|
fragmentExitTransition.setResetOnTransitionEnd(true);
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ function clearEntry(entry: BackstackEntry): void {
|
|||||||
entry.recreated = false;
|
entry.recreated = false;
|
||||||
entry.fragment = null;
|
entry.fragment = null;
|
||||||
const page = entry.resolvedPage;
|
const page = entry.resolvedPage;
|
||||||
if (page._context) {
|
if (page && page._context) {
|
||||||
entry.resolvedPage._tearDownUI(true);
|
entry.resolvedPage._tearDownUI(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1032,6 +1032,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private loadBitmapFromView(view: android.view.View): android.graphics.Bitmap {
|
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
|
// Another way to get view bitmap. Test performance vs setDrawingCacheEnabled
|
||||||
// const width = view.getWidth();
|
// const width = view.getWidth();
|
||||||
// const height = view.getHeight();
|
// const height = view.getHeight();
|
||||||
@ -1041,7 +1047,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
|||||||
// view.draw(canvas);
|
// view.draw(canvas);
|
||||||
|
|
||||||
view.setDrawingCacheEnabled(true);
|
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);
|
view.setDrawingCacheEnabled(false);
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
@ -6,8 +6,6 @@ import {
|
|||||||
export { ios };
|
export { ios };
|
||||||
export * from "./utils-common";
|
export * from "./utils-common";
|
||||||
|
|
||||||
let mainScreenScale;
|
|
||||||
|
|
||||||
export function openFile(filePath: string): boolean {
|
export function openFile(filePath: string): boolean {
|
||||||
try {
|
try {
|
||||||
const appPath = ios.getCurrentAppPath();
|
const appPath = ios.getCurrentAppPath();
|
||||||
@ -47,5 +45,3 @@ export function openUrl(location: string): boolean {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mainScreenScale = UIScreen.mainScreen.scale;
|
|
||||||
|
Reference in New Issue
Block a user