Nativescript: Image is broken in Empty cases

Created on 10 Nov 2016  Â·  4Comments  Â·  Source: NativeScript/NativeScript

Please, provide the details below:

Did you verify this is a real problem by searching

Yes

Tell us about the problem

The code that was recently updated in 2.4 breaks the Image in cases where it is in a listview/radlistview and the data that would go into the image is a null/empty src. In this case the OLD image from the recycled listview cell continues to show instead of the cell image being blanked out.

Which platform(s) does your issue occur on?

Android (might occur on iOS, untested)

Please provide the following version numbers that your issue occurs with:

nativescript │ 2.3.0
tns-core-modules │ 2.5.0-2016-11-07-4695
tns-android │ 2.5.0-next-2016-11-07-1363

Please tell us how to recreate the issue in as much detail as possible.

  1. Drop a Image view in a listview
  2. setup the observable data so you have valid images and empty image srcs
  3. Scroll in the list view so that the cells get recyled, and you should see the old image show.
bug done android

Most helpful comment

Can confirm that the behaviour is observed when I reproduce the scenario described by @NathanaelA
Code to reproduce here

Or use the one below:
_main-view-model.ts_

import {Observable} from 'data/observable';

export class HelloWorldModel extends Observable {

  private items: Array<string>;

  constructor() {
    super();

    this.items = ["res://icon", "res://logo","res://icon","res://logo",null,null,null,null,null,null,null,null,null,null, "res://logo","res://icon"];
  }
}

_main-page.xml_

      <ListView.itemTemplate>
          <StackLayout>
              <Label text="test" textWrap="true" />
              <Image src="{{ $value }}" stretch="none" />
          </StackLayout>
      </ListView.itemTemplate>
  </ListView>

_main-page.ts_

import { EventData } from 'data/observable';
import { Page } from 'ui/page';
import { HelloWorldModel } from './main-view-model';

export function navigatingTo(args: EventData) {
  let page = <Page>args.object;
  page.bindingContext = new HelloWorldModel();
}

Expected: the list view to have 4 items with images.. then scroll a bunch with null images and then finish with 2 images.

Actual result: when scrolling the images are not recycled and the old ones are showing in cells where the images has null as a value for src

All 4 comments

Is this a regression @dtopuzov ? Cc @hhristov.

Can confirm that the behaviour is observed when I reproduce the scenario described by @NathanaelA
Code to reproduce here

Or use the one below:
_main-view-model.ts_

import {Observable} from 'data/observable';

export class HelloWorldModel extends Observable {

  private items: Array<string>;

  constructor() {
    super();

    this.items = ["res://icon", "res://logo","res://icon","res://logo",null,null,null,null,null,null,null,null,null,null, "res://logo","res://icon"];
  }
}

_main-page.xml_

      <ListView.itemTemplate>
          <StackLayout>
              <Label text="test" textWrap="true" />
              <Image src="{{ $value }}" stretch="none" />
          </StackLayout>
      </ListView.itemTemplate>
  </ListView>

_main-page.ts_

import { EventData } from 'data/observable';
import { Page } from 'ui/page';
import { HelloWorldModel } from './main-view-model';

export function navigatingTo(args: EventData) {
  let page = <Page>args.object;
  page.bindingContext = new HelloWorldModel();
}

Expected: the list view to have 4 items with images.. then scroll a bunch with null images and then finish with 2 images.

Actual result: when scrolling the images are not recycled and the old ones are showing in cells where the images has null as a value for src

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Pourya8366 picture Pourya8366  Â·  3Comments

valentinstoychev picture valentinstoychev  Â·  3Comments

NickIliev picture NickIliev  Â·  3Comments

rogangriffin picture rogangriffin  Â·  3Comments

kn9ts picture kn9ts  Â·  3Comments