Skip to content

Commit edc6163

Browse files
prashantsaini1hansemannn
authored andcommitted
Android: marker event was only triggered for first and last visible section items (#14124)
* fix(android): fire marker event for all visible items in range of first to last visible item * chore: remove package.json files
1 parent a72b174 commit edc6163

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListViewProxy.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,15 @@ public void handleMarkers()
631631
return;
632632
}
633633

634-
finalListItemProxy[] items =
635-
newListItemProxy[] { listView.getFirstVisibleItem(), listView.getLastVisibleItem()};
634+
finalArrayList<ListItemProxy> items = newArrayList<>();
635+
finalLinearLayoutManagerlm = listView.getLayoutManager();
636+
finalintfirstVisibleItemPos = lm.findFirstVisibleItemPosition();
637+
finalintlastVisibleItemPos = lm.findLastVisibleItemPosition();
638+
639+
// ideally markers should be triggered for all visible items between first and last visible ones
640+
for (inti = firstVisibleItemPos; i <= lastVisibleItemPos; i++) {
641+
items.add(listView.getVisibleItemAt(i));
642+
}
636643

637644
for (finalListItemProxyitem : items) {
638645
if (item != null) {

android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/TiListView.java

+12
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,18 @@ public ListItemProxy getFirstVisibleItem()
571571
returnnull;
572572
}
573573

574+
publicListItemProxygetVisibleItemAt(intindex)
575+
{
576+
finalViewitemView = getLayoutManager().findViewByPosition(index);
577+
578+
if (itemView == null) {
579+
returnnull;
580+
}
581+
582+
// Obtain list item proxy
583+
return ((ListViewHolder) recyclerView.getChildViewHolder(itemView)).getProxy();
584+
}
585+
574586
/**
575587
* Obtain last visible list item proxy.
576588
*

0 commit comments

Comments
 (0)
close