CardStackView icon indicating copy to clipboard operation
CardStackView copied to clipboard

Even when just on Automatic mode, cards can be dragged after the swipe begins

Open samwaxman opened this issue 6 years ago • 2 comments

I've set manager.setSwipeableMethod(SwipeableMethod.Automatic) and it works, but it fails when an automatic swipe begins. There's a gif below. The expected behavior is that I shouldn't be able to start dragging it.

swipeBug

samwaxman avatar May 05 '19 05:05 samwaxman

@samwaxman Thank you for report.

I already know this issue and try to resolve. But it is difficult because we can't identify manual swipe or automatic swipe in CardStackLayoutManager especially in scrollHorizontallyBy and scrollVerticallyBy. So we can't block manual swipe while running automatic swipe.

Do you have any idea to resolve this issue? And your contribution is welcome!

yuyakaido avatar May 08 '19 21:05 yuyakaido

@samwaxman there's a hack way to solve this issue temporarily. you can add another view to cover on the cardStackView. And then add a scrollListener for cardStackView, when it comes to scrolling, show the cover view to intercept touch event.

cardStackView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);
        if (newState == RecyclerView.SCROLL_STATE_IDLE) {
            coverView.setVisibility(View.GONE);
        } else {
            coverView.setVisibility(View.VISIBLE);
        }
    }
});

make sure your cover view is transparent and can handle touch event:

android:background="@android:color/transparent"
android:clickable="true"
android:focusable="true"

yueban avatar Jun 08 '19 04:06 yueban