500px/500px-android-blur

Cannot use blur view with RecyclerView

Opened this issue · 2 comments

Hello,

I was trying to use your blur view in my app insde items displyed in RecyclerView. Unfortunatly, after my recycler is scrolled (up or down) for few items I get following exception:

android.support.v8.renderscript.RSInvalidStateException: Calling RS with no Context active.
at android.support.v8.renderscript.ExceptionThunker.convertException(ExceptionThunker.java:26)
at android.support.v8.renderscript.AllocationThunker.copyFrom(AllocationThunker.java:183)

It is thrown from blur method. To me it looks like this is caused by items being recycled and reused by RecycleView. For current moment I haven't found any solution for this.

same with HeaderGridView. My blurred view is the header of my GridView. When I call setAdapter multiple times it crashes. My workaround is to comment these lines of code:

//     @Override
//     protected void onDetachedFromWindow() {
//         super.onDetachedFromWindow();
//        if (mRenderScript != null) {
//            mRenderScript.destroy();
//        }
//     }

but I think is not a good practice.

I used it normally...
public ViewHolder(View itemView) { super(itemView); imageView = (ImageView) itemView.findViewById(R.id.imageViewHero); mBlurringView = (BlurringView) itemView.findViewById(R.id.blurring_view); View blurredView = itemView.findViewById(R.id.imageViewHero); mBlurringView.setBlurredView(blurredView);

`

            <com.fivehundredpx.android.blur.BlurringView
                android:id="@+id/blurring_view"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:layout_gravity="center"
                app:blurRadius="11"
                app:downsampleFactor="6"
                app:overlayColor="#99FFFFFF"/>`

Just make sure that your BlurringView isn't the child of the BlurredView as you can see above