Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.49k stars 331 forks source link

Drawing not stopped when used in RecyclerView #15

Closed rayanmestiri closed 8 years ago

rayanmestiri commented 8 years ago

I'm adding multiple BlurViews in a RecyclerView.
When I scroll to the point that a BlurView is outside the screen area and then scroll back to see that view, it crashes because the functions are called on null objects.

Maybe I can manage this outside the library, from the RecyclerView but how could I stop the draw calls on the BlurViews when they're not rendered and start them back when they are?

I tried adding conditions checks in the library but it does not start blurring back when the views are displayed again.

Dimezis commented 8 years ago

Ok, I see. I'll check this behavior and add the possibility to correctly resume blurring.

rayanmestiri commented 8 years ago

Hi Dimezis,

Thanks for taking the time to look into this. I wanted to point out that the errors returned by this bug are the same as this issue: https://github.com/Dimezis/BlurView/issues/16 They are both related to showing/hiding the views but not by the same means.

I also wanted to point out that the bug also affects Fragments. When you commit a Fragment that replaces one that contains a BlurView, similar errors appear, due to the BlurView returned being null.

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate()' on a null object reference at eightbitlab.com.blurview.DefaultBlurController.updateBlur(DefaultBlurController.java:138) at eightbitlab.com.blurview.DefaultBlurController.access$100(DefaultBlurController.java:21) at eightbitlab.com.blurview.DefaultBlurController$2.onPreDraw(DefaultBlurController.java:123)

Thanks for the great lib ^^

Dimezis commented 8 years ago

Hi,

Yes, indeed it seems like they have the same root problem, more specifically - calling destroy() inside onDetachedFromWindow().

I have fixed the bug you reported (not released yet) and now investigating all possible consequences and related issues.

Thanks for help.

Dimezis commented 8 years ago

Please check 1.1.0 version, I believe it should be fixed now.

rayanmestiri commented 8 years ago

Ok, tested 1.1.0 on API 23 and it seems to be fixed now. It doesn't crash with RecyclerView, neither with a Fragment Manager. Thank you very much for fixing it so quickly, the lib is extremely useful.

I might do some GPU profiling at some point to make sure the blurring is stopped as intended in every cases. But I won't be able to do so just now.

Thanks again for the fix, I call the issue resolved.