-
Notifications
You must be signed in to change notification settings - Fork 220
[[ LifecycleListeners ]] Allow lcb widgets to register and listen for Android lifecycle events #7339
[[ LifecycleListeners ]] Allow lcb widgets to register and listen for Android lifecycle events #7339
Conversation
So I think using an indexed-container would be better. This means we can guarantee an order on calling of OnPause / OnResume. We OnPause in order of addition, and OnResume in reverse order. There's no need to use/return an index - as the Listeners are objects - unless I'm forgetting something about Java that means we can just use equality? We can make things super simple - Register appends the given listener object to the list, Unregister removes the most recent matching listener from the list. (By list I mean array which is always dense - so if you delete element 1, all elements above get shuffled back down). I also think that the code to register/unregister and the list itself should be maintained in the engine view, not the Activity (the Activity is purposely very lightweight). Finally, I think all registered listeners should pause before the main view does, and resume afterwards - otherwise things they may depend on engine-side might not be in the right state. (One other thing is that I don't think we need to worry about synchronization, engine/LCB always runs co-operatively so these shouldn't ever be called from two threads at once). |
7429695
to
00d6d2f
Compare
00d6d2f
to
affe81c
Compare
affe81c
to
60d3ee9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one last thing :)
The commit message is now stale as it refers to Android activity:
[[ LifecycleListeners ]] Add ability to register for lifecycle events on Android
This patch adds methods to the Android `Engine` class to enable subscription to
the `onPause` and `onResume` lifecycle events. Subscription is done by providing
an object implementing the `LifecycleListener` interface. The ability is designed
to be used internally, and to be wrapped by LCB utility methods.
7466965
to
45aef32
Compare
@livecode-vulcan review ok 45aef32 |
💙 review by @runrevmark ok 45aef32 |
…fecycle_events [[ LifecycleListeners ]] Allow lcb widgets to register and listen for Android lifecycle events This PR adds handlers to the android-utils module allowing lcb widgets to register for Android lifecycle events (at present these are pause and resume). Note that we wrap the listener object in LiveCodeActivity.java, allowing for storage in a hash set. A possible alternative would be to use an index based container, with register returning the index of the listener in the container and unregister taking the index of the listener to unregister.
😞 test failure 45aef32
|
The patch updates the docs parser to ensure that it correctly handles handler type definitions. Previously, it was parsing them as handler definitions, expecting a corresponding end handler and a docs entry, causing the parser to get confused.
… on Android This patch adds methods to the Android `Engine` class to enable subscription to the `onPause` and `onResume` lifecycle events. Subscription is done by providing an object implementing the `LifecycleListener` interface. The ability is designed to be used internally, and to be wrapped by LCB utility methods.
… to android utils module This patch add handlers to the android utils module allowing for lcb widgets to register to receive lifecycle events.
45aef32
to
8cd3d53
Compare
@livecode-vulcan review ok 8cd3d53 |
💙 review by @runrevmark ok 8cd3d53 |
…fecycle_events [[ LifecycleListeners ]] Allow lcb widgets to register and listen for Android lifecycle events This PR adds handlers to the android-utils module allowing lcb widgets to register for Android lifecycle events (at present these are pause and resume). Note that we wrap the listener object in LiveCodeActivity.java, allowing for storage in a hash set. A possible alternative would be to use an index based container, with register returning the index of the listener in the container and unregister taking the index of the listener to unregister.
😎 test success 8cd3d53
|
This PR adds handlers to the android-utils module allowing lcb widgets to register for Android lifecycle events (at present these are pause and resume).
Note that we wrap the listener object in LiveCodeActivity.java, allowing for storage in a hash set. A possible alternative would be to use an index based container, with register returning the index of the listener in the container and unregister taking the index of the listener to unregister.