PeterStaev / nativescript-image-swipe

A NativeScript widget to easily :point_up_2: and :mag: through a list of images
Apache License 2.0
35 stars 21 forks source link

Don't work refresh, when update imageList #50

Closed san3k1990 closed 4 years ago

san3k1990 commented 5 years ago

Hi. Thanks for your plugin, but i have same problem. I have a button. And when i click the button, then i change imgList. (I clean imgList and add new images). If count img in old imgList == count img in new imgList , then plugin show old images. If count in new imgList > count in old imgList -> i have exception: System.err: java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 2, found: 3 Pager id: 13 Pager class: class com.tns.gen.android.support.v4.view.ViewPager_swipe_115_28_StateViewPager Problematic adapter: class com.tns.gen.android.support.v4.view.PagerAdapter_swipe_133_28_ImageSwipePageAdapter Version plugin 4.1.1

PeterStaev commented 5 years ago

Hey @san3k1990 , seems you are using an older version of the plugin. If your project is NS 6+ make sure you update to the latest version. Also not sure what flavor of NS are you using (Core, Angular, Vue) and not sure what arrays are you using. Please provide a reproducible example via the NS playground or directly attaching your reproducible project here.

san3k1990 commented 5 years ago

imageSwipeTest.zip I upgrade project to ns 6+ and upgrade plugin to 5.0.1, but the problem stil have. This is small project with problem. If tap to replaceElement, i replace image in my array, but the screen displays the same pictures. If i tap to addElement, i add 2 new elements to may array. And then when i swipe image, i get Exception.

san3k1990 commented 5 years ago

And if use project in old device (with Android 5 and 2GB memory), sometimes we can get OutOfMemory. Same problem, if use Image from Core component.

PeterStaev commented 4 years ago

Hey @san3k1990 , since you are using angular, and the widget doesn't have native angular support (#24) you will probably have to manually call refresh() of the widget in order for the new values to correctly be shown.

As for the OOM problem - there is not much that can be done. The widget already loads the minimal amount of images - the current one, previous (if any) and next (if any). So in the general case there will be 3 images loaded. I guess if there is not enough memory and if the images are big, there would be problems.

san3k1990 commented 4 years ago

About OOM problem. The problem is faster in clearing the memory. The problem occurs if you go to the page with ImageSwipe several times. Same problem with native component Image. I switched to the plugin nativescript-image (old nativescript-fresco) and the problem is gone. But i can't use nativescript-image in nativescript-image-swipe

PeterStaev commented 4 years ago

I see, yes, you can't use fresco here (and I'm not sure if it will be possible). I will log this as another issue.

PeterStaev commented 4 years ago

No further response so closing this one for now.