Skip to content

Commit

Permalink
fix(android): gesture not being detached correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Apr 11, 2022
1 parent 9d221a0 commit 8dca885
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/gesturehandler/gesturehandler.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export class Manager extends ManagerBase {
return handler as any;
}

findRegistry(view: View) {
findRegistry(view: View): com.swmansion.gesturehandler.GestureHandlerRegistryImpl {
let registry: com.swmansion.gesturehandler.GestureHandlerRegistryImpl;
const page = view.page as PageGestureExtended;
if (page) {
Expand All @@ -548,7 +548,7 @@ export class Manager extends ManagerBase {
}
return registry;
}
attachGestureHandlerToView(handler: Handler<any, any>, view: View) {
attachGestureHandlerToView<T extends com.swmansion.gesturehandler.GestureHandler<any> = com.swmansion.gesturehandler.GestureHandler<any>>(handler: Handler<T, any>, view: View) {
const nHandler = handler.getNative();
if (nHandler) {
const registry = this.findRegistry(view);
Expand All @@ -561,18 +561,18 @@ export class Manager extends ManagerBase {
}
}

detachGestureHandlerFromView(handler: Handler<any, any>, view: View) {
detachGestureHandlerFromView<T extends com.swmansion.gesturehandler.GestureHandler<any> = com.swmansion.gesturehandler.GestureHandler<any>>(handler: Handler<T, any>, view: View) {
const nHandler = handler.getNative();
if (nHandler) {
const registry = this.findRegistry(view);
if (registry) {
registry.dropHandler(handler.getNative());
registry.dropHandler(nHandler.getTag());
}
}
}

viewListeners = new Map<View, Map<number, { init: () => void; dispose: () => void }>>();
attachGestureHandler(handler: Handler<any, any>, view: View) {
attachGestureHandler<T extends com.swmansion.gesturehandler.GestureHandler<any> = com.swmansion.gesturehandler.GestureHandler<any>>(handler: Handler<T, any>, view: View) {
if (view.nativeView) {
this.attachGestureHandlerToView(handler, view);
}
Expand All @@ -590,7 +590,7 @@ export class Manager extends ManagerBase {
dispose: onDispose,
});
}
detachGestureHandler(handler: Handler<any, any>, view: View) {
detachGestureHandler<T extends com.swmansion.gesturehandler.GestureHandler<any> = com.swmansion.gesturehandler.GestureHandler<any>>(handler: Handler<T, any>, view: View) {
if (view) {
const viewListeners = this.viewListeners.get(view);
if (viewListeners) {
Expand Down

0 comments on commit 8dca885

Please sign in to comment.