From 5065e60b56a25376959d3cef46de1d58191da519 Mon Sep 17 00:00:00 2001 From: Osei Fortune Date: Wed, 24 Dec 2025 02:51:03 -0400 Subject: [PATCH] fix(rive): android events --- packages/rive/index.android.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/rive/index.android.ts b/packages/rive/index.android.ts index 4947fb1..b96285e 100644 --- a/packages/rive/index.android.ts +++ b/packages/rive/index.android.ts @@ -23,26 +23,38 @@ class Listener extends java.lang.Object implements app.rive.runtime.kotlin.contr } notifyPlay(animation: app.rive.runtime.kotlin.core.PlayableInstance): void { - // this.owner.get()?.events.notifyEvent(RiveEvents.onPlayEvent, { name: animation.getName() }); + const owner = this.owner.get(); + if (owner) { + owner.events.notifyEvent(RiveEvents.onPlayEvent, { name: animation.getName() }); + } } notifyStop(animation: app.rive.runtime.kotlin.core.PlayableInstance): void { - // this.owner.get()?.events.notifyEvent(RiveEvents.onStopEvent, { name: animation.getName() }); + const owner = this.owner.get(); + if (owner) { + owner.events.notifyEvent(RiveEvents.onStopEvent, { name: animation.getName() }); + } } notifyPause(animation: app.rive.runtime.kotlin.core.PlayableInstance): void { - // this.owner.get()?.events.notifyEvent(RiveEvents.onPauseEvent, { name: animation.getName() }); + const owner = this.owner.get(); + if (owner) { + owner.events.notifyEvent(RiveEvents.onPauseEvent, { name: animation.getName() }); + } } notifyLoop(animation: app.rive.runtime.kotlin.core.PlayableInstance): void { const owner = this.owner.get(); if (owner) { - // owner.events.notifyEvent(RiveEvents.onLoopEndEvent, { name: animation.getName(), loop: owner.loop }); + owner.events.notifyEvent(RiveEvents.onLoopEndEvent, { name: animation.getName(), loop: owner.loop }); } } notifyStateChanged(stateMachine: string, stateName: string): void { - // this.owner.get()?.events.notifyEvent(RiveEvents.stateChangedEvent, { stateMachine, stateName }); + const owner = this.owner.get(); + if (owner) { + owner.events.notifyEvent(RiveEvents.stateChangedEvent, { stateMachine, stateName }); + } } } @@ -247,9 +259,8 @@ export class RiveView extends RiveViewBase { private addListener() { if (!this.listener) { - // todo investigate. - // this.listener = new Listener(new WeakRef(this)); - //this.nativeViewProtected.getController().registerListener(this.listener); + this.listener = new Listener(new WeakRef(this)); + this.nativeViewProtected.getController().registerListener(this.listener); } }