nativescript-community / ui-image

Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
Apache License 2.0
36 stars 9 forks source link

Set stretch mode in updateViewSize #38

Closed tomups closed 3 years ago

tomups commented 3 years ago

Should fix https://github.com/nativescript-community/ui-image/issues/37 for Android.

I can't currently build nor test iOS, so would be good to know if https://github.com/nativescript-community/ui-image/issues/37 even happens in iOS at all or not. A friend helped me test in iOS and this bug is not present there, it's only in Android.

I am not sure if this is the best solution, I see that the scale types used in the plug-in come from com.facebook.drawee.drawable.ScalingUtils.ScaleType but when using those in setScaleType, I was getting a "wrong parameter" error from Android, only using the types from android.widget.ImageView.ScaleType worked.

farfromrefug commented 3 years ago

@tomtastico did you try it? As per fresco doc this is not the right way to do it. I am waiting on an answer from the fresco repo here https://github.com/facebook/fresco/issues/2565

tomups commented 3 years ago

Yes it works for me like this:

image

I suspect it's not the most correct way, but if I use Fresco's StyleType for setScaleType the app crashes and in logcat I get:

JNI DETECTED ERROR IN APPLICATION: bad arguments passed to void android.widget.ImageView.setScaleType(android.widget.ImageView$ScaleType) (see above for details)

tomups commented 3 years ago

Also not sure what is going on with the image borders with this fix, it's like the image is drawn over them...

farfromrefug commented 3 years ago

@tomtastico thanks i ll merge it for now and wait for a better answer from the fresco team. Not sure about the borders. Have to think about it

tomups commented 3 years ago

@farfromrefug I think I found a better way, please check the new merge request https://github.com/nativescript-community/ui-image/pull/39 , this one uses Fresco, but I could not test it because somehow my test app has broken and I can't seem to run it again (getting TypeError: Cannot read property 'imagepipeline' of undefined no matter what I try...). If you can give it a test and see if it works the same...

tomups commented 3 years ago

I fixed my test app, it seems this doesn't work 😞 So skip the merge request, I will close it. No idea how to do it with Fresco...

farfromrefug commented 3 years ago

@tomtastico just so you know i rollbacked your PR. Found the right way to fix the original issue. It has been published