Skip to content

Commit ae13b93

Browse files
author
farfromrefug
committed
fix(android): refreshVisibleItems not always working
1 parent 87f3fd3 commit ae13b93

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/collectionview/index.android.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,15 @@ export class CollectionView extends CollectionViewBase {
970970
if (!view) {
971971
return;
972972
}
973-
const ids = Array.from(this.bindedViewHolders).sort((a, b) => a - b);
974-
this._listViewAdapter.notifyItemRangeChanged(ids[0], ids[ids.length - 1] - ids[0] + 1);
973+
const layoutManager = this.layoutManager as androidx.recyclerview.widget.LinearLayoutManager;
974+
if (layoutManager['findFirstVisibleItemPosition']) {
975+
const first = layoutManager.findFirstVisibleItemPosition();
976+
const last = layoutManager.findLastVisibleItemPosition();
977+
this._listViewAdapter.notifyItemRangeChanged(first, last + 1);
978+
} else {
979+
const ids = Array.from(this.bindedViewHolders).sort((a, b) => a - b);
980+
this._listViewAdapter.notifyItemRangeChanged(ids[0], ids[ids.length - 1] - ids[0] + 1);
981+
}
975982
}
976983
public isItemAtIndexVisible(index: number): boolean {
977984
const view = this.nativeViewProtected;

0 commit comments

Comments
 (0)