tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.76k stars 1.21k forks source link

Image Gallery Preloader Issues #14084

Open Informate opened 4 months ago

Informate commented 4 months ago

I have searched and made sure there are no existing issues for the issue I am filing

Description

I am creating an Image Gallery with remote images using ImageView. I have a local default image to show while images are loading. I am preloading the image to speed up the gallery swiping. To preload the images I put them in an ImageView with {visibility: false, width: 0, height: 0}, in this way when I call them they should be already cached and show up immediately when I change the image in the original gallery image. (gallery.image=...)

Maybe this is just the wrong way to do it and I have to use separate ImageView and do not reuse the same object. I am not posting the code because it is very complex.

This happens on Android, still not tested on iOS (Maybe changing approach and will never be test).

Expected Behavior

The images appears correctly.

Actual behavior

While the images are loading if I swipe to an another image the default image do not shows up and the image is partially shown without the not loaded part.

Reproducible sample

x

Steps to reproduce

x

Platform

Android & iOS

SDK version you are using

12.3.0

Alloy version you are using

No response

m1ga commented 4 months ago

This sounds more like an implementation issue and not a SDK bug. If it is a bug please try to create a simple example so we can test it. You don't say how you created your gallery or any other infos. Is it a ScrollableView?

I wouldn't create ImageViews to preload the images, I would download them and if you have the local file you show it, if not show the preview image and wait until the image is downloaded and then replace it. Or your API should provide multiple sizes and you show a smaller version right away and then higher version behind the "small" imageview. When that is ready hide the "small" imageview.

Or try other imageviews like https://github.com/AndreaVitale/av.imageview