Search in sources :

Example 6 with BottomSheetBehavior

use of android.support.design.widget.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);
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) TextView(android.widget.TextView) View(android.view.View)

Example 7 with BottomSheetBehavior

use of android.support.design.widget.BottomSheetBehavior in project coins-android by bubelov.

the class MapActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    dependencies().inject(this);
    setContentView(R.layout.activity_map);
    ButterKnife.bind(this);
    drawerHeader = navigationView.getHeaderView(0);
    avatar = ButterKnife.findById(drawerHeader, R.id.avatar);
    userName = ButterKnife.findById(drawerHeader, R.id.user_name);
    googleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API).addApi(Auth.GOOGLE_SIGN_IN_API).addConnectionCallbacks(new LocationApiConnectionCallbacks()).enableAutoManage(this, connectionResult -> Toast.makeText(MapActivity.this, connectionResult.getErrorMessage(), Toast.LENGTH_SHORT).show()).build();
    googleApiClient.connect();
    firstLaunch = savedInstanceState == null;
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    bottomSheetBehavior = BottomSheetBehavior.from(placeDetails);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            placeDetails.setFullScreen(newState == BottomSheetBehavior.STATE_EXPANDED);
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            actionButton.setVisibility(slideOffset > 0.5f ? View.GONE : View.VISIBLE);
        }
    });
    new Handler(Looper.getMainLooper()).postDelayed(() -> bottomSheetBehavior.setPeekHeight(placeDetails.getHeaderHeight()), 1000);
    placeDetails.setCallback(new PlaceDetailsView.Callback() {

        @Override
        public void onEditPlaceClick(@NonNull Place place) {
            if (!TextUtils.isEmpty(userRepository.getUserAuthToken())) {
                EditPlaceActivity.Companion.startForResult(MapActivity.this, place.getId(), null, REQUEST_EDIT_PLACE);
            } else {
                signIn();
            }
        }

        @Override
        public void onDismissed() {
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        }
    });
    toolbar.setNavigationOnClickListener(v -> drawerLayout.openDrawer(navigationView));
    toolbar.inflateMenu(R.menu.map);
    toolbar.setOnMenuItemClickListener(this);
    navigationView.setNavigationItemSelectedListener(item -> {
        switch(item.getItemId()) {
            case R.id.action_exchange_rates:
                drawerLayout.closeDrawers();
                openExchangeRatesScreen();
                return true;
            case R.id.action_notification_area:
                drawerLayout.closeDrawers();
                openNotificationAreaScreen();
                return true;
            case R.id.action_chat:
                drawerLayout.closeDrawers();
                openChat();
                return true;
            case R.id.action_settings:
                drawerLayout.closeDrawers();
                openSettingsScreen();
                return true;
        }
        return false;
    });
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close);
    drawerLayout.addDrawerListener(drawerToggle);
    updateDrawerHeader();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Handler(android.os.Handler) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) PlaceDetailsView(com.bubelov.coins.ui.widget.PlaceDetailsView) View(android.view.View) TextView(android.widget.TextView) SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) PlaceDetailsView(com.bubelov.coins.ui.widget.PlaceDetailsView) Place(com.bubelov.coins.model.Place)

Aggregations

BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)7 View (android.view.View)5 TextView (android.widget.TextView)4 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)3 ImageView (android.widget.ImageView)3 DialogInterface (android.content.DialogInterface)2 AlertDialog (android.support.v7.app.AlertDialog)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 CompoundButton (android.widget.CompoundButton)2 EditText (android.widget.EditText)2 BindView (butterknife.BindView)2 SpringViewAnimatorManager (io.codetail.animation.SpringViewAnimatorManager)2 ViewRevealManager (io.codetail.animation.ViewRevealManager)2 File (java.io.File)2 Intent (android.content.Intent)1 Point (android.graphics.Point)1 MediaPlayer (android.media.MediaPlayer)1 Handler (android.os.Handler)1 NavigationView (android.support.design.widget.NavigationView)1