Skip to content

Commit

Permalink
fix(android): amend scrollend event fire condition
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews authored and sgtcoolguy committed Jan 19, 2021
1 parent 393072c commit b7609ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat
{
super.onScrollStateChanged(recyclerView, newState);

if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (isScrolling && newState == RecyclerView.SCROLL_STATE_IDLE) {
isScrolling = false;
proxy.fireSyncEvent(TiC.EVENT_SCROLLEND, generateScrollPayload());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class TiTableView extends TiSwipeRefreshLayout implements OnSearchChangeL
private final SelectionTracker tracker;

private boolean isFiltered = false;
private boolean isScrolling = false;
private int scrollOffsetX = 0;
private int scrollOffsetY = 0;

Expand All @@ -82,10 +83,12 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat
{
super.onScrollStateChanged(recyclerView, newState);

if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (isScrolling && newState == RecyclerView.SCROLL_STATE_IDLE) {
final KrollDict payload = generateScrollPayload();
final TiNestedRecyclerView nestedRecyclerView = getRecyclerView();

isScrolling = false;

// Obtain last touch position for `scrollend` event.
final TiDimension xDimension =
new TiDimension(nestedRecyclerView.getLastTouchX(), TiDimension.TYPE_WIDTH);
Expand All @@ -103,6 +106,8 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy)
{
super.onScrolled(recyclerView, dx, dy);

isScrolling = true;

// Update scroll offsets.
scrollOffsetX += dx;
scrollOffsetY += dy;
Expand Down

0 comments on commit b7609ff

Please sign in to comment.