500px / 500px-android-blur

Android Blurring View
http://developers.500px.com/2015/03/17/a-blurring-view-for-android.html
MIT License
2.69k stars 326 forks source link

Cannot use blur view with RecyclerView #8

Open ghost opened 9 years ago

ghost commented 9 years ago

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.

sbelloz commented 9 years ago

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.

jaadchacra commented 7 years ago

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);

` <ImageView android:id="@+id/imageViewHero" android:layout_width="match_parent" android:layout_height="250dp" />

            <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