| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 58c9905 commit 45c7a80
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,10 +3,10 @@ import { Point, CustomLayoutView as CustomLayoutViewDefinition, dip } from "."; | |||
| 3 | 3 | import { GestureTypes, GestureEventData } from "../../gestures"; | |
| 4 | 4 | // Types. | |
| 5 | 5 | import { | |
| 6 | - Color, EventData, ViewCommon, layout, getAncestor, automationTextProperty, | ||
| 7 | - isEnabledProperty, isUserInteractionEnabledProperty, originXProperty, originYProperty, | ||
| 6 | + ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, | ||
| 7 | + traceEnabled, traceWrite, traceCategories, traceNotifyEvent, | ||
| 8 | 8 | paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, | |
| 9 | - traceEnabled, traceWrite, traceCategories, traceNotifyEvent | ||
| 9 | + Color, EventData | ||
| 10 | 10 | } from "./view-common"; | |
| 11 | 11 | ||
| 12 | 12 | import { | |
@@ -20,7 +20,7 @@ import { | |||
| 20 | 20 | ||
| 21 | 21 | import { Background, ad as androidBackground } from "../../styling/background"; | |
| 22 | 22 | import { profile } from "../../../profiling"; | |
| 23 | - import { Frame, topmost } from "../../frame"; | ||
| 23 | + import { topmost } from "../../frame"; | ||
| 24 | 24 | import { AndroidActivityBackPressedEventData, android as androidApp } from "../../../application"; | |
| 25 | 25 | ||
| 26 | 26 | export * from "./view-common"; | |
@@ -269,24 +269,31 @@ export class View extends ViewCommon { | |||
| 269 | 269 | let manager = this._manager; | |
| 270 | 270 | if (!manager) { | |
| 271 | 271 | let view: View = this; | |
| 272 | + let frameOrTabFound = false; | ||
| 272 | 273 | while (view) { | |
| 274 | + // when interacting with nested fragments instead of using getSupportFragmentManager | ||
| 275 | + // we must always use getChildFragmentManager instead; | ||
| 276 | + // we have three sources of fragments -- Frame fragments, TabViewItem fragments, and | ||
| 277 | + // modal dialog fragments | ||
| 278 | + | ||
| 279 | + // modal -> frame / tabview (frame / tabview use modal CHILD fm) | ||
| 273 | 280 | const dialogFragment = view._dialogFragment; | |
| 274 | 281 | if (dialogFragment) { | |
| 275 | 282 | manager = dialogFragment.getChildFragmentManager(); | |
| 276 | 283 | break; | |
| 277 | 284 | } | |
| 278 | - | ||
| 279 | - if (view instanceof Frame) { | ||
| 280 | - // when interacting with nested fragments instead of using getSupportFragmentManager | ||
| 281 | - // we must always use getChildFragmentManager | ||
| 282 | - const parentFrame: Frame = <Frame>getAncestor(view, Frame); | ||
| 283 | - if (parentFrame) { | ||
| 284 | - const backstackEntry = parentFrame._currentEntry || parentFrame._executingEntry; | ||
| 285 | - if (backstackEntry && backstackEntry.fragment && backstackEntry.fragment.isAdded()) { | ||
| 286 | - manager = backstackEntry.fragment.getChildFragmentManager(); | ||
| 287 | - break; | ||
| 288 | - } | ||
| 285 | + | ||
| 286 | + // - frame1 -> frame2 (frame2 uses frame1 CHILD fm) | ||
| 287 | + // - tabview -> frame1 (frame1 uses tabview item CHILD fm) | ||
| 288 | + // - frame1 -> tabview (tabview uses frame1 CHILD fm) | ||
| 289 | + // - frame1 -> tabview -> frame2 (tabview uses frame1 CHILD fm; frame2 uses tabview item CHILD fm) | ||
| 290 | + if (view.typeName === "Frame" || view.typeName === "TabView") { | ||
| 291 | + if (frameOrTabFound) { | ||
| 292 | + manager = (<any>view)._getChildFragmentManager(); | ||
| 293 | + break; | ||
| 289 | 294 | } | |
| 295 | + | ||
| 296 | + frameOrTabFound = true; | ||
| 290 | 297 | } | |
| 291 | 298 | ||
| 292 | 299 | // the case is needed because _dialogFragment is on View | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -175,6 +175,15 @@ export class Frame extends FrameBase { | |||
| 175 | 175 | } | |
| 176 | 176 | } | |
| 177 | 177 | ||
| 178 | + public _getChildFragmentManager() { | ||
| 179 | + const backstackEntry = this._executingEntry || this._currentEntry; | ||
| 180 | + if (backstackEntry && backstackEntry.fragment && backstackEntry.fragment.isAdded()) { | ||
| 181 | + return backstackEntry.fragment.getChildFragmentManager(); | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + return null; | ||
| 185 | + } | ||
| 186 | + | ||
| 178 | 187 | _onRootViewReset(): void { | |
| 179 | 188 | this.disposeCurrentFragment(); | |
| 180 | 189 | super._onRootViewReset(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -361,6 +361,17 @@ export class TabView extends TabViewBase { | |||
| 361 | 361 | tabs.push(new WeakRef(this)); | |
| 362 | 362 | } | |
| 363 | 363 | ||
| 364 | + public _getChildFragmentManager(): android.support.v4.app.FragmentManager { | ||
| 365 | + if (this._pagerAdapter) { | ||
| 366 | + const fragment: android.support.v4.app.Fragment = (<any>this._pagerAdapter).mCurrentPrimaryItem; | ||
| 367 | + if (fragment && fragment.isAdded()) { | ||
| 368 | + return fragment.getChildFragmentManager(); | ||
| 369 | + } | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + return null; | ||
| 373 | + } | ||
| 374 | + | ||
| 364 | 375 | public onItemsChanged(oldItems: TabViewItem[], newItems: TabViewItem[]): void { | |
| 365 | 376 | super.onItemsChanged(oldItems, newItems); | |
| 366 | 377 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments