| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,9 @@ import { profile } from "../../profiling"; | |||
| 22 | 22 | // TODO: Remove this and get it from global to decouple builder for angular | |
| 23 | 23 | import { createViewFromEntry } from "../builder"; | |
| 24 | 24 | ||
| 25 | + import { device } from "../../platform"; | ||
| 26 | + import lazy from "../../utils/lazy"; | ||
| 27 | + | ||
| 25 | 28 | export * from "./frame-common"; | |
| 26 | 29 | ||
| 27 | 30 | const INTENT_EXTRA = "com.tns.activity"; | |
@@ -32,6 +35,8 @@ const CALLBACKS = "_callbacks"; | |||
| 32 | 35 | const ownerSymbol = Symbol("_owner"); | |
| 33 | 36 | const activityRootViewsMap = new Map<number, WeakRef<View>>(); | |
| 34 | 37 | ||
| 38 | + const sdkVersion = lazy(() => parseInt(device.sdkVersion)); | ||
| 39 | + | ||
| 35 | 40 | let navDepth = -1; | |
| 36 | 41 | let fragmentId = -1; | |
| 37 | 42 | export let moduleLoaded: boolean; | |
@@ -186,13 +191,28 @@ export class Frame extends FrameBase { | |||
| 186 | 191 | super.onUnloaded(); | |
| 187 | 192 | } | |
| 188 | 193 | ||
| 189 | - private disposeCurrentFragment(){ | ||
| 190 | - if (this._currentEntry && this._currentEntry.fragment) { | ||
| 191 | - const manager: android.app.FragmentManager = this._getFragmentManager(); | ||
| 192 | - const transaction = manager.beginTransaction(); | ||
| 194 | + private disposeCurrentFragment(): void { | ||
| 195 | + if (!this._currentEntry || !this._currentEntry.fragment) { | ||
| 196 | + return; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + const manager: android.app.FragmentManager = this._getFragmentManager(); | ||
| 200 | + const transaction = manager.beginTransaction(); | ||
| 201 | + const androidSdkVersion = sdkVersion(); | ||
| 202 | + | ||
| 203 | + if (androidSdkVersion !== 21 && androidSdkVersion !== 22) { | ||
| 193 | 204 | transaction.remove(this._currentEntry.fragment); | |
| 194 | - transaction.commitAllowingStateLoss(); | ||
| 205 | + } else { | ||
| 206 | + // https://github.com/NativeScript/NativeScript/issues/5674 | ||
| 207 | + // HACK: Add and remove dummy fragment to workaround a Lollipop issue | ||
| 208 | + // 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 | ||
| 209 | + const dummyFragmentTag = "dummy"; | ||
| 210 | + const dummyFragment = this.createFragment(<BackstackEntry>{}, dummyFragmentTag); | ||
| 211 | + transaction.replace(this.containerViewId, dummyFragment, dummyFragmentTag); | ||
| 212 | + transaction.remove(dummyFragment); | ||
| 195 | 213 | } | |
| 214 | + | ||
| 215 | + transaction.commitAllowingStateLoss(); | ||
| 196 | 216 | } | |
| 197 | 217 | ||
| 198 | 218 | private createFragment(backstackEntry: BackstackEntry, fragmentTag: string): android.app.Fragment { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments