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

Calling BottomSheetView#showWithSheetView(...) may result in a stuck undismissible sheet #48

Closed
AChep opened this issue Aug 19, 2015 · 4 comments

Comments

@AChep
Copy link

AChep commented Aug 19, 2015

Steps how to reproduce:

  1. Create a button and listen to clicks on it.
void onClick(View view) {
    if (sheetView.isSheetShowing()) {
        return;
    }
    sheetView.showWithSheetView(...);
}
  1. Click the button as fast as you can multiply times.
  2. Bottom sheet appears in expanded mode and may not be dismissed by calling #dismissSheet() nor by dragging it.

To finally dismiss it you have to do:

if (sheetView.isSheetShowing()) {
    sheetView.dismissSheet();
} else if (sheetView.getSheetView() != null) {
    // Here we go. This should never happen, right?
    try {
        Method method = BottomSheetLayout.class.getDeclaredMethod(
                "setState", BottomSheetLayout.State.class);
        method.setAccessible(true);
        method.invoke(sheetView, BottomSheetLayout.State.EXPANDED);
        sheetView.dismissSheet();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
@AChep
Copy link
Author

AChep commented Aug 19, 2015

As a probably totally broken workaround I do:

void onClick(View view) {
    if (sheetView.isSheetShowing()) {
        return;
    }
    sheetView.showWithSheetView(...);
    try {
        Method method = BottomSheetLayout.class.getDeclaredMethod(
                "setState", BottomSheetLayout.State.class);
        method.setAccessible(true);
        method.invoke(sheetView, BottomSheetLayout.State.PEEKED);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

and it fixes the issue.

@AChep AChep changed the title Calling BottomSheetView#showWithSheetView(...) may result in a stuck undismissable sheet Calling BottomSheetView#showWithSheetView(...) may result in a stuck undismissible sheet Aug 19, 2015
@ZacSweers
Copy link
Contributor

I'm not sure there's anything we can do about this. Seems like the onus should be on the developer to debounce the clicks (or more specifically, calls to showWithSheetView()). @st028 @emilsjolander thoughts?

@emilsjolander
Copy link
Contributor

This should not be put on the developer to debounce clicks. It should 'just work'. I'll submit a pull request in the next couple of hours which fixes this.

@ZacSweers
Copy link
Contributor

Fixed in master, will be out in the next release

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

3 participants