Giter Site home page Giter Site logo

blurview's Introduction

Stand With Ukraine

BlurView

Dynamic iOS-like blur for Android Views. Includes library and small example project.

BlurView can be used as a regular FrameLayout. It blurs its underlying content and draws it as a background for its children. The children of the BlurView are not blurred. BlurView redraws its blurred content when changes in view hierarchy are detected (draw() called). It honors its position and size changes, including view animation and property animation.

How to use

  <eightbitlab.com.blurview.BlurView
      android:id="@+id/blurView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:blurOverlayColor="@color/colorOverlay">

       <!--Any child View here, TabLayout for example. This View will NOT be blurred -->

  </eightbitlab.com.blurview.BlurView>
    float radius = 20f;

    View decorView = getWindow().getDecorView();
    // ViewGroup you want to start blur from. Choose root as close to BlurView in hierarchy as possible.
    ViewGroup rootView = (ViewGroup) decorView.findViewById(android.R.id.content);
    
    // Optional:
    // Set drawable to draw in the beginning of each blurred frame.
    // Can be used in case your layout has a lot of transparent space and your content
    // gets a too low alpha value after blur is applied.
    Drawable windowBackground = decorView.getBackground();

    blurView.setupWith(rootView, new RenderScriptBlur(this)) // or RenderEffectBlur
           .setFrameClearDrawable(windowBackground) // Optional
           .setBlurRadius(radius)

Always try to choose the closest possible root layout to BlurView. This will greatly reduce the amount of work needed for creating View hierarchy snapshot.

SurfaceView, TextureView, VideoView, MapFragment, GLSurfaceView, etc

BlurView currently doesn't support blurring of these targets, because they work only with hardware-accelerated Canvas, and BlurView relies on a software Canvas to make a snapshot of Views to blur.

Gradle

Since JCenter is closing, please use https://jitpack.io/ and release tags as the source of stable artifacts.

implementation 'com.github.Dimezis:BlurView:version-2.0.3'

Rounded corners

It's possible to set rounded corners without, the algorithm is the same way as with other regular Views:

Create a rounded drawable, and set it as a background.

Then set up the clipping, so the BlurView doesn't draw outside the corners

blurView.setOutlineProvider(ViewOutlineProvider.BACKGROUND);
blurView.setClipToOutline(true);

Related thread - #37

Why blurring on the main thread?

Because blurring on other threads would introduce 1-2 frames of latency.

Comparing to other blurring libs

  • The main advantage of BlurView over almost any other library is that it doesn't trigger redundant redraw.
  • The BlurView never invalidates itself or other Views in the hierarchy and updates only when needed relying on just a Bitmap mutation, which is recorded on a hardware-accelerated canvas.
  • It supports multiple BlurViews on the screen without triggering a draw loop.
  • It uses optimized RenderScript Allocations on devices that require certain Allocation sizes, which greatly increases blur performance.
  • It allows choosing a custom root view to take a snapshot from, which reduces the amount of drawing traversals and allows greater flexibility.
  • Supports blurring of Dialogs (and Dialog's background)

Other libs:

License

Copyright 2022 Dmytro Saviuk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

blurview's People

Contributors

danielwilson1702 avatar dimezis avatar jlmcdonnell avatar masc3d avatar rayliverified avatar stemyke avatar tbarthel-fr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blurview's Issues

How to use BlurView correctly in popup window?

Thanks for this great job, but now I am a little puzzled by this question.
I need to show a full-screen and translucent popup window, blurring the background. At first I tried to add BlurView as the root view of popup window, and called setupWith() with itself as the argument. But nothing was blurred.
Then I managed to blur the background by adding BlurView in the activity, and set its visibility every time I show popup window, but I think this is a compromise.
Is there any way to use BlurView in popup window also blurring the background activity? Or more commonly, will BlurView work correctly when background is changeable? Thanks for your reading!

Starting a blocking GC NativeAlloc (after pressing HOME and re-starting)

I'm using BlurView for 7-8 cards on my MainActivity page. Loads fine, performance great. No issues.
If I press HOME and then few minutes later relaunch my app (from Recents), it slows down tremendously and I see loglines (infinitely looping) with:
04-25 08:29:20.213 19957-19957/.... I/art: Starting a blocking GC NativeAlloc

Its basically an ANR and I have to kill the process. Any idea what's going on here?
BlurView is the 4th lib I've tried for blurring and by far the best but if I can't solve this, won't
be able to use it.

Seeing same issue on multiple devices (not device specific). I test w/ Nexus5X and PixelXL

Drawing whats beneath layout

Hey guys.
Maybe its a blunder from my part, but is it possible to blur extacly what is beneath a view.
Right now i can only blur the entire underlaying view, and not the area covered by me BlurView.

Thx.

Wrong rendering after return from background

Hi, Dmitriy! All woks fine except one thing )
When blur view is showing and I send app in background and return it I have strange picture.

device-2016-07-22-120602

I making invalidate() this view in onResume(), but nothing happened (
Please look at this problem.
This is code of call

public void onStart() {

        final View decorView = mFragment.getActivity().getWindow().getDecorView();
        //Activity's root View. Can also be root View of your layout
        final View rootView = decorView.findViewById(android.R.id.content);
        //set background, if your root layout doesn't have one
        final Drawable windowBackground = decorView.getBackground();

        mBlurBgView.setupWith(rootView)
                .windowBackground(windowBackground)
                .blurAlgorithm(new RenderScriptBlur(mFragment.getContext(), true)) //Preferable algorithm, needs RenderScript support mode enabled
                .blurRadius(mRadius);
        mBlurBgView.startAutoBlurUpdate();
    }

This is were the Blur view set up

public void onActivityCreated() {

        Rect visibleFrame = new Rect();
        mRoot = (ViewGroup) mFragment.getActivity().getWindow().getDecorView();
        mRoot.getWindowVisibleDisplayFrame(visibleFrame);

        mBlurContainer = new FrameLayout(mFragment.getActivity());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            // window has a navigation bar
            mBlurContainer = new FrameLayout(mFragment.getActivity());
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(visibleFrame.right - visibleFrame.left,
                    visibleFrame.bottom - visibleFrame.top);
            params.setMargins(visibleFrame.left, visibleFrame.top, 0, 0);
            mBlurContainer.setLayoutParams(params);
        } else {
            mBlurContainer.setPadding(visibleFrame.left, visibleFrame.top, 0, 0);
        }

        mBlurBgView = new BlurView(mFragment.getContext());
        mBlurContainer.addView(mBlurBgView);

        mRoot.addView(mBlurContainer);

    }

CPU load on Activity start

I'm noticing a ~10-15% CPU usage on starting up an activity with a BlurView in it. The CPU use continues until the orientation changes, the screen is turned off or other configuration change happens. Also opening up another activity stops the CPU use.

The CPU usage happens only when I have BlurView being initialized in an activity's onCreate. Here's my project: https://github.com/lordjebe/beaconproject

Low frame rate on device with low memory[see videos]

Today I tested this Library on another device and the performance was really terrible...

videos.zip
better device's profile:
OS:5.1
resolution:1440_2560
ppi:515
CPU:2.0GHz_4+1.5GHz*4
RAM:4G

poor device's profile:
OS:4.4
resolution:720_1280
ppi:312
CPU:1.2GHz_4
RAM:1G

Problems with ImageView as background

I am trying to set the blur effect at the bottom of my screen and set an image as background but the result that I get is:

https://s31.postimg.org/gx452v7rf/test_blur_1.png

There is any bug with imageView?

Here is the XML that I tested:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.esmonissimo.monissimotienda.LoginActivity">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/image_background_login"
    android:src="@mipmap/login_background"
    android:scaleType="centerCrop" />

<eightbitlab.com.blurview.BlurView
    android:id="@+id/blurView"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_gravity="bottom"
    app:blurOverlayColor="@color/colorOverlay">

</eightbitlab.com.blurview.BlurView>
</FrameLayout>

and the activity:

public class LoginActivity extends AppCompatActivity {


@BindView(R.id.blurView) BlurView blurView;
@BindView(R.id.image_background_login) ImageView imageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    ButterKnife.bind(this);

    final float radius = 16f;

    final View decorView = getWindow().getDecorView();
    //Activity's root View. Can also be root View of your layout
    final View rootView = decorView.findViewById(android.R.id.content);
    //set background, if your root layout doesn't have one
    final Drawable windowBackground = decorView.getBackground();

    blurView.setupWith(rootView)
            .windowBackground(windowBackground)
            .blurAlgorithm(new RenderScriptBlur(this, true)) //Preferable algorithm, needs RenderScript support mode enabled
            .blurRadius(radius);
}
}

Note: if I set the blurView setup with:

 android:layout_width="match_parent"
 android:layout_height="match_parent"

Shows all the image blurred.

Rotate BlurView in xml also rotate blurred content

Hi,

Thank your for this awesome lib. I have a small issue when I try to rotate the BlurView in xml by -45 degree to replicate a diamond, like this:

<BlurView
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:rotation="-45"
        app:blurOverlayColor="@color/black_50" />

And as you could have guessed the blurred content get rotated as well which create a weird effect.
I'm thinking about pre-rotating the internalBitmap in BlockingBlurController by 45 degree to counteract this effect without much success.

Another way I'm thinking about is to have the internalBitmap actually bigger than the canvas, and only rotate the canvas to achieve this effect.

Any suggestion is highly appreciated.

Question: is the blurring done on the main thread?

I don't see any threading going on with BlurAlgorithm#blur(Bitmap, float) or with BlurController#drawBlurredContent(Canvas). Blurring on the main thread concerns me. Let me know if I'm wrong or if I've overlooked the threading code

blur

how to change the blur effect? and how to close blur

Crash on destroy

Sometimes crashes with
Attempt to invoke virtual method 'void android.support.v8.renderscript.Allocation.destroy()' on a null object reference at eightbitlab.com.blurview.RenderScriptBlur.destroy(RenderScriptBlur.java:74)

Question: Animate blur effect

Can you add posibility or show example (i can't find it by myself) to animate BlurView from default view state(no blur) to blur with radius 16f. I tried with ObjectAnimator.valueOf and animate redius but that's not what I was looking for

NullPointerException on a BlurView previously shown

I'm having trouble hiding and showing a BlurView, I have a grid with a few tiles, when a button is pressed the blur appears and then the user can hide it. When I show it for the first time or multiple times on the same tile it works properly but when I show it on another tile and go back to the first one I get an exception. The BlurView is inside a RelativeLayout and I'm using alpha + visibility to show/hide the layout (but it also happens if the Blur is outside this layout).

My code is:

final float radius = 8;
final View rootView = itemView.getRootView();

overlay.setupWith(rootView)
       .blurAlgorithm(new RenderScriptBlur(itemView.getContext(), true))
       .blurRadius(radius);
overlay.stopAutoBlurUpdate();

This is the exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getLeft()' on a null object reference
at eightbitlab.com.blurview.DefaultBlurController.setupInternalCanvasMatrix(DefaultBlurController.java:181)
at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:212)
at eightbitlab.com.blurview.BlurView.draw(BlurView.java:57)
at android.view.View.updateDisplayListIfDirty(View.java:15190)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.draw(View.java:16197)
at android.view.View.updateDisplayListIfDirty(View.java:15190)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.support.v7.widget.RecyclerView.drawChild(RecyclerView.java:4134)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.draw(View.java:16197)
at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3543)
at android.view.View.updateDisplayListIfDirty(View.java:15190)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1131)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1377)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.draw(View.java:16197)
at android.view.View.updateDisplayListIfDirty(View.java:15190)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.updateDisplayListIfDirty(View.java:15185)
at android.view.View.draw(View.java:15964)
at android.view.ViewGroup.drawChild(ViewGroup.java:3612)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402)
at android.view.View.draw(View.java:16197)
at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2690)
at android.view.View.updateDisplayListIfDirty(View.java:15190)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)

Thanks in advance.

Blurring not in real time

Hi, i have a recyclerview and to the top of the fragment i have the blurview;
The problem is that the blurview change the picture just when i stop scrolling why please

Stack overflow drawUnderlyingViews

Hi,

We are getting a re-occuring issue with many users with this crash:

Fatal Exception: java.lang.StackOverflowError
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3209)
at android.view.View.draw(View.java:15537)
at android.support.v4.view.ViewPager.draw(ViewPager.java:2257)
at android.view.View.draw(View.java:15419)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15537)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at eightbitlab.com.blurview.DefaultBlurController.drawUnderlyingViews(DefaultBlurController.java:204)
at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:213)
at eightbitlab.com.blurview.BlurView.draw(BlurView.java:56)
at android.view.View.buildDrawingCache(View.java:14744)
at android.view.View.getDrawingCache(View.java:14529)
at android.view.View.draw(View.java:15222)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3221)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15537)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at eightbitlab.com.blurview.DefaultBlurController.drawUnderlyingViews(DefaultBlurController.java:204)
at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:213)
at eightbitlab.com.blurview.BlurView.draw(BlurView.java:56)
at android.view.View.buildDrawingCache(View.java:14744)
at android.view.View.getDrawingCache(View.java:14529)
at android.view.View.draw(View.java:15222)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3221)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15537)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at eightbitlab.com.blurview.DefaultBlurController.drawUnderlyingViews(DefaultBlurController.java:204)
at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:213)
at eightbitlab.com.blurview.BlurView.draw(BlurView.java:56)
at android.view.View.buildDrawingCache(View.java:14744)
at android.view.View.getDrawingCache(View.java:14529)
at android.view.View.draw(View.java:15222)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15417)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.draw(View.java:15537)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at eightbitlab.com.blurview.DefaultBlurController.drawUnderlyingViews(DefaultBlurController.java:204)
at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:213)
at eightbitlab.com.blurview.BlurView.draw(BlurView.java:56)
at android.view.View.getDisplayList(View.java:14428)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.View.draw(View.java:15248)
at android.view.ViewGroup.drawChild(ViewGroup.java:3366)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3202)
at android.view.View.getDisplayList(View.java:14423)
at android.view.View.getDisplayList(View.java:14470)
at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1596)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1469)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2839)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2705)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2274)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1311)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6707)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)
at android.view.Choreographer.doCallbacks(Choreographer.java:613)
at android.view.Choreographer.doFrame(Choreographer.java:583)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5756)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(NativeStart.java)

Here is an example setup:

` final float radius = 2;
final ImageView rootView = (ImageView)root.findViewById(R.id.episodeBlured_background);
final Drawable windowBackground = rootView.getDrawable();

        BlurView blurView = (BlurView) root.findViewById(R.id.blurEpisodeDescView);
        if (blurView != null) {
            blurView.setVisibility(View.VISIBLE);
            if(!isSetUpBlurEpisodeDesc) {
                blurView.setupWith(rootView)
                        .windowBackground(windowBackground)
                        //.blurAlgorithm(new RenderScriptBlur(getActivity(), true)) //Preferable algorithm, needs RenderScript support mode enabled
                        .blurAlgorithm(new StackBlur(true)) //Preferable algorithm, needs RenderScript support mode enabled
                        .blurRadius(radius);
                isSetUpBlurEpisodeDesc = true;
            }
        }`

And another case (we don't know which one is crashing):
` final float radius = 2;
final ImageView rootView = (ImageView) root.findViewById(R.id.episodeBlured_background);
final Drawable windowBackground = rootView.getDrawable();

        BlurView blurView = (BlurView) root.findViewById(R.id.blurEpisodeDescView);
        if (blurView != null) {
            blurView.setVisibility(View.VISIBLE);
            if (!isSetUpBlurEpisodeDesc) {
                blurView.setupWith(rootView)
                        .windowBackground(windowBackground)
                        .blurAlgorithm(new RenderScriptBlur(getActivity(), true)) //Preferable algorithm, needs RenderScript support mode enabled
                        .blurRadius(radius);
                isSetUpBlurEpisodeDesc = true;
            }
        }`

Another slightly different implementation:
` final float radius = 20;
final View decorView = getWindow().getDecorView();
//Activity's root View. Can also be root View of your layout
final View rootView = decorView.findViewById(android.R.id.content);
//set background, if your root layout doesn't have one
final Drawable windowBackground = decorView.getBackground();

        BlurView blurView = (BlurView) findViewById(R.id.blurView);
        if (blurView != null) {
            blurView.setupWith(rootView)
                    .windowBackground(windowBackground)
                    .blurAlgorithm(new RenderScriptBlur(VideoSuggestionActivity.this, true)) //Preferable algorithm, needs RenderScript support mode enabled
                    .blurRadius(radius);
        }`

All check build version before trying to draw:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

And all crashes so far are 4.4 devices.

Any idea what could cause this?

Thanks
James

RenderScript v8 incompatible with other support libraries.

Hi,

I just want to notice you a little problem with Android Studio 2.3. See this SOF for the long version. The short version is Android Studio requires explicit declaration of which library is currently used. As most of our support lib is currently at 25.2.0, it would require a matching 25.2.0 RenderScript version. However, the latest build tool version, which provides the RenderScript lib, is sitting at 25.0.2 which throws a Gradle incompatible error.

As our application supports minSDK 18, I just need to switch to the native version of RenderScript instead. Hopefully this issue will get resolved soon.

Force BlurView to redraw?

I have a blur view in a drawer, and when the drawer is pulled out the blur is static. Is there a way for me to force a redraw every frame, during the drawer action?

I've tested with the demo, and can see that layers underneath a blurview work.

Any help would be greatly appreciated.

Regards,

Caleb

BlurView fails to blur underlying activities

Hello- I'm a bit stumped on this. I can't get it to work.

I'm creating a new activity that contains a blurview, with the intent of blurring the activity underneath. My goal is to have this blurview take up the entire screen, so I have a full-screen blurred view, but for this test I didn't even make it full screen, and it still crashes.

Here's my entire onCreate for my Activity:

public class BlurWindowActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blur_window);

        BlurView blurView = (BlurView)findViewById(R.id.blurView);
        final float radius = 16;



        final View decorView = getWindow().getDecorView();
        //Activity's root View. Can also be root View of your layout
        final View rootView = decorView.findViewById(android.R.id.content);
        //set background, if your root layout doesn't have one
        final Drawable windowBackground = decorView.getBackground();

        blurView.setupWith(rootView)
                .windowBackground(windowBackground)
                .blurAlgorithm(new RenderScriptBlur(this, true)) //Optional, enabled by default. User can have custom implementation
                .blurRadius(radius);
}

Here's my entire XML, "activity_blur_window.xml".

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <eightbitlab.com.blurview.BlurView
    android:id="@+id/blurView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:blurOverlayColor="@color/md_blue_50">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="@string/hello_blank_fragment"/>

</eightbitlab.com.blurview.BlurView>
    </FrameLayout>

The moment I instantiate this, it crashes.

Here's the first part of the crash.

09-06 15:45:24.185 6914-6914/com.myapp E/art: Failed to register native method android.support.v8.renderscript.RenderScript.rsnScriptForEach(JJI[JJ[B[I)V in /data/data/com.myapp/files/instant-run/dex/slice-renderscript-v8_723e22d4b50ba946bb48a8a78fc2e239fc80c235-classes.dex
09-06 15:45:24.185 6914-6914/com.myapp E/art: ----- class 'Landroid/support/v8/renderscript/RenderScript;' cl=0x12cb72e0 -----
09-06 15:45:24.185 6914-6914/com.myapp E/art: objectSize=2330 (744 from super)

From my build.gradle:

defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        renderscriptTargetApi 24
        renderscriptSupportModeEnabled true
    }

What is causing this crash?

Why enabled RenderScript by default?

I see this in the constructor of BlockingBlurController

this.blurAlgorithm = new RenderScriptBlur(blurView.getContext(), true);

I use my custom implementation to avoid apk size going up due to libRSSupport.so, but BlurView instantiated a RenderScript implementation no matter whether I have set a custom implementation, and causing crash.

I think maybe the default implementation should not be instantiated in the constructor , and check before if a custom implementation is set.

NullPointerException

With RenderScript enable:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v8.renderscript.RenderScript.validate()' on a null object reference at android.support.v8.renderscript.BaseObj.getID(BaseObj.java:53) at android.support.v8.renderscript.Script.setVar(Script.java:324) at android.support.v8.renderscript.ScriptIntrinsicBlur.setRadius(ScriptIntrinsicBlur.java:89) at eightbitlab.com.blurview.RenderScriptBlur.blur(RenderScriptBlur.java:60) at eightbitlab.com.blurview.DefaultBlurController.blurAndSave(DefaultBlurController.java:233) at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:216) at eightbitlab.com.blurview.BlurView.draw(BlurView.java:57)

Whit StackBlur enable:
java.lang.NullPointerException: Attempt to get length of null array at eightbitlab.com.blurview.StackBlur.blur(StackBlur.java:56) at eightbitlab.com.blurview.DefaultBlurController.blurAndSave(DefaultBlurController.java:233) at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(DefaultBlurController.java:216) at eightbitlab.com.blurview.BlurView.draw(BlurView.java:57)

This issue occur every time when I use Fragments with custom animation for transactions.

java.lang.IllegalArgumentException: parameter must be a descendant of this view

I just update the lib to latest version and now setupWith is requiring ViewGroup, so i cast it to ViewGroup but it's crashing now. Do i need more than that? thanks.
java.lang.IllegalArgumentException: parameter must be a descendant of this view at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:5459) at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:5388) at eightbitlab.com.blurview.BlockingBlurController.setupInternalCanvasMatrix(BlockingBlurController.java:175) at eightbitlab.com.blurview.BlockingBlurController.drawBlurredContent(BlockingBlurController.java:207) at eightbitlab.com.blurview.BlurView.draw(BlurView.java:57) at android.view.View.updateDisplayListIfDirty(View.java:16167) at android.view.View.draw(View.java:16951) at android.view.ViewGroup.drawChild(ViewGroup.java:3727) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at android.view.View.draw(View.java:17188) at android.view.View.updateDisplayListIfDirty(View.java:16167) at android.view.View.draw(View.java:16951) at android.view.ViewGroup.drawChild(ViewGroup.java:3727) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at android.view.View.updateDisplayListIfDirty(View.java:16162) at android.view.View.draw(View.java:16951) at android.view.ViewGroup.drawChild(ViewGroup.java:3727) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at android.view.View.updateDisplayListIfDirty(View.java:16162) at android.view.View.draw(View.java:16951) at android.view.ViewGroup.drawChild(ViewGroup.java:3727) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at android.view.View.draw(View.java:17188) at com.android.internal.policy.DecorView.draw(DecorView.java:753) at android.view.View.updateDisplayListIfDirty(View.java:16167) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:648) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:654) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:762) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2800) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2608) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2215) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:621) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:6194) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

issue with vector icons

in layouts containing vector icons beneath blurview, it also blurs the icons as well when phone is locked and unlocked, is there any workaround for this?

Disable blur for certain views

Hey there, great lib by the way.

Is there a way to disable the blur just for a view? Thing is I have a textView which animates from the center of the screen over to the blurview, but as it is outside the blurLayout, it gets blurred, and as it is animating, it gets really slow!

how to close blur?

i want to close the blur but i only set mBlurView.setOverlayColor(Color.parseColor("#00000000")), when i open blur happend a issure,the blurView not update

Drawing not stopped when used in RecyclerView

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.

Crash in other lib

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.yr.mx-2/base.apk"],nativeLibraryDirectories=[/data/app/com.yr.mx-2/lib/arm64, /data/app/com.yr.mx-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libMyJni.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at com.yr.mx.utils.JniUtils.(JniUtils.java:8)
at com.yr.mx.MApplication.onCreate(MApplication.java:175)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4726)
at android.app.ActivityThread.access$1600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

when i add the blurview it comes anthor error what i never meet before

Having issue with 1.3.0 release

Hi, I've just updated the library to 1.3.2 and the blurring stops working for my case.
For a quick summary, I'm trying to achieve a very flat 4 direction layout (like snapchat), something like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/view_container_vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/top_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:id="@+id/top_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <BlurView
                android:id="@+id/top_blurView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="invisible" />
        </FrameLayout>

        <LinearLayout
            android:id="@+id/view_container_horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <FrameLayout
                android:id="@+id/left_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent" /> //no blurview for this

            <FrameLayout
                android:id="@+id/middle_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <FrameLayout
                    android:id="@+id/middle_frame"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                <BlurView
                    android:id="@+id/middle_blurView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="invisible"/>
            </FrameLayout>

            <FrameLayout
                android:id="@+id/right_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <FrameLayout
                    android:id="@+id/right_frame"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                <BlurView
                    android:id="@+id/right_blurView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="invisible"/>
            </FrameLayout>
        </co.shutta.shuttapro.mycustomview.MyLinearLayout>

        <FrameLayout
            android:id="@+id/bottom_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:id="@+id/bottom_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <co.shutta.shuttalibrary.views.blurview3.BlurView
                android:id="@+id/bottom_blurView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="invisible"/>
        </FrameLayout>
    </LinearLayout>
....
</RelativeLayout>

And in order for the layout to be laid out like a cross, I shift the view's position like this:

        //top frame
        FrameLayout topContainer = (FrameLayout) findViewById(R.id.top_container);
        topContainer .setY(-screenHeight);
        topContainer .invalidate();

        //Horizontal View container
        final LinearLayout horizontalViewContainer = (LinearLayout) findViewById(R.id.view_container_horizontal);
        horizontalViewContainer.getLayoutParams().height = screenHeight;
        horizontalViewContainer.setY(-screenHeight);
        horizontalViewContainer.invalidate();

        //Left frame
        FrameLayout leftContainer = (FrameLayout) findViewById(R.id.left_frame);
        leftContainer.setX(-screenWidth);
        leftContainer.invalidate();

        //middle frame
        FrameLayout middleContainer = (FrameLayout) findViewById(R.id.middle_container);
        middleContainer .getLayoutParams().width = screenWidth;
        middleContainer .setX(-screenWidth);
        middleContainer .invalidate();

        //right frame
        FrameLayout rightContainer = (FrameLayout) findViewById(R.id.right_container);
        rightContainer .getLayoutParams().width = screenWidth;
        rightContainer .setX(-screenWidth);
        rightContainer .invalidate();

        //bottom
        FrameLayout bottomContainer = (FrameLayout) findViewById(R.id.bottom_container);
        bottomContainer .getLayoutParams().height = screenHeight;
        bottomContainer .setY(-screenHeight);
        bottomContainer .invalidate();

When the navigating between each frame the blurview associated to each frame will be shown.

This same setup has been working fine with version 1.2.0 but it doesn't work with version 1.3.2. After some digging around I found the line that cause this problem:

BlockingBlurController

private void setupInternalCanvasMatrix() {
        //this bitcausing the problem
        //blurView.getDrawingRect(relativeViewBounds);
        //rootView.offsetDescendantRectToMyCoords(blurView, relativeViewBounds);

        float scaleFactorX = scaleFactor * roundingWidthScaleFactor;
        float scaleFactorY = scaleFactor * roundingHeightScaleFactor;

        //float scaledLeftPosition = -relativeViewBounds.left / scaleFactorX;
        //float scaledTopPosition = -relativeViewBounds.top / scaleFactorY;
        float scaledLeftPosition = -blurView.getLeft() / scaleFactorX;
        float scaledTopPosition = -blurView.getTop() / scaleFactorY;
       
        float scaledTranslationX = blurView.getTranslationX() / scaleFactorX;
        float scaledTranslationY = blurView.getTranslationY() / scaleFactorY;

        internalCanvas.translate(scaledLeftPosition - scaledTranslationX, scaledTopPosition - scaledTranslationY);
        internalCanvas.scale(1f / scaleFactorX, 1f / scaleFactorY);
    }

I understand that by taking that bit out, it's is basically the same logic as in version 1.2.0. I would also like to add that for version 1.3.2, only those blurviews that has position change like those above have trouble displaying the blur. All other blurview with fixed position still work as expected.

For my specific use case, I can just comment out that line to get the old behaviour back but I would like to leave this issue here for tracking purpose.

Thank you very much for your time.

Crash, Fatal Exception: java.lang.ArrayIndexOutOfBoundsException

Hi Dmitriy! Now I got a crash in blur view. I can't reproduce it on my devices, but it happens several time. It happened only on Samsung SM-G900F. This is crashlytics log:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=1024; index=1064 at eightbitlab.com.blurview.StackBlur.blur(SourceFile:115) at eightbitlab.com.blurview.DefaultBlurController.blurAndSave(SourceFile:233) at eightbitlab.com.blurview.DefaultBlurController.drawBlurredContent(SourceFile:216) at eightbitlab.com.blurview.BlurView.draw(SourceFile:56) at android.view.View.getDisplayList(View.java:13397) at android.view.View.getDisplayList(View.java:13439) at android.view.View.draw(View.java:14217) at android.view.ViewGroup.drawChild(ViewGroup.java:3103) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940) at android.view.View.getDisplayList(View.java:13392) at android.view.View.getDisplayList(View.java:13439) at android.view.View.draw(View.java:14217) at android.view.ViewGroup.drawChild(ViewGroup.java:3103) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940) at android.view.View.draw(View.java:14503) at android.widget.FrameLayout.draw(FrameLayout.java:472) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2326) at android.view.View.getDisplayList(View.java:13397) at android.view.View.getDisplayList(View.java:13439) at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1582) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2388) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2260) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1890) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1007) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5677) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5021) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643) at dalvik.system.NativeStart.main(NativeStart.java)

Please look at it, maybe you have some ideas.

CPU Load

Hello,

I have a bug when loading Blurview, the CPU load goes up and does not go down.

When I load my application I have to wait until the end before "blurView.setupWith".

When I load a Fragment, the CPU load goes up and I have to re-execute "blurView.setupWith" to see the CPU load return to normal.

If I load an activity, the cpu load returns to normal and I can make a return without seeing it go up.

Sometimes even by running "blurView.setupWith" the CPU remains blocked at high load.

I put a link to my application to see more clearly https://github.com/Old-Geek/Musique

I code just out of curiosity but I confess not to be very gifted, I do not find the problem so I fill it with DIY.

All com.android.support libraries must use the exact same version specification

Hello,

Android studio gives me warning,

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes) Found versions 25.4.0, 25.0.3. Example include com.android.support.animated-vector-drawable:25.4.0 and com.android.support.renderscript:25.0.3

my build.gradle:

dependencies {
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:support-v13:25.4.0'
compile 'com.android.support:animated-vector-drawable:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
//BlurView
compile 'com.eightbitlab:supportrenderscriptblur:1.0.0'
compile 'com.eightbitlab:blurview:1.3.3'
}

I could not find in your source code, where "com.android.support.renderscript:25.0.3" is used.

How can I resolve issue?

couldn't find "libruntimecore_java.so" when adding another library

Hello :)

First of all really thank you for creating such a great library. My issue is when I using your library with Esri Android SDK library get confused and app crash.

SO I googled it and found this question related with this issue and this question for solving issue.

So I could not affort to decide which filter that I have to use for solving issue.

Thanks for helpings

Here is my log :

08-25 10:53:57.369 31674-31674/com.example.saltun.blurviewlibdemo E/AndroidRuntime: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.saltun.blurviewlibdemo-1/base.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_9_apk.apk"], nativeLibraryDirectories=[/data/app/com.example.saltun.blurviewlibdemo-1/lib/arm64, /data/app/com.example.saltun.blurviewlibdemo-1/base.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.example.saltun.blurviewlibdemo-1/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]] couldn't find "libruntimecore_java.so"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.