Created
April 8, 2015 21:53
-
-
Save mandhor/31b8d73dfefc21c89a50 to your computer and use it in GitHub Desktop.
SwipeRefreshLayout RecyclerView bug workaround (SwipeRefreshLayout catches scroll up too early - not on top of the list - making it impossible to scroll up recyclerview)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//we have to keep current scroll value somewhere in our fragment | |
private int overallYScroll = 0; | |
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
overallYScroll = overallYScroll + dy; | |
if (overallYScroll <= 0) { | |
//enable swipeRefreshLayout | |
swipeRefreshLayout.setEnabled(true); | |
} else { | |
//disable | |
swipeRefreshLayout.setEnabled(false); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment