Created
July 5, 2016 08:23
-
-
Save sonvp/247a5455c768d5f0df6486445ffca0c7 to your computer and use it in GitHub Desktop.
Base on swipeRefreshLayoutRecyclerView.java of Mandhor . I fixed bug SwipeRefreshLayout catches scroll up too early - not on top of the list when use with recyclerview. But in some cases It disable SwipeRefreshLayout I can't scroll up . I fixed it with code below
This file contains hidden or 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); | |
} | |
} | |
}); | |
.... | |
///Combine with code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment