You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
There seems to be good support for onClick related listeners, but not UI elements that have custom listeners, (e.g. SeekBar.OnSeekBarChangeListener).
You could build a @Listener annotation that could take the id of a specific UI element and based on that element's type and the name of the method being annotated, infer what listener to bind.
The below example could delegate the onProgressChanged method of SeekBar.OnSeekBarChangeListener to the annotated class.
@Listener(R.id.mySeekBar)
public void onProgressChanged(...)
This is an interesting idea, however, it can't be done that way :) .
We cannot determine the type of a view based on its ID. Different views can have the same id, ids can be generated without any view associated with them in the xml, views can be added from the code, layouts can be set from the code, etc.
Even if we knew that R.id.mySeekBar is a SeekBar, it wouldn't be easy to find the corresponding listener: you'd have to list all methods and parent methods of the activity, trying to find a "setXXX" that has a param with the corresponding type:
Won't work with @EBean
Sometimes it may be addXXX instead of setXXX
You might as well find two methods with different names and the same param type
There's a convention in AA where the method name is used as id is no id is given. It would clearly not work here
We'd have to match the exact signature (eg void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)), because of overloading (two methods may have the same name), but then we'd lost the advantage of not defining some params.
If you or someone else comes up with other ideas on how to do that, please tell :) . In the meantime, I guess the best fix we can have for now is to provide a SeekBar event dedicated annotation.
There seems to be good support for onClick related listeners, but not UI elements that have custom listeners, (e.g. SeekBar.OnSeekBarChangeListener).
You could build a @Listener annotation that could take the id of a specific UI element and based on that element's type and the name of the method being annotated, infer what listener to bind.
The below example could delegate the onProgressChanged method of SeekBar.OnSeekBarChangeListener to the annotated class.
@Listener(R.id.mySeekBar)
public void onProgressChanged(...)