Skip to content

Commit

Permalink
fix(android): add comments for waterfall onScroll event params
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 authored and siguangli committed Oct 30, 2024
1 parent b0b30a3 commit 84a02fa
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ private void relayoutWaterfallIfNeeded() {
LayoutManager layoutManager = hippyRecyclerView.getLayoutManager();
if (layoutManager instanceof HippyStaggeredGridLayoutManager) {
int[] firstVisibleItem = null;
firstVisibleItem = ((HippyStaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions(firstVisibleItem);
firstVisibleItem = ((HippyStaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions(
firstVisibleItem);
if (firstVisibleItem != null && (firstVisibleItem[0] <= WATERFALL_SCROLL_RELAYOUT_THRESHOLD)) {
Adapter adapter = hippyRecyclerView.getAdapter();
if (adapter != null) {
Expand Down Expand Up @@ -421,11 +422,16 @@ public HashMap<String, Object> generateWaterfallViewScrollEvent() {
if (adapter instanceof HippyRecyclerListAdapter) {
HippyRecyclerListAdapter listAdapter = ((HippyRecyclerListAdapter) adapter);
int count = listAdapter.getItemCount();
// Android includes a pull header and a pull footer when calculating the position of an item. In order to
// align with iOS, if a pull header is included, the first item and last item position needs to be
// subtracted by 1
if (listAdapter.hasPullHeader()) {
first = Math.max(0, (first - 1));
end = Math.max(0, (end - 1));
count -= 1;
}
// For align with iOS, if a pull footer is included, the last item position needs to be
// subtracted by 1
if (listAdapter.hasPullFooter() && (end == (count - 1))) {
end = Math.max(0, (end - 1));
}
Expand Down

0 comments on commit 84a02fa

Please sign in to comment.