Skip to content

Commit

Permalink
fix: set/unset touchListener.owner onLoaded/onUnloaded (#6922)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-abs authored and manoldonev committed Mar 15, 2019
1 parent 0482460 commit f056167
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tns-core-modules/ui/core/view/view.android.ts
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 }
});
});

0 comments on commit f056167

Please sign in to comment.