Java Code Examples for com.google.android.material.bottomsheet.BottomSheetBehavior#STATE_EXPANDED

The following examples show how to use com.google.android.material.bottomsheet.BottomSheetBehavior#STATE_EXPANDED . 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: TestRecyclerViewInNestedScrollViewActivity.java    From SmoothRefreshLayout with MIT License 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: TestRecyclerViewInNestedScrollViewInSrlActivity.java    From SmoothRefreshLayout with MIT License 6 votes vote down vote up
@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);
    }
}
 
Example 3
Source File: MapFragment.java    From nearby-android with Apache License 2.0 6 votes vote down vote up
/**
 * Set the menu options based on
 * the bottom sheet state
 *
 */
@Override
public final void onPrepareOptionsMenu(final Menu menu){
  final MenuItem listItem = menu.findItem(R.id.list_action);
  final MenuItem routeItem = menu.findItem(R.id.route_action);
  final MenuItem filterItem = menu.findItem(R.id.filter_in_map);


  if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
    listItem.setVisible(true);
    filterItem.setVisible(true);
    routeItem.setVisible(false);
  }else if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED){
    listItem.setVisible(false);
    filterItem.setVisible(true);
    routeItem.setVisible(true);
  }
}
 
Example 4
Source File: AbstractWidgetConfigActivity.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onBackPressed() {
    if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
        setBottomSheetState(true);
        return;
    }

    long time = System.currentTimeMillis();
    if (time - lastBackPressedTime < 2000) {
        super.onBackPressed();
        return;
    }

    lastBackPressedTime = time;
    SnackbarUtils.showSnackbar(this, getString(R.string.feedback_click_again_to_exit));
}
 
Example 5
Source File: OngoingCallActivity.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * To disable back button
 */
@Override
public void onBackPressed() {
    // In case the dialpad is opened, pressing the back button will close it
    if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);

    // You cant press the back button in order to get out of the call
}
 
Example 6
Source File: Pix.java    From PixImagePicker with Apache License 2.0 5 votes vote down vote up
@Override
public void onLongClick(Img img, View view, int position) {
    if (options.getCount() > 1) {
        Utility.vibe(Pix.this, 50);
        LongSelection = true;
        if ((selectionList.size() == 0) && (mBottomSheetBehavior.getState()
                != BottomSheetBehavior.STATE_EXPANDED)) {
            sendButton.setVisibility(View.VISIBLE);
            Animation anim = new ScaleAnimation(
                    0f, 1f, // Start and end values for the X axis scaling
                    0f, 1f, // Start and end values for the Y axis scaling
                    Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling
                    Animation.RELATIVE_TO_SELF, 0.5f); // Pivot point of Y scaling
            anim.setFillAfter(true); // Needed to keep the result of the animation
            anim.setDuration(300);
            sendButton.startAnimation(anim);
        }
        if (selectionList.contains(img)) {
            selectionList.remove(img);
            initaliseadapter.select(false, position);
            mainImageAdapter.select(false, position);
        } else {
            if (options.getCount() <= selectionList.size()) {
                Toast.makeText(Pix.this,
                        String.format(getResources().getString(R.string.selection_limiter_pix),
                                selectionList.size()), Toast.LENGTH_SHORT).show();
                return;
            }
            img.setPosition(position);
            selectionList.add(img);
            initaliseadapter.select(true, position);
            mainImageAdapter.select(true, position);
        }
        selection_check.setVisibility(View.GONE);
        topbar.setBackgroundColor(colorPrimaryDark);
        selection_count.setText(selectionList.size() + " " + getResources().getString(R.string.pix_selected));
        img_count.setText(String.valueOf(selectionList.size()));
        DrawableCompat.setTint(selection_back.getDrawable(), Color.parseColor("#ffffff"));
    }
}
 
Example 7
Source File: BaseLibraryActivity.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    BottomSheetBehavior<View> bottomSheet = BottomSheetBehavior.from(mBinding.miniplayerHolder);
    boolean expanded = bottomSheet.getState() == BottomSheetBehavior.STATE_EXPANDED;
    outState.putBoolean(KEY_WAS_NOW_PLAYING_EXPANDED, expanded);
}
 
Example 8
Source File: MoodleAssignmentsActivity.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onBackPressed() {
    if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    else
        super.onBackPressed();
}
 
Example 9
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@Override public boolean onOptionsItemSelected(MenuItem item) {
  if (item.getItemId() == R.id.action_show_layer_list) {
    // if bottom sheet is not shown
    if (mBottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
      // show bottom sheet
      mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
      // hide bottom sheet
      mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    }
    return true;
  }
  return super.onOptionsItemSelected(item);
}
 
Example 10
Source File: MoodleAssignmentsActivity.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    boolean bSShown = bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
    outState.putBoolean(SHOW_BS_KEY, bSShown);

    super.onSaveInstanceState(outState);
}
 
Example 11
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@Override public boolean onOptionsItemSelected(MenuItem item) {
  if (item.getItemId() == R.id.action_show_layer_list) {
    // if bottom sheet is not shown
    if (mBottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
      // show bottom sheet
      mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
      // hide bottom sheet
      mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    }
    return true;
  }
  return super.onOptionsItemSelected(item);
}
 
Example 12
Source File: BaseLibraryActivityViewModel.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Bindable
public Drawable getNowPlayingContentBackground() {
    if (mBottomSheetState == BottomSheetBehavior.STATE_EXPANDED) {
        return null;
    } else {
        return mNowPlayingBackground;
    }
}
 
Example 13
Source File: BaseLibraryActivityViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Bindable
public int getMiniplayerVisibility() {
    return (mBottomSheetState == BottomSheetBehavior.STATE_EXPANDED)
            ? View.GONE
            : View.VISIBLE;
}
 
Example 14
Source File: BaseLibraryActivityViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Bindable
public int getMainContentVisibillity() {
    return (mBottomSheetState == BottomSheetBehavior.STATE_EXPANDED)
            ? View.GONE
            : View.VISIBLE;
}
 
Example 15
Source File: LoginSignUpFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public boolean bottomSheetIsExpanded() {
  return bottomSheetBehavior != null
      && bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
}
 
Example 16
Source File: JoinCodeFragment.java    From zephyr with MIT License 4 votes vote down vote up
@Override
protected int getInitialBottomSheetState() {
    return BottomSheetBehavior.STATE_EXPANDED;
}
 
Example 17
Source File: DebugFragment.java    From zephyr with MIT License 4 votes vote down vote up
@Override
protected int getInitialBottomSheetState() {
    return BottomSheetBehavior.STATE_EXPANDED;
}
 
Example 18
Source File: WhatsNewFragment.java    From zephyr with MIT License 4 votes vote down vote up
@Override
protected int getInitialBottomSheetState() {
    return BottomSheetBehavior.STATE_EXPANDED;
}
 
Example 19
Source File: PrivacyFragment.java    From zephyr with MIT License 4 votes vote down vote up
@Override
protected int getInitialBottomSheetState() {
    return BottomSheetBehavior.STATE_EXPANDED;
}
 
Example 20
Source File: MenuFragment.java    From zephyr with MIT License 4 votes vote down vote up
@Override
protected int getInitialBottomSheetState() {
    return BottomSheetBehavior.STATE_EXPANDED;
}