avast / android-styled-dialogs

Backport of Material dialogs with easy-to-use API based on DialogFragment
Apache License 2.0
2.15k stars 450 forks source link

enhance code format; fix #95 #96

Closed liaohuqiu closed 9 years ago

TomasKypta commented 9 years ago

Hi, thank you for your effort. But your proposed changes cannot be merged because they go directly against the current architecture of styled dialogs. We don't want to support setting dialog listeners in builders since it's a very error-prone feature breaking correct handling of device rotation and causing memory leaks. There are also no plans to add such feature in future releases. The only safe approach for handling listeners is via target fragment and activity listeners.

liaohuqiu commented 9 years ago

Memory leaks? So, what do you think about View.setOnClickListener() ?

liaohuqiu commented 9 years ago

If I have a Customized View used in multiple Activity, and I want to show a dialog to show some information related to this Customized View, do you mean that I should process the listener in every Activity?

TomasKypta commented 9 years ago

View listeners are different. Your general listener is strongly referenced in the DialogFragment when you pass an inner class of an Activity you risk leaking the activity when you rotate the device. To solve your problem can have a common ancestor of your activities or if that's really not the case you can always fork styled dialogs and do it your way (I guess there might already be some forks like that).

liaohuqiu commented 9 years ago

OK. Thank you for your nice explanation and your patient.