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

The following examples show how to use com.google.android.material.bottomsheet.BottomSheetBehavior#STATE_HIDDEN . 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: BottomSheetMenuDialog.java    From SimplicityBrowser with MIT License 6 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet,
                           @BottomSheetBehavior.State int newState) {

    if (mCallback != null) {
        mCallback.onStateChanged(bottomSheet, newState);
    }

    //noinspection WrongConstant
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setBottomSheetCallback(null);
        try {
            BottomSheetMenuDialog.super.dismiss();
        } catch (IllegalArgumentException e) {
            // Ignore exception handling
        }

        // User dragged the sheet.
        if (!mClicked && !mRequestDismiss && !mRequestCancel && mOnCancelListener != null) {
            mOnCancelListener.onCancel(BottomSheetMenuDialog.this);
        }
    }
}
 
Example 2
Source File: BaseModalBottomSheet.java    From CommonUtils with Apache License 2.0 6 votes vote down vote up
@Override
@CallSuper
public void onStateChanged(@NonNull View bottomSheet, @BottomSheetBehavior.State int newState) {
    BaseModalBottomSheet.this.bottomSheet = bottomSheet;

    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismissAllowingStateLoss();
        return;
    }

    heightChanged();

    if (newState == BottomSheetBehavior.STATE_COLLAPSED)
        prepareCollapsed();

    if (newState == BottomSheetBehavior.STATE_DRAGGING && hasNoScroll)
        restoreNotCollapsed();
}
 
Example 3
Source File: LiveObjectDetectionActivity.java    From mlkit-material-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onBackPressed() {
  if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) {
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
  } else {
    super.onBackPressed();
  }
}
 
Example 4
Source File: BottomAppBarMainDemoFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onBackPressed() {
  if (bottomDrawerBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) {
    bottomDrawerBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    return true;
  }
  return false;
}
 
Example 5
Source File: MainActivity.java    From Status with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (resetItem != null) {
        if (adapter.getItem(position) instanceof AppPreferenceFragment) {
            fab.show();
            resetItem.setVisible(true);
        } else {
            fab.hide();
            resetItem.setVisible(false);
        }
    }

    if (behavior != null && behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        switch (position) {
            case 1:
                if (StaticUtils.shouldShowTutorial(this, "disableicon")) {
                    setTutorial(R.string.tutorial_icon_switch, R.string.tutorial_icon_switch_desc, null, false);
                } else if (StaticUtils.shouldShowTutorial(this, "moveicon", 1)) {
                    setTutorial(R.string.tutorial_icon_order, R.string.tutorial_icon_order_desc, null, false);
                }
                break;
            case 2:
                if (StaticUtils.shouldShowTutorial(this, "activities")) {
                    setTutorial(R.string.tutorial_activities, R.string.tutorial_activities_desc, null, false);
                }
                break;
        }
    }
}
 
Example 6
Source File: BottomSheetUserDialogFragment.java    From intra42 with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
 
Example 7
Source File: MainActivity.java    From youtube-dl-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBackPressed() {
    if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        super.onBackPressed();
    }
    else {
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    }
}
 
Example 8
Source File: MoodleAssignmentsActivity.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN)
        openAssignmentFab.setVisibility(View.VISIBLE);
}
 
Example 9
Source File: StickerBSFragment.java    From PhotoEditor with MIT License 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
 
Example 10
Source File: EmojiBSFragment.java    From PhotoEditor with MIT License 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
 
Example 11
Source File: HomeScreenFragment.java    From ground-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onBack() {
  if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
    return false;
  } else {
    hideBottomSheet();
    return true;
  }
}
 
Example 12
Source File: MainActivity.java    From call_manage with MIT License 5 votes vote down vote up
public void updateButtons(int bottomSheetState) {
    if (bottomSheetState == BottomSheetBehavior.STATE_HIDDEN || bottomSheetState == BottomSheetBehavior.STATE_COLLAPSED) {
        showButtons(true);
        if (mViewPager.getCurrentItem() == 1) showView(mAddContactButton, true);
    } else {
        showButtons(false);
        if (mViewPager.getCurrentItem() == 1) showView(mAddContactButton, false);
    }
}
 
Example 13
Source File: EmojiBSFragment.java    From indigenous-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
 
Example 14
Source File: ViewFragment.java    From pandora with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (operableView.isSelectedEmpty()) {
        behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    } else {
        if (behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
            behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        }
    }
    targetView = v;
    refreshViewInfo(v);
}
 
Example 15
Source File: StaticObjectDetectionActivity.java    From mlkit-material-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onBackPressed() {
  if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) {
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
  } else {
    super.onBackPressed();
  }
}
 
Example 16
Source File: HomeScreenFragment.java    From ground-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
  if (newState == BottomSheetBehavior.STATE_HIDDEN) {
    viewModel.onBottomSheetHidden();
  }
}
 
Example 17
Source File: BottomSheetSlotsDialogFragment.java    From intra42 with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }
}
 
Example 18
Source File: MainActivity.java    From Status with Apache License 2.0 4 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    service.setOnCheckedChangeListener(null);
    service.setChecked((boolean) PreferenceData.STATUS_ENABLED.getValue(this) || StaticUtils.isStatusServiceRunning(this));
    service.setOnCheckedChangeListener(this);

    if (behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        if (!StaticUtils.isStatusServiceRunning(this) && StaticUtils.shouldShowTutorial(this, "enable")) {
            setTutorial(R.string.tutorial_enable, R.string.tutorial_enable_desc, () -> {
                if (service != null) service.setChecked(true);
            }, false);
        } else if (!StaticUtils.isAllPermissionsGranted(this)) {
            setTutorial(R.string.tutorial_missing_permissions, R.string.tutorial_missing_permissions_desc, () -> {
                List<String> permissions = new ArrayList<>();
                for (IconData icon : StatusServiceImpl.getIcons(MainActivity.this)) {
                    permissions.addAll(Arrays.asList(icon.getPermissions()));
                }

                StaticUtils.requestPermissions(MainActivity.this, permissions.toArray(new String[permissions.size()]));
            }, true);
        } else if (searchView != null && StaticUtils.shouldShowTutorial(MainActivity.this, "search", 1)) {
            setTutorial(R.string.tutorial_search, R.string.tutorial_search_desc, () -> {
                if (searchView != null) searchView.setIconified(false);
            }, false);
        } else if (tabLayout != null && viewPager != null && viewPager.getCurrentItem() != 3 && StaticUtils.shouldShowTutorial(MainActivity.this, "faqs", 2)) {
            setTutorial(R.string.tutorial_help, R.string.tutorial_help_desc, () -> {
                if (viewPager != null) viewPager.setCurrentItem(3);
            }, false);
        } else if (StaticUtils.shouldShowTutorial(MainActivity.this, "donate", 3)) {
            new AlertDialog.Builder(this)
                    .setTitle(R.string.tutorial_donate)
                    .setMessage(R.string.tutorial_donate_desc)
                    .setCancelable(false)
                    .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss())
                    .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                        MainActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(InfoUtils.SUPPORT_URL)));
                        dialog.dismiss();
                    })
                    .show();
        }
    }
}
 
Example 19
Source File: SelectAlbumBuilder.java    From leafpicrevived with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }
}
 
Example 20
Source File: CustomBottomSheetDialogFragment.java    From Weather with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }
}