Skip to content

Instantly share code, notes, and snippets.

@twiceyuan
Created March 16, 2016 11:46
Show Gist options
  • Save twiceyuan/3ce699650620f4c316d9 to your computer and use it in GitHub Desktop.
Save twiceyuan/3ce699650620f4c316d9 to your computer and use it in GitHub Desktop.
监听 RecyclerView 滚动到顶部 / 底部
import android.support.v7.widget.RecyclerView;
public abstract class OnVerticalScrollListener extends RecyclerView.OnScrollListener {
@Override
public final void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (!recyclerView.canScrollVertically(1)) {
onScrolledToEnd();
} else if (!recyclerView.canScrollVertically(-1)) {
onScrolledToTop();
} else if (dy < 0) {
onScrolledUp();
} else if (dy > 0) {
onScrolledDown();
}
}
public void onScrolledUp() {
}
public void onScrolledDown() {
}
public void onScrolledToEnd() {
}
public void onScrolledToTop() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment