FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[DO NOT MERGE] Mdonev/lollipop fragment transition fix by manoldonev · Pull Request #5712 · NativeScript/NativeScript · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
30 changes: 25 additions & 5 deletions tns-core-modules/ui/frame/frame.android.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import { profile } from "../../profiling";
// TODO: Remove this and get it from global to decouple builder for angular
import { createViewFromEntry } from "../builder";

import { device } from "../../platform";
import lazy from "../../utils/lazy";

export * from "./frame-common";

const INTENT_EXTRA = "com.tns.activity";
Expand All @@ -32,6 +35,8 @@ const CALLBACKS = "_callbacks";
const ownerSymbol = Symbol("_owner");
const activityRootViewsMap = new Map<number, WeakRef<View>>();

const sdkVersion = lazy(() => parseInt(device.sdkVersion));

let navDepth = -1;
let fragmentId = -1;
export let moduleLoaded: boolean;
Expand Down Expand Up @@ -186,13 +191,28 @@ export class Frame extends FrameBase {
super.onUnloaded();
}

private disposeCurrentFragment(){
if (this._currentEntry && this._currentEntry.fragment) {
const manager: android.app.FragmentManager = this._getFragmentManager();
const transaction = manager.beginTransaction();
private disposeCurrentFragment(): void {
if (!this._currentEntry || !this._currentEntry.fragment) {
return;
}

const manager: android.app.FragmentManager = this._getFragmentManager();
const transaction = manager.beginTransaction();
const androidSdkVersion = sdkVersion();

if (androidSdkVersion !== 21 && androidSdkVersion !== 22) {
transaction.remove(this._currentEntry.fragment);
transaction.commitAllowingStateLoss();
} else {
// https://github.com/NativeScript/NativeScript/issues/5674
// HACK: Add and remove dummy fragment to workaround a Lollipop issue
// with inFragment passed as null when adding transition targets: https://android.googlesource.com/platform/frameworks/base.git/+/lollipop-release/core/java/android/app/BackStackRecord.java#1127
const dummyFragmentTag = "dummy";
const dummyFragment = this.createFragment(<BackstackEntry>{}, dummyFragmentTag);
transaction.replace(this.containerViewId, dummyFragment, dummyFragmentTag);
transaction.remove(dummyFragment);
}

transaction.commitAllowingStateLoss();
}

private createFragment(backstackEntry: BackstackEntry, fragmentTag: string): android.app.Fragment {
Expand Down

Back | FazBrowse Home | New Git URL