eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Simplify onResult API: void instead of boolean #70

Closed mtotschnig closed 3 years ago

mtotschnig commented 3 years ago

If I am not mistaken the value returned from the onResult callback has no effect. onResult is only used from callResultListener, and the return value of callResultListener is always ignored. Wouldn't it make sense to redesign the API and have onResult as a void function?

eltos commented 3 years ago

While the return value of the protected callResultListener is indeed (currently) not used, the return value of onResult is very much used inside the callResultListener:
It is used to decide whether the result was handled or not. If not, it will be passed to the other fragments or activity inside the hierarchy until it finally got handled. For most use cases this might not be relevant, but if you work with (nested) fragments in your activity then it is important. The library itself requires this mechanism e.g. for the color palette dialogs from which you can open a "nested" color picker dialog.

mtotschnig commented 3 years ago

thank you for the explanation. sorry for having overlooked this.

eltos commented 3 years ago

No problem, you're welcome :)