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
2 changes: 2 additions & 0 deletions nativescript-core/ui/core/view/view.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 13 additions & 6 deletions nativescript-core/ui/frame/frame.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions nativescript-core/utils/utils.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
export { ios };
export * from "./utils-common";

let mainScreenScale;

export function openFile(filePath: string): boolean {
try {
const appPath = ios.getCurrentAppPath();
Expand Down Expand Up @@ -47,5 +45,3 @@ export function openUrl(location: string): boolean {

return false;
}

mainScreenScale = UIScreen.mainScreen.scale;