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

fix(6913): set/unset touchListener.owner onLoaded/onUnloaded by m-abs · Pull Request #6922 · NativeScript/NativeScript · GitHub

16 changes: 11 additions & 5 deletions tns-core-modules/ui/core/view/view.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 @@ -57,13 +57,19 @@ function initializeTouchListener(): void {

@Interfaces([android.view.View.OnTouchListener])
class TouchListenerImpl extends java.lang.Object implements android.view.View.OnTouchListener {
constructor(private owner: View) {
private owner: WeakRef<View>;
constructor(owner: View) {
super();
this.owner = new WeakRef(owner);

return global.__native(this);
}

onTouch(view: android.view.View, event: android.view.MotionEvent): boolean {
const owner = this.owner;
const owner = this.owner.get();
if (!owner) {
return;
}
owner.handleGestureTouch(event);

let nativeView = owner.nativeViewProtected;
Expand Down Expand Up @@ -211,7 +217,7 @@ function initializeDialogFragment() {
const owner = this.owner;

if (owner) {
// Android calls onDestroy before onDismiss.
// Android calls onDestroy before onDismiss.
// Make sure we unload first and then call _tearDownUI.
if (owner.isLoaded) {
owner.callUnloaded();
Expand Down Expand Up @@ -298,7 +304,7 @@ export class View extends ViewCommon {
let view: View = this;
let frameOrTabViewItemFound = false;
while (view) {
// when interacting with nested fragments instead of using getSupportFragmentManager
// when interacting with nested fragments instead of using getSupportFragmentManager
// we must always use getChildFragmentManager instead;
// we have three sources of fragments -- Frame fragments, TabViewItem fragments, and
// modal dialog fragments
Expand Down Expand Up @@ -1026,4 +1032,4 @@ createNativePercentLengthProperty({
createNativePercentLengthProperty({
setter: "_setMinHeightNative",
get setPixels() { return org.nativescript.widgets.ViewHelper.setMinHeight }
});
});

Back | FazBrowse Home | New Git URL