Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to prevent activity to finish while scroll up in recyclerview? #31

Open
ronakinheritx opened this issue Jan 24, 2017 · 4 comments

Comments

@ronakinheritx
Copy link

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 ?

@svendroid
Copy link

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.

@liuguangqiang
Copy link
Owner

OK, thanks for your comments.

@4qn
Copy link

4qn commented Sep 12, 2017

it not working ,
I have a hierarchy like this
SwipeBackLayout -> FrameLayout -> ConstraintLayout -> RecyclerView

@VaseemSathar
Copy link

VaseemSathar commented Sep 13, 2017

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants