Open DennyWeinberg opened 4 years ago
Why do you initialize the blurScript with delay?
Because Glide fills the ImageView also with a delay after the cache is loaded, so I just wanted to make sure the image is completely loaded before using your lib. Of course it's just a test...
You need to do it straight away, before anything is drawn on the ImageView
I have the same issue then...
RenderScriptProvider renderScriptProvider = new RenderScriptProvider(mActivity);
photoView.setClipToOutline(true);
ShadowView shadowView = viewDetailsContent.findViewById(R.id.spaceShadow);
shadowView.blurScript = new RenderScriptBlur(renderScriptProvider);
// Target
b.into(photoView);
kotlin.UninitializedPropertyAccessException: lateinit property bitmap has not been initialized
at com.eightbitlab.shadowview.ShadowView.blurChild(ShadowView.kt:125)
at com.eightbitlab.shadowview.ShadowView.onDescendantInvalidated(ShadowView.kt:111)
at android.view.View.damageInParent(View.java:19307)
at android.view.View.setClipToOutline(View.java:18468)
at com.levionsoftware.photos.details.DetailsPagerAdapter.instantiateItem(DetailsPagerAdapter.java:423)
at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1158)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
Move photoView.setClipToOutline(true)
after
shadowView.blurScript = new RenderScriptBlur(renderScriptProvider)
I've already tried that... Doesn't help. I'm asking myself it it isn't because of the ViewPager, because he instantiaties the Views with a delay... maybe...
kotlin.UninitializedPropertyAccessException: lateinit property bitmap has not been initialized
at com.eightbitlab.shadowview.ShadowView.blurChild(ShadowView.kt:125)
at com.eightbitlab.shadowview.ShadowView.onDescendantInvalidated(ShadowView.kt:111)
at android.view.View.damageInParent(View.java:19307)
at android.view.View.setClipToOutline(View.java:18468)
at com.levionsoftware.photos.details.DetailsPagerAdapter.instantiateItem(DetailsPagerAdapter.java:425)
at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1158)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
Where do you initialize the ShadowView?
Right in the instantiateItem
method of my Pager Adapter:
PagerAdapter:
@Override
public Object instantiateItem(@NonNull ViewGroup container, final int position) {
// Inflate
View viewDetailsContent = LayoutInflater.from(container.getContext()).inflate(
R.layout.details_content_normal
, null
);
container.addView(viewDetailsContent);
[...]
RenderScriptProvider renderScriptProvider = new RenderScriptProvider(mActivity);
ShadowView shadowView = viewDetailsContent.findViewById(R.id.spaceShadow);
shadowView.blurScript = new RenderScriptBlur(renderScriptProvider);
photoView.setClipToOutline(true);
[...]
Seems like the view gets invalidated before it has any size assigned.
You can check if the bitmap is initialized in blurChild
and drawShadow
of ShadowView
and skip the shadow drawing if it's not
Thanks for your help! I will try that out. (But not today)
Because Glide fills the ImageView also with a delay after the cache is loaded, so I just wanted to make sure the image is completely loaded before using your lib. Of course it's just a test...
You can wait for glide to fill the image with a callback, that's a lot safer.
Hi,
I'm trying to use your library from my java project:
I'm using an ImageView (PhotoView) and Glide...
I'm getting the following error:
Do you know how to fix that? I've never used Kotlin.
Thanks
EDIT: Use case: Gallery App (Photo Map), full image view with cropped image and I want a shadow on the top and the bottom...