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

Items from http kill the plugin #14

Closed ghost closed 6 years ago

ghost commented 7 years ago

I must image from http get service. I have this code but the app has error What is the problem in my code? Plese help me how can I get image url from API Thanx

this.newcatalogService.getCatalogImages()
            .subscribe(
                (response) => {
                    response.forEach((i) => {
                        this.items.push({ imageUrl: i.imageUrl });
                    });
                    setTimeout( () => {
                        this.isLoading = false;
                    },200 );
                },
                (err) => {

                }
            );
PeterStaev commented 7 years ago

Hey @bumbella , need more info what is the error, on what platform, etc. I have a production (non-angular) app that is loading the URLs from via REST and it is working fine.

ghost commented 6 years ago

Hi!

Thank you for your question. I use android HTC 626 desire device and Grnymotion emulator. I get this error when killing the app. Can U help me what is the problem? Thanx Bumbella

An uncaught Exception occurred on "main" thread.
java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 2, found: 10 Pager id: ffffffff Pager class: class com.tns.gen.android.support.v4.view.ViewPager_frnal_ts_helpers_l58_c38__StateViewPager Problematic adapter: class com.tns.gen.android.support.v4.view.PagerAdapter_frnal_ts_helpers_l58_c38__ImageSwipePageAdapter
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1167)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
    at android.view.View.measure(View.java:18788)
    at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
    at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1059)
    at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:869)
    at org.nativescript.widge
ghost commented 6 years ago

Can I use observable items? I think this is the problem

PeterStaev commented 6 years ago

@bumbella I'm not sure what you are doing when the app is closed so cant really help you on this. Seems you are updating something which is messing up the widget state. And yes you can use ObservableArray as item source for the widget.

PeterStaev commented 6 years ago

No further response so closing this one for now. In case you still have problems, please provide more details.