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

Is there ant way to update image array? #30

Closed bachras closed 5 years ago

bachras commented 5 years ago

Hi, Thanks for great plugin. I have a scenario, where I don't want to check for all images on page load, but once user reach the end of the image array, I want to update array with another 20 images. Currently it shows error below, once I update the array of images. Any help is appreciated. Thanks


System.err: java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 30, found: 40 Pager id: a Pager class: class com.tns.gen.android.support.v4.view.ViewPager_swipe_110_28_StateViewPager Problematic adapter: class com.tns.gen.android.support.v4.view.PagerAdapter_swipe_128_28_ImageSwipePageAdapter
System.err:     at android.support.v4.view.ViewPager.populate(ViewPager.java:1137)
System.err:     at android.support.v4.view.ViewPager.populate(ViewPager.java:1086)
System.err:     at android.support.v4.view.ViewPager$3.run(ViewPager.java:267)
System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:723)
System.err:     at android.view.Choreographer.doFrame(Choreographer.java:655)
System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
System.err:     at android.os.Handler.handleCallback(Handler.java:789)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:98)
System.err:     at android.os.Looper.loop(Looper.java:164)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6541)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
PeterStaev commented 5 years ago

Hey @bachras , new version (4.1) should resolve this. Note that you need to push your images on the fore-last item and not the last one, since the plugin automatically preloads the next image from the current one to have a nice smooth scrolling.