use of com.google.android.material.bottomsheet.BottomSheetBehavior in project android by owncloud.
the class OCFileListFragment method registerFabUploadListeners.
/**
* registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
* on the Upload mini FAB for the linked action an {@link Snackbar} showing the underlying action.
*/
private void registerFabUploadListeners() {
getFabUpload().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final View uploadBottomSheet = getLayoutInflater().inflate(R.layout.upload_bottom_sheet_fragment, null);
final BottomSheetDialog dialog = new BottomSheetDialog(requireContext());
dialog.setContentView(uploadBottomSheet);
final BottomSheetFragmentItemView uploadFromFilesItemView = uploadBottomSheet.findViewById(R.id.upload_from_files_item_view);
BottomSheetFragmentItemView uploadFromCameraItemView = uploadBottomSheet.findViewById(R.id.upload_from_camera_item_view);
TextView uploadToTextView = uploadBottomSheet.findViewById(R.id.upload_to_text_view);
uploadFromFilesItemView.setOnTouchListener((v13, event) -> {
Intent action = new Intent(Intent.ACTION_GET_CONTENT);
action = action.setType(ALL_FILES_SAF_REGEX).addCategory(Intent.CATEGORY_OPENABLE);
action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
getActivity().startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS);
dialog.hide();
return false;
});
uploadFromCameraItemView.setOnTouchListener((v12, event) -> {
((FileDisplayActivity) getActivity()).getFilesUploadHelper().uploadFromCamera(FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA);
dialog.hide();
return false;
});
uploadToTextView.setText(String.format(getResources().getString(R.string.upload_to), getResources().getString(R.string.app_name)));
final BottomSheetBehavior uploadBottomSheetBehavior = BottomSheetBehavior.from((View) uploadBottomSheet.getParent());
dialog.setOnShowListener(dialog1 -> uploadBottomSheetBehavior.setPeekHeight(uploadBottomSheet.getMeasuredHeight()));
dialog.show();
getFabMain().collapse();
recordMiniFabClick();
}
});
getFabUpload().setOnLongClickListener(v -> {
showSnackMessage(R.string.actionbar_upload);
return true;
});
}
use of com.google.android.material.bottomsheet.BottomSheetBehavior in project SmoothRefreshLayout by dkzwm.
the class TestRecyclerViewInNestedScrollViewActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case Menu.FIRST:
LinearLayout linearLayout = findViewById(R.id.linearLayout_test_recyclerView_in_nestedScrollView);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(linearLayout);
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
use of com.google.android.material.bottomsheet.BottomSheetBehavior in project SmoothRefreshLayout by dkzwm.
the class TestRecyclerViewInNestedScrollViewInSrlActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case Menu.FIRST:
LinearLayout linearLayout = findViewById(R.id.linearLayout_test_recyclerView_in_nestedScrollView);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(linearLayout);
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
use of com.google.android.material.bottomsheet.BottomSheetBehavior in project simperium-android by Simperium.
the class LoginBottomSheetDialogFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View layout = inflater.inflate(R.layout.sheet_login, null);
AppCompatButton buttonEmail = layout.findViewById(R.id.button_email);
buttonEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mLoginSheetListener.onLoginSheetEmailClicked();
}
});
AppCompatButton buttonOther = layout.findViewById(R.id.button_other);
buttonOther.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mLoginSheetListener.onLoginSheetOtherClicked();
}
});
if (getDialog() != null) {
getDialog().setContentView(layout);
// Set peek height to full height of view (i.e. set STATE_EXPANDED) to avoid buttons
// being off screen when bottom sheet is shown.
getDialog().setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialogInterface;
FrameLayout bottomSheet = bottomSheetDialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
if (bottomSheet != null) {
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
behavior.setSkipCollapsed(true);
}
}
});
}
return super.onCreateView(inflater, container, savedInstanceState);
}
use of com.google.android.material.bottomsheet.BottomSheetBehavior in project Weather by Sparker0i.
the class CustomBottomSheetDialogFragment method setupDialog.
@Override
public void setupDialog(Dialog dialog, int style) {
// super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.dialog_modal, null);
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
}
Aggregations