Skip to content

Commit

Permalink
Android: marker event was only triggered for first and last visible s…
Browse files Browse the repository at this point in the history
…ection items (#14124)

* fix(android): fire marker event for all visible items in range of first to last visible item

* chore: remove package.json files
  • Loading branch information
prashantsaini1 committed Sep 27, 2024
1 parent 8666185 commit fb696a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,15 @@ public void handleMarkers()
return;
}

final ListItemProxy[] items =
new ListItemProxy[] { listView.getFirstVisibleItem(), listView.getLastVisibleItem()};
final ArrayList<ListItemProxy> items = new ArrayList<>();
final LinearLayoutManager lm = listView.getLayoutManager();
final int firstVisibleItemPos = lm.findFirstVisibleItemPosition();
final int lastVisibleItemPos = lm.findLastVisibleItemPosition();

// ideally markers should be triggered for all visible items between first and last visible ones
for (int i = firstVisibleItemPos; i <= lastVisibleItemPos; i++) {
items.add(listView.getVisibleItemAt(i));
}

for (final ListItemProxy item : items) {
if (item != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@ public ListItemProxy getFirstVisibleItem()
return null;
}

public ListItemProxy getVisibleItemAt(int index)
{
final View itemView = getLayoutManager().findViewByPosition(index);

if (itemView == null) {
return null;
}

// Obtain list item proxy
return ((ListViewHolder) recyclerView.getChildViewHolder(itemView)).getProxy();
}

/**
* Obtain last visible list item proxy.
*
Expand Down

0 comments on commit fb696a1

Please sign in to comment.