@@ -23,26 +23,38 @@ class Listener extends java.lang.Object implements app.rive.runtime.kotlin.contr
2323 }
2424
2525 notifyPlay ( animation : app . rive . runtime . kotlin . core . PlayableInstance ) : void {
26- // this.owner.get()?.events.notifyEvent(RiveEvents.onPlayEvent, { name: animation.getName() });
26+ const owner = this . owner . get ( ) ;
27+ if ( owner ) {
28+ owner . events . notifyEvent ( RiveEvents . onPlayEvent , { name : animation . getName ( ) } ) ;
29+ }
2730 }
2831
2932 notifyStop ( animation : app . rive . runtime . kotlin . core . PlayableInstance ) : void {
30- // this.owner.get()?.events.notifyEvent(RiveEvents.onStopEvent, { name: animation.getName() });
33+ const owner = this . owner . get ( ) ;
34+ if ( owner ) {
35+ owner . events . notifyEvent ( RiveEvents . onStopEvent , { name : animation . getName ( ) } ) ;
36+ }
3137 }
3238
3339 notifyPause ( animation : app . rive . runtime . kotlin . core . PlayableInstance ) : void {
34- // this.owner.get()?.events.notifyEvent(RiveEvents.onPauseEvent, { name: animation.getName() });
40+ const owner = this . owner . get ( ) ;
41+ if ( owner ) {
42+ owner . events . notifyEvent ( RiveEvents . onPauseEvent , { name : animation . getName ( ) } ) ;
43+ }
3544 }
3645
3746 notifyLoop ( animation : app . rive . runtime . kotlin . core . PlayableInstance ) : void {
3847 const owner = this . owner . get ( ) ;
3948 if ( owner ) {
40- // owner.events.notifyEvent(RiveEvents.onLoopEndEvent, { name: animation.getName(), loop: owner.loop });
49+ owner . events . notifyEvent ( RiveEvents . onLoopEndEvent , { name : animation . getName ( ) , loop : owner . loop } ) ;
4150 }
4251 }
4352
4453 notifyStateChanged ( stateMachine : string , stateName : string ) : void {
45- // this.owner.get()?.events.notifyEvent(RiveEvents.stateChangedEvent, { stateMachine, stateName });
54+ const owner = this . owner . get ( ) ;
55+ if ( owner ) {
56+ owner . events . notifyEvent ( RiveEvents . stateChangedEvent , { stateMachine, stateName } ) ;
57+ }
4658 }
4759}
4860
@@ -247,9 +259,8 @@ export class RiveView extends RiveViewBase {
247259
248260 private addListener ( ) {
249261 if ( ! this . listener ) {
250- // todo investigate.
251- // this.listener = new Listener(new WeakRef(this));
252- //this.nativeViewProtected.getController().registerListener(this.listener);
262+ this . listener = new Listener ( new WeakRef ( this ) ) ;
263+ this . nativeViewProtected . getController ( ) . registerListener ( this . listener ) ;
253264 }
254265 }
255266
0 commit comments