Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on closing dialog #2

Open
achatina opened this issue Dec 3, 2018 · 1 comment
Open

NPE on closing dialog #2

achatina opened this issue Dec 3, 2018 · 1 comment

Comments

@achatina
Copy link

achatina commented Dec 3, 2018

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

@danielzeller
Copy link
Owner

danielzeller commented Dec 5, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants