tvbarthel / BlurDialogFragment

Library project to display DialogFragment with a blur effect.
Apache License 2.0
2.09k stars 334 forks source link

[BlurEngine] fix delayed blur due to pre-draw registration #65

Closed tbarthel-fr closed 8 years ago

tbarthel-fr commented 8 years ago

Blame myself on this.

When requesting a blur, there no certitude that a new draw pass will be performed for the holding activity decor view. Therefore registering a onPreDrawListener was completly silly if the holding activity decor view was already displayed.

This was leading to several crashes due to registered onPreDrawListener triggered only once the dialog fragment was destroyed. HoldingActivity was at this time null and an NPE was fired.

62

A onPreDrawListener is still needed to handle a configuration change. In fact, dialogs fragments are attached again before activity UI is drawn. That's why we have to wait onPreDraw to ensure that blurred won't be performed on black pixels. But instead on registering the onPreDrawListener every times, we check now that the decor view isn't already shown. If it's the case, we directly launch the blur process.

Hope I won't release new critical bugs like this in the futur...

vbarthel-fr commented 8 years ago

There is no apparent reason to return false in your OnPreDrawListener#onPreDraw =)

vbarthel-fr commented 8 years ago

lgtm :ghost: