Blurry icon indicating copy to clipboard operation
Blurry copied to clipboard

Fragments

Open AhmadHossam10 opened this issue 6 years ago • 5 comments

Blurry doesn't work with fragments always giving me null pointer exception

@easycheese @wasabeef @Pkmmte @JasonCromer can you help please ?

AhmadHossam10 avatar May 22 '18 18:05 AhmadHossam10

Blurry gives null pointer exception in Fragment NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.recycle()' on a null object reference

Blurry.with(getContext()).radius(25).sampling(2).onto(mainLayout);

iyashamihsan avatar Jul 17 '19 19:07 iyashamihsan

@iyashamihsan when is this happening while you are blurring the image? Is the fragment being recreated at any point before this crash occurs?

JasonCromer avatar Jul 17 '19 22:07 JasonCromer

Maybe you can share a bit more code and a larger stack trace, please.

JasonCromer avatar Jul 17 '19 22:07 JasonCromer

@JasonCromer Please find below issue with fragments : Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.recycle()' on a null object reference at jp.wasabeef.blurry.internal.Blur.of(SourceFile:42) at jp.wasabeef.blurry.Blurry$Composer.onto(SourceFile:115) ...................

while calling below,

Blurry.with(activity) .radius(40) .sampling(2) .color(ResourcesUtil.getColor(R.color.dirtyBlack25)) .onto(blurredView);

As far as I understood, the err occurs here inside of method of Blur class:

Bitmap cache = view.getDrawingCache(); cache.recycle();

Here, the drawing cache can be null sometimes. This happens when Fragments are used with BottomNavigation Bar. Fragment is removed and redrawn.

The possible solution/ workaround could be to add a null check for bitmap and then recycle.

patilvishwanath avatar Mar 10 '21 12:03 patilvishwanath

Have similar issue, do you have good solution for this problem ?

AMV007 avatar Jun 26 '22 09:06 AMV007