Skip to content

Commit cf34d0b

Browse files
committed
fix(collectionview): android fix for collectionview wrongly updating items
Mix of checking `this.isLayoutValid` which is not what i expected, and wrongly returning item id while not having stable ids
1 parent 8ee65fd commit cf34d0b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/collectionview/collectionview.android.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ export class CollectionView extends CollectionViewBase {
677677
}
678678
}
679679
_updateSpanCount() {
680-
if (this.isLayoutValid && this.layoutManager && this.layoutManager['setSpanCount']) {
680+
if (this._layedOut && this.layoutManager && this.layoutManager['setSpanCount']) {
681681
this.layoutManager['setSpanCount'](this.computeSpanCount());
682682
}
683683
}
@@ -690,6 +690,7 @@ export class CollectionView extends CollectionViewBase {
690690
super._onRowHeightPropertyChanged(oldValue, newValue);
691691
}
692692
public onLayout(left: number, top: number, right: number, bottom: number) {
693+
this._layedOut = true;
693694
super.onLayout(left, top, right, bottom);
694695
const p = CollectionViewBase.plugins[this.layoutStyle];
695696
if (p && p.onLayout) {
@@ -810,13 +811,14 @@ export class CollectionView extends CollectionViewBase {
810811
return false;
811812
}
812813

814+
_layedOut = false;
813815
@profile
814816
public refresh() {
815817
if (!this.nativeViewProtected) {
816818
return;
817819
}
818820
const view = this.nativeViewProtected;
819-
if (!this.isLoaded || !this.isLayoutValid) {
821+
if (!this.isLoaded || !this._layedOut) {
820822
this._isDataDirty = true;
821823
return;
822824
}
@@ -915,7 +917,7 @@ export class CollectionView extends CollectionViewBase {
915917
}
916918

917919
public getItemId(i: number) {
918-
let id = i;
920+
let id = -1;
919921
if (this._itemIdGenerator && this.items) {
920922
const item = this.getItemAtIndex(i);
921923
id = this._itemIdGenerator(item, i, this.items);

0 commit comments

Comments
 (0)