SwipeBack icon indicating copy to clipboard operation
SwipeBack copied to clipboard

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

Open ronakinheritx opened this issue 8 years ago • 4 comments

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 ?

ronakinheritx avatar Jan 24 '17 13:01 ronakinheritx

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.

svendroid avatar Jul 12 '17 12:07 svendroid

OK, thanks for your comments.

liuguangqiang avatar Jul 28 '17 01:07 liuguangqiang

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

4qn avatar Sep 12 '17 13:09 4qn

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

VaseemSathar avatar Sep 13 '17 17:09 VaseemSathar