wasabeef / Blurry

Blurry is an easy blur library for Android
Apache License 2.0
5.57k stars 602 forks source link

Crash using on Oncreate #52

Closed SluggedGerm2 closed 7 years ago

SluggedGerm2 commented 7 years ago

It crash using it into onCreate. I solved using a hendler like final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 1000ms Blurry.with(getApplicationContext()).capture(m_Cover).into((ImageView) findViewById(R.id.dash_imageView_cover_to_blurry)); } }, 150);

Are there any solution to have blur effect without delay?

rafa-js commented 7 years ago

This approach worked for me:

container.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                setupBlurEffect();
                container.getViewTreeObserver().removeOnGlobalLayoutListener( this );
            }
        } );
SluggedGerm2 commented 7 years ago

Thanks, it work fine :)