Java Code Examples for com.google.android.material.bottomsheet.BottomSheetBehavior#setPeekHeight()

The following examples show how to use com.google.android.material.bottomsheet.BottomSheetBehavior#setPeekHeight() . 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: ChatFragment.java    From Twire with GNU General Public License v3.0 7 votes vote down vote up
@Override
public void onMessageClicked(SpannableStringBuilder formattedMessage, final String userName, final String message) {
    View v = LayoutInflater.from(getContext()).inflate(R.layout.chat_message_options, null);
    bottomSheetDialog = new BottomSheetDialog(getContext());
    bottomSheetDialog.setContentView(v);
    final BottomSheetBehavior behavior = BottomSheetBehavior.from((View) v.getParent());
    behavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels / 3);

    bottomSheetDialog.setOnDismissListener(dialogInterface -> behavior.setState(BottomSheetBehavior.STATE_COLLAPSED));

    TextView mMessage = v.findViewById(R.id.text_chat_message);
    TextView mMention = v.findViewById(R.id.text_mention);
    TextView mDuplicateMessage = v.findViewById(R.id.text_duplicate_message);

    mMessage.setText(formattedMessage);
    mMention.setOnClickListener(view -> {
        insertSendText("@" + userName);
        bottomSheetDialog.dismiss();
    });
    mDuplicateMessage.setOnClickListener(view -> {
        insertSendText(message);
        bottomSheetDialog.dismiss();
    });

    bottomSheetDialog.show();
}
 
Example 2
Source File: ChatFragment.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMessageClicked(SpannableStringBuilder formattedMessage, final String userName, final String message) {
	View v = LayoutInflater.from(getContext()).inflate(R.layout.chat_message_options, null);
	final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
	bottomSheetDialog.setContentView(v);
	final BottomSheetBehavior behavior = BottomSheetBehavior.from((View) v.getParent());
	behavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels/3);

	bottomSheetDialog.setOnDismissListener(dialogInterface -> behavior.setState(BottomSheetBehavior.STATE_COLLAPSED));

	TextView mMessage = v.findViewById(R.id.text_chat_message);
	TextView mMention = v.findViewById(R.id.text_mention);
	TextView mDuplicateMessage = v.findViewById(R.id.text_duplicate_message);

	mMessage.setText(formattedMessage);
	mMention.setOnClickListener(view -> {
		insertSendText("@" + userName);
		bottomSheetDialog.dismiss();
	});
	mDuplicateMessage.setOnClickListener(view -> {
		insertSendText(message);
		bottomSheetDialog.dismiss();
	});

	bottomSheetDialog.show();
}
 
Example 3
Source File: OpenWithFragment.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void show() {
    if (getContext().getResources().getBoolean(R.bool.is_tablet)) {
        final int peekHeight = getContext().getResources().getDimensionPixelSize(R.dimen.tablet_bottom_sheet_peekheight);

        BottomSheetBehavior<View> bsBehaviour = BottomSheetBehavior.from((View) contentView.getParent());
        bsBehaviour.setPeekHeight(peekHeight);
    }

    super.show();
}
 
Example 4
Source File: StreamFragment.java    From Twire with GNU General Public License v3.0 4 votes vote down vote up
private BottomSheetBehavior getDefaultBottomSheetBehaviour(View bottomSheetView) {
    BottomSheetBehavior behavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
    behavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels / 3);
    return behavior;
}
 
Example 5
Source File: BaseModalBottomSheet.java    From CommonUtils with Apache License 2.0 4 votes vote down vote up
@CallSuper
protected void attachedBehavior(@NonNull Context context, @NonNull BottomSheetBehavior<?> behavior) {
    behavior.setPeekHeight(getPeekHeight());
    behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    prepareCollapsed();
}
 
Example 6
Source File: StreamFragment.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
private BottomSheetBehavior getDefaultBottomSheetBehaviour(View bottomSheetView) {
    BottomSheetBehavior behavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
    behavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels / 3);
    return behavior;
}
 
Example 7
Source File: BindingAdapters.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("behavior_peekHeight")
public static void bindPeekHeight(View view, int peekHeight) {
    BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(view);
    behavior.setPeekHeight(peekHeight);
}