-
Notifications
You must be signed in to change notification settings - Fork 594
API Documentation
Mark Rietveld edited this page Dec 1, 2015
·
4 revisions
##API
/**
* Set the presented sheet to be in an expanded state.
*/
public void expandSheet();
/**
* Set the presented sheet to be in a peeked state.
*/
public void peekSheet();
/**
* @return The peeked state translation for the
* presented sheet view. Translation is counted from
* the bottom of the view.
*/
public float getPeekSheetTranslation();
/**
* @return The maximum translation for the presented
* sheet view. Translation is counted from the bottom
* of the view.
*/
public float getMaxSheetTranslation();
/**
* @return The currently presented sheet view. If no
* sheet is currently presented null will returned.
*/
public View getContentView();
/**
* @return The currently presented sheet view. If no
* sheet is currently presented null will returned.
*/
public View getSheetView();
/**
* Set the content view of the bottom sheet. This is
* the view which is shown under the sheet being presented.
* This is usually the root view of your application.
*
* @param contentView The content view of your application.
*/
public void setContentView(View contentView);
/**
* Convenience for showWithSheetView(sheetView, null, null)
*/
public void showWithSheetView(View sheetView);
/**
* Convenience for
* showWithSheetView(sheetView, viewTransformer, null)
*/
public void showWithSheetView(View sheetView, ViewTransformer viewTransformer);
/**
* Dismiss the sheet currently being presented.
*/
public void dismissSheet();
/**
* @return The current state of the sheet.
*/
public State getState();
/**
* @return Whether or not a sheet is currently presented.
*/
public boolean isSheetShowing();
/**
* Set the default view transformer to use for showing
* a sheet. Usually applications will use a similar
* transformer for most use cases of bottom sheet so
* this is a convenience instead of passing a new transformer
* each time a sheet is shown. This choice is overridden by
* any view transformer passed to showWithSheetView().
*
* @param defaultViewTransformer The view transformer user by default.
*/
public void setDefaultViewTransformer(ViewTransformer defaultViewTransformer);
/**
* Enable or disable dimming of the content view while a
* sheet is presented. If enabled a transparent black dim
* is overlaid on top of the content view indicating that
* the sheet is the foreground view. This dim is animated
* into place is coordination with the sheet view. Defaults to true.
*
* @param shouldDimContentView whether or not to dim the content view.
*/
public void setShouldDimContentView(boolean shouldDimContentView);
/**
* @return whether the content view is being dimmed while
* presenting a sheet or not.
*/
public boolean shouldDimContentView();
/**
* Enable or disable the use of a hardware layer for the
* presented sheet while animating. This settings defaults
* to true and should only be changed if you know that
* putting the sheet in a layer will negatively effect
* performance. One such example is if the sheet contains
* a view which needs to frequently be re-drawn.
*
* @param useHardwareLayerWhileAnimating whether or not to use a hardware layer.
*/
public void setUseHardwareLayerWhileAnimating(boolean useHardwareLayerWhileAnimating);
/**
* Add a OnSheetStateChangeListener which will be notified
* when the state of the presented sheet changes.
* The listener will not be automatically removed,
* so remember to remove it when it's no longer need (probably when the sheet is HIDDEN)
*
*
* @param onSheetStateChangeListener the listener to be notified.
*/
public void addOnSheetStateChangeListener(OnSheetStateChangeListener onSheetStateChangeListener);
/**
* Removes a previously added {@link OnSheetStateChangeListener}.
*
* @param onSheetStateChangeListener the listener to be removed.
*/
public void removeOnSheetStateChangeListener(@NonNull OnSheetStateChangeListener onSheetStateChangeListener);
/**
* Adds an {@link OnSheetDismissedListener} which will be notified when the state of the presented sheet changes.
*
* @param onSheetDismissedListener the listener to be notified.
*/
public void addOnSheetDismissedListener(@NonNull OnSheetDismissedListener onSheetDismissedListener);
/**
* Removes a previously added {@link OnSheetDismissedListener}.
*
* @param onSheetDismissedListener the listener to be removed.
*/
public void removeOnSheetDismissedListener(@NonNull OnSheetDismissedListener onSheetDismissedListener);
/**
* Called when the presented sheet has been dismissed.
*
* @param bottomSheet The bottom sheet which contained
* the presented sheet.
*/
void onDismissed(BottomSheet bottomSheet);
/**
* Called on every frame while animating the presented
* sheet. This method allows you to coordinate other
* animations (usually on the content view) with the
* sheet view's translation.
*
* @param translation The current translation of the
* presented sheet view.
* @param maxTranslation The max translation of the
* presented sheet view.
* @param peekedTranslation The peeked state translation
* of the presented sheet view.
* @param parent The BottomSheet presenting the sheet view.
* @param view The content view to transform.
*/
void transformView(float translation, float maxTranslation, float peekedTranslation, BottomSheetLayout parent, View view);
/**
* Called on when the translation of the sheet view
* changes allowing you to customize the amount of dimming which
* is applied to the content view.
*
* @param translation The current translation of the presented sheet view.
* @param maxTranslation The max translation of the presented sheet view.
* @param peekedTranslation The peeked state translation of the presented sheet view.
* @param parent The BottomSheet presenting the sheet view.
* @param view The content view to transform.
*
* @return The alpha to apply to the dim overlay.
*/
float getDimAlpha(float translation, float maxTranslation, float peekedTranslation, BottomSheetLayout parent, View view);