SwipeBack
SwipeBack copied to clipboard
Is it possible to prevent activity to finish while scroll up in recyclerview?
Hello I am using swipe back activity in one of my project activity. My activity layout contains recyclerview and other components as well. So the problem is when I scroll up my recyclerview items then activity get finished. So is there any way to prevent activity to finish while recyclerview is visible ?
Add || child instanceof RecyclerView
in the if-clause in line 217 of SwipeBackLayout
and the RecyclerView will be scrollable like the ListView, WebView ... . You also need to add the recyclerview support library as dependency to the build.gradle
file of the library.
OK, thanks for your comments.
it not working ,
I have a hierarchy like this
SwipeBackLayout -> FrameLayout -> ConstraintLayout -> RecyclerView
I solved by adding a scroll listener.
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int firstVisibleItem = layoutManager.findFirstCompletelyVisibleItemPosition();
if (firstVisibleItem == 0) {
setEnableSwipe(true);
} else {
setEnableSwipe(false);
}
}
});
I don't know if this is the best solution. But it works :)