Java Code Examples for android.support.design.widget.BottomSheetBehavior#BottomSheetCallback

The following examples show how to use android.support.design.widget.BottomSheetBehavior#BottomSheetCallback . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleListStepDefinitions.java    From material-activity-chooser with Apache License 2.0 6 votes vote down vote up
private void waitUntilBottomSheetDisplayed() {
    MaterialActivityChooserActivity activityChooserActivity = ActivityUtils.getCurrentActivity(mActivityRule);
    BottomSheetBehavior.BottomSheetCallback originalBottomSheetCallback = SuperReflect.on(activityChooserActivity).get("mBottomSheetCallback");
    if (!(originalBottomSheetCallback instanceof IdlingResourceBottomSheetCallback)) {
        final BottomSheetBehavior bottomSheetBehavior = SuperReflect.on(activityChooserActivity)
                .get("mBottomSheetBehavior");

        /* The bottom sheet gets opened with a delay (using Handler#postDelayed())
         * therefore we need to initially wait for the bottom sheet to get to the 'collapsed' state
         */
        await().until(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED;
            }
        });
        mIdlingResourceBottomSheetCallback = new IdlingResourceBottomSheetCallback(originalBottomSheetCallback, mBottomSheetIdlingResource);
        bottomSheetBehavior.setBottomSheetCallback(mIdlingResourceBottomSheetCallback);
    }
    onView(withId(R.id.mac_bottom_sheet)).check(matches(isDisplayed()));
}
 
Example 2
Source File: BottomSheetCoordinatorLayout.java    From BottomSheetCoordinatorLayout with Apache License 2.0 5 votes vote down vote up
/**
 * Set a {@link android.support.design.widget.BottomSheetBehavior.BottomSheetCallback} callback
 * to our behavior, as soon as it is available.
 *
 * @param bottomSheetCallback desired callback.
 */
public void setBottomSheetCallback(final BottomSheetBehavior.BottomSheetCallback bottomSheetCallback) {
    if (bottomSheetBehavior == null) {
        delayedBottomSheetCallback = bottomSheetCallback;
    } else {
        bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
    }
}
 
Example 3
Source File: BottomSheetMenuDialog.java    From BottomSheetBuilder with Apache License 2.0 4 votes vote down vote up
public void setBottomSheetCallback(BottomSheetBehavior.BottomSheetCallback callback) {
    mCallback = callback;
}
 
Example 4
Source File: IdlingResourceBottomSheetCallback.java    From material-activity-chooser with Apache License 2.0 4 votes vote down vote up
public IdlingResourceBottomSheetCallback(BottomSheetBehavior.BottomSheetCallback wrappedCallback, CountingIdlingResource mBottomSheetIdlingResource) {
    this.mWrappedCallback = wrappedCallback;
    this.mBottomSheetIdlingResource = mBottomSheetIdlingResource;
}