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

fix: set/unset touchListener.owner onLoaded/onUnloaded (#6922) · NativeScript/NativeScript@f056167 · GitHub

Commit f056167

Browse files
authored andcommitted
fix: set/unset touchListener.owner onLoaded/onUnloaded (#6922)
1 parent 0482460 commit f056167

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎tns-core-modules/ui/core/view/view.android.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ function initializeTouchListener(): void {
5757

5858
@Interfaces([android.view.View.OnTouchListener])
5959
class TouchListenerImpl extends java.lang.Object implements android.view.View.OnTouchListener {
60-
constructor(private owner: View) {
60+
private owner: WeakRef<View>;
61+
constructor(owner: View) {
6162
super();
63+
this.owner = new WeakRef(owner);
64+
6265
return global.__native(this);
6366
}
6467

6568
onTouch(view: android.view.View, event: android.view.MotionEvent): boolean {
66-
const owner = this.owner;
69+
const owner = this.owner.get();
70+
if (!owner) {
71+
return;
72+
}
6773
owner.handleGestureTouch(event);
6874

6975
let nativeView = owner.nativeViewProtected;
@@ -211,7 +217,7 @@ function initializeDialogFragment() {
211217
const owner = this.owner;
212218

213219
if (owner) {
214-
// Android calls onDestroy before onDismiss.
220+
// Android calls onDestroy before onDismiss.
215221
// Make sure we unload first and then call _tearDownUI.
216222
if (owner.isLoaded) {
217223
owner.callUnloaded();
@@ -298,7 +304,7 @@ export class View extends ViewCommon {
298304
let view: View = this;
299305
let frameOrTabViewItemFound = false;
300306
while (view) {
301-
// when interacting with nested fragments instead of using getSupportFragmentManager
307+
// when interacting with nested fragments instead of using getSupportFragmentManager
302308
// we must always use getChildFragmentManager instead;
303309
// we have three sources of fragments -- Frame fragments, TabViewItem fragments, and
304310
// modal dialog fragments
@@ -1026,4 +1032,4 @@ createNativePercentLengthProperty({
10261032
createNativePercentLengthProperty({
10271033
setter: "_setMinHeightNative",
10281034
get setPixels() { return org.nativescript.widgets.ViewHelper.setMinHeight }
1029-
});
1035+
});

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL