Commit 953a5b28 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Dismiss content in bottom sheet when closed

This only applies if the content does not have a custom lifecycle.
This patch also adds a test for this functionality.

Change-Id: Ia5f2d87e3d3d0b8d83b7181e23e3b403fbd8b0d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1624813
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662891}
parent e6288abf
...@@ -201,6 +201,10 @@ public class BottomSheetController implements Destroyable { ...@@ -201,6 +201,10 @@ public class BottomSheetController implements Destroyable {
} }
scrim.hideScrim(false); scrim.hideScrim(false);
// If not using a custom lifecycle, notify the controller that the sheet's content
// has been dismissed.
hideContent(mBottomSheet.getCurrentSheetContent(), false);
} }
@Override @Override
......
...@@ -255,6 +255,29 @@ public class BottomSheetControllerTest { ...@@ -255,6 +255,29 @@ public class BottomSheetControllerTest {
assertEquals(customLifecycleContent, mBottomSheet.getCurrentSheetContent()); assertEquals(customLifecycleContent, mBottomSheet.getCurrentSheetContent());
} }
@Test
@MediumTest
public void testCloseEvent() throws TimeoutException, InterruptedException {
requestContentInSheet(mHighPriorityContent, true);
expandSheet();
CallbackHelper contentChangedHelper = new CallbackHelper();
mBottomSheet.addObserver(new EmptyBottomSheetObserver() {
@Override
public void onSheetContentChanged(BottomSheetContent content) {
contentChangedHelper.notifyCalled();
}
});
ThreadUtils.runOnUiThreadBlocking(
() -> mBottomSheet.setSheetState(BottomSheet.SheetState.HIDDEN, false));
contentChangedHelper.waitForCallback(0, 1);
assertEquals("The sheet's content should be null!", null,
mSheetController.getBottomSheet().getCurrentSheetContent());
}
/** /**
* Request content be shown in the bottom sheet and end animations. * Request content be shown in the bottom sheet and end animations.
* @param content The content to show. * @param content The content to show.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment