Dimezis / BlurView

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

[Guide] Refresh blurview not updated after glide image loaded successfully #169

Open nguyenvp08 opened 2 years ago

nguyenvp08 commented 2 years ago

Thank for your helpful library, I have a problem that I use a ViewPager for display images and the blurview is on top of these images but the images need time to be loaded and after they're loaded successful the blurview not updated to show correct blur. So how to solve this issue ? do I need to create a listener for these images to notify when the images are loaded and then requestLayout for the blurview ? or any help from your library ? Thank a lot

Dimezis commented 2 years ago

Can you please show your BlurView setup code? Theoretically, you don't need to do anything extra. But you can try to call invalidate on BlurView after the images are loaded. Let me know if that worked

nguyenvp08 commented 2 years ago

hi @Dimezis, I used the code setup as below :

                viewBinding.blurView.setupWith(viewBinding.layoutRoot as ViewGroup)
                    .setFrameClearDrawable(windowBg)
                    .setBlurAlgorithm(RenderScriptBlur(it))
                    .setBlurRadius(1.0F)
                    .setBlurAutoUpdate(true)
                    .setHasFixedTransformationMatrix(false)
            }

This setup code will be call at onCreate of the fragment. After an api called successfully I make the blur view visible as the same time the image is loading. Then sometimes the blur view showed the correct blur effect, but sometimes it didn't. I just make a test to delay the visibility of blur view about 300ms after image is loaded, then it always show correct blur effect.

I also tried the invalidate function on blur view but it is not update because of this :

if (canvas instanceof BlurViewCanvas) {
            return false;
        }

When the screen is off and turn on again the RecordingCanvas is pass to the updateBlur function and the blur show correct blur effect

Dimezis commented 2 years ago

Do you have some animation running on those ImageViews when the image is loaded?

nguyenvp08 commented 2 years ago

Do you have some animation running on those ImageViews when the image is loaded?

I don't use any animation when loading images, but there is a place holder image, i think the blur view make a blur effect on that place holder image, and after image is loaded successfully, it can not be updated.

elza-khamdeeva commented 10 months ago

@Dimezis hello, is there any updates on this issue?

Dimezis commented 10 months ago

@elza-khamdeeva I haven't been able to reproduce it. A working test project would help