Blur-LIB-Android icon indicating copy to clipboard operation
Blur-LIB-Android copied to clipboard

NPE on closing dialog

Open achatina opened this issue 7 years ago • 1 comments

Tried to use this lib for blur effect in dialog, but when it closes, i get this:

    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Canvas.isRecordingFor(java.lang.Object)' on a null object reference
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3443)
        at android.view.View.draw(View.java:17217)
        at no.danielzeller.blurbehindlib.BlurBehindLayout.renderBehindViewToTexture(BlurBehindLayout.kt:252)
        at no.danielzeller.blurbehindlib.BlurBehindLayout.redrawBlurTexture(BlurBehindLayout.kt:216)
        at no.danielzeller.blurbehindlib.BlurBehindLayout.access$redrawBlurTexture(BlurBehindLayout.kt:25)
        at no.danielzeller.blurbehindlib.BlurBehindLayout$frameCallBack$1.doFrame(BlurBehindLayout.kt:234)

Plus can't understand, while it rendering, it has a moment when view becomes black on a second. Looks not very good.

Maybe I'm doing smth wrong. Here is how i use it in dialog:

<FrameLayout
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/blur_root"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <no.danielzeller.blurbehindlib.BlurBehindLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/blur"
            app:blurRadius="30.0"
            app:updateMode="continuously"
            app:blurTextureScale="0.1">
        //content
    </no.danielzeller.blurbehindlib.BlurBehindLayout>
</FrameLayout>

And setting view: dialog?.blur?.viewBehind = activity.root

achatina avatar Dec 03 '18 09:12 achatina

The View behind in your case activity.root should not be the parent of the BlurBehindLayout. Try something like:

<FrameLayout
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/blur_root"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<FrameLayout
        android:id="@+id/viewToBeBlurred"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
<!--add your content views here, the ones that will be blurred and are "behind"... -->
</FrameLayout>
    <no.danielzeller.blurbehindlib.BlurBehindLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/blur"
            app:blurRadius="30.0"
            app:updateMode="continuously"
            app:blurTextureScale="0.1">
 
    </no.danielzeller.blurbehindlib.BlurBehindLayout>
</FrameLayout>  

dialog?.blur?.viewBehind = viewToBeBlurred

danielzeller avatar Dec 05 '18 15:12 danielzeller