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

PagerAdapter notifyDataSetChanged! #58

Closed PabloPG closed 3 years ago

PabloPG 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.

Originally posted by @PeterStaev in https://github.com/PeterStaev/nativescript-image-swipe/issues/50#issuecomment-531708089

Platform: Android Nativescript Angular

Some can help to get the swipe element?

I try with page.getViewById, ViewChild, #swipe inside parameter and always return undefined.

<GridLayout rows="30, 15, *, auto" cols="*, auto" height="365" width="320">
    <Label row="0" col="0" rowSpan="2" [text]="title" class="modal-title"></Label>
    <NSImg
        row="0"
        col="1"
        src="res://baseline_close_black_36"
        (tap)="closeModal()"
        width="20"
        height="20"
        style="margin: 10"
        horizontalAlignment="right"
    ></NSImg>

    <StackLayout row="2" colSpan="2" class="painel-imagem">
        <ImageSwipe
                        #mySwipe
                        id="swipe"
            [items]="items"
            imageUrlProperty="imageUrl"
            [pageNumber]="pageNumber"
            (pageChanged)="pageChanged($event)"
            backgroundColor="#000000"
        >
        </ImageSwipe>
    </StackLayout>

    <Button
        row="3"
        text="delete"
        class="btn-contained btn-primary"
        (tap)="deleteImg(mySwipe)"
    ></Button>
</GridLayout>
deleteImg(mySwipe: ImageSwipe) {
        mySwipe.refresh(); // undefined mySwipe
        let swp = this.page.getViewById("swipe"); // undefined
        this.mySwipe.nativeElement.refresh(); // undefined this.mySwipe
    this.items.splice(this.pageNumber, 1);
    this.pageNumber--;
}
PeterStaev commented 4 years ago

Hey @PabloPG , I've just tried both using @ViewChild and with sending directly the element reference to the function and in both situations it is working just fine. So it is probably something specific with you setup.

It would be best if you provide a reproducible sample using the NS PlayGround.

PabloPG commented 4 years ago

Hey @PabloPG , I've just tried both using @ViewChild and with sending directly the element reference to the function and in both situations it is working just fine. So it is probably something specific with you setup.

It would be best if you provide a reproducible sample using the NS PlayGround.

Hi, I managed to use it, the problem now is that even with splice, the scroll keeps showing the image

https://media.giphy.com/media/IcvDG1YR7kcnTDrkQJ/giphy.gif

PeterStaev commented 4 years ago

@PabloPG sorry but I dont understand your last comment. What do you mean with "with splice the scroll keeps showing the image"

PeterStaev commented 3 years ago

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