Skip to content

Commit

Permalink
Fixed #369 - Added OnScrollListener as counterpart of onDetachedFromW…
Browse files Browse the repository at this point in the history
…indow, when ViewPager Adapter is changed at runtime
  • Loading branch information
davideas committed May 25, 2017
1 parent 64b3a9b commit da0d4b9
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -340,11 +340,22 @@ public boolean onTouchEvent(@NonNull MotionEvent event) {
return super.onTouchEvent(event);
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (recyclerView != null) {
// #369 - OnScrollListener as counterpart of onDetachedFromWindow
// Occurs only when a new ViewPager Adapter is changed at runtime
recyclerView.addOnScrollListener(onScrollListener);
}
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (recyclerView != null)
if (recyclerView != null) {
recyclerView.removeOnScrollListener(onScrollListener);
}
}

protected void setRecyclerViewPosition(float y) {
Expand Down

0 comments on commit da0d4b9

Please sign in to comment.