Java 类android.support.design.widget.BottomSheetBehavior 实例源码

项目:referendum_1o_android    文件:VoteFragment.java   
public void showColegiElectoralData(final ColegiElectoral colegiElectoral) {
    LatLng latLng = new LatLng(colegiElectoral.getLat(), colegiElectoral.getLon());
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16);
    mGoogleMap.animateCamera(cameraUpdate);

    txtNomLocal.setText(colegiElectoral.getLocal());
    txtAdresa.setText(colegiElectoral.getAdresa());
    txtLocalitat.setText(colegiElectoral.getMunicipi());
    txtDistricte.setText(colegiElectoral.getDistricte() != null ? StringsManager.getString("data_districte", colegiElectoral.getDistricte()) : "");
    txtSeccio.setText(colegiElectoral.getSeccio() != null ? StringsManager.getString("data_seccio", colegiElectoral.getSeccio()) : "");
    txtMesa.setText(colegiElectoral.getMesa() != null ? StringsManager.getString("data_mesa", colegiElectoral.getMesa()) : "");

    icnCalendari.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            addEventToCalendar(colegiElectoral);
        }
    });

    bsb.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:TodoRealm    文件:AddListDialogFragment.java   
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    switch (newState) {
        case BottomSheetBehavior.STATE_HIDDEN: {
            LogUtils.d("Bottom sheet hidden to dismiss");
            dismiss();
            break;
        }
        case BottomSheetBehavior.STATE_EXPANDED: {
            LogUtils.d("expanded");
            break;
        }
        case BottomSheetBehavior.STATE_COLLAPSED: {
            LogUtils.d("collapsed");
            break;
        }

    }

}
项目:TodoRealm    文件:AddListDialogFragment.java   
@Override
public void setupDialog(Dialog dialog, int style) {
    LogUtils.footPrint();
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.fragment_add_list_dialog, null);
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = params.getBehavior();

    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        BottomSheetBehavior bottomSheetBehavior = ((BottomSheetBehavior) behavior);
        bottomSheetBehavior.setBottomSheetCallback(bottomSheetBehaviorCallback);
    }

    ButterKnife.bind(this, contentView);

    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }

    presenter = new AddListPresenter(TodoRepository.getInstance());
    presenter.attachView(this);
}
项目:africastalking-android    文件:BaseActivity.java   
protected void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
    hideKeyboard();
    AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
    AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
    AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
    if (error) {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
    } else {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
    }

    infoHeader.setText(header);
    infoDesc.setText(desc);
    if (drawable != null)
        infoImg.setImageDrawable(drawable);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:Farmacias    文件:MapTabFragment.java   
private void handleNoResults(CustomCameraUpdate cameraUpdate) {
    mMap.moveCamera(cameraUpdate.getmCameraUpdate());
    mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    ArrayList<LatLng> list = new ArrayList<LatLng>();
    list.add(new LatLng(39.63108, -7.62451));
    list.add(new LatLng(37.92687, -7.59155));
    list.add(new LatLng(37.92687, -4.52637));
    list.add(new LatLng(40.41768, -4.63623));
    list.add(new LatLng(40.54929, -6.97083));
    list.add(new LatLng(39.63108, -7.62451));
    list.add(new LatLng(37.92687, -7.59155));
    list.add(new LatLng(37.92687, -4.52637));
    String message;
    if (Utils.contains(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()), list)) {
        message = getString(R.string.mtf_radio_busqueda_insuficiente);
        // Snackbar.make(mRootView,message,Snackbar.LENGTH_INDEFINITE).show();
    } else {
        message = getString(R.string.mtf_fuera_de_extremadura);
    }

    mSnackBar = new SnackBarWrapper(getActivity(),message,Snackbar.LENGTH_INDEFINITE);
    mSnackBar.show();

    //Snackbar.make(mRootView, message, Snackbar.LENGTH_INDEFINITE).show();
}
项目:CoordinatorLayoutExample-master    文件:ToolBarSampleSnar.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_first);
    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    mRlBottomSheet = (RelativeLayout) findViewById(R.id.rl_bottom_sheet);
    mFrom = BottomSheetBehavior.from(mRlBottomSheet);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    // 该属性必须在setSupportActionBar之前 调用
    mToolbar.setTitle("toolBar");
    setSupportActionBar(mToolbar);

    initListener();
    initData();
}
项目:login    文件:BottomSheetMenuDialog.java   
@Override
public void onStateChanged(@NonNull View bottomSheet,
                           @BottomSheetBehavior.State int newState) {
    if (mCallback != null) {
        mCallback.onStateChanged(bottomSheet, newState);
    }

    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);
        }
    }
}
项目:whatanime-android    文件:MainActivity.java   
private void setupViews() {
    drawer = (DrawerLayout) findViewById(R.id.drawerlayout);
    navview = (NavigationView) findViewById(R.id.navview);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.main_drawer_open, R.string.main_drawer_close);
    //drawer.addDrawerListener(this);
    toggle.syncState();
    navview.setNavigationItemSelectedListener(this);

    View _view = findViewById(R.id.bottom_search_results);
    resultsBottom = BottomSheetBehavior.from(_view);
    resultsBottom.setHideable(true);
    resultsBottom.setState(BottomSheetBehavior.STATE_HIDDEN);
    resultsRv = (RecyclerView) findViewById(R.id.rv_results);
    resultsRv.setLayoutManager(new LinearLayoutManager(MainActivity.this,
            LinearLayoutManager.VERTICAL, false));
    photoIv = (SquareImageView) findViewById(R.id.iv_photo);
    searchFab = (FloatingActionButton) findViewById(R.id.fab_search);
    closeBottomBtn = (AppCompatImageButton) findViewById(R.id.btn_close_bottom);
    indicatorLoadingLayout = (LinearLayout) findViewById(R.id.layout_main_loading);
    indicatorStatusTv = (AppCompatTextView) findViewById(R.id.tv_progress_status);
    AppCompatTextView versionAppTv = navview.getHeaderView(0).findViewById(R.id.tv_header_app_version);
    versionAppTv.setText(C.getAppVersion(MainActivity.this));
}
项目:MusicX-music-player    文件:Playing3Fragment.java   
@Override
protected void ui(View rootView) {
    albumArt = (ImageView) rootView.findViewById(R.id.albumArt);
    queuerv = (RecyclerView) rootView.findViewById(R.id.commonrv);
    favButton = (ImageButton) rootView.findViewById(R.id.action_favorite);
    moreMenu = (ImageButton) rootView.findViewById(R.id.menu_button);
    shuffleButton = (ImageView) rootView.findViewById(R.id.shuffle_song);
    repeatButton = (ImageView) rootView.findViewById(R.id.repeat_song);
    playpausebutton = (ImageView) rootView.findViewById(R.id.play_pause_toggle);
    next = (ImageView) rootView.findViewById(R.id.next);
    prev = (ImageView) rootView.findViewById(R.id.prev);
    currentDur = (TextView) rootView.findViewById(R.id.currentDur);
    totalDur = (TextView) rootView.findViewById(R.id.totalDur);
    songArtist = (TextView) rootView.findViewById(R.id.song_artist);
    songTitle = (TextView) rootView.findViewById(R.id.song_title);
    seekbar = (SeekBar) rootView.findViewById(R.id.seekbar);
    lrcView = (TextView) rootView.findViewById(R.id.lyrics);
    bottomsheetLyrics = (FrameLayout) rootView.findViewById(R.id.bottomsheetLyrics);
    bottomSheetBehavior = BottomSheetBehavior.from(bottomsheetLyrics);
    diagonalLayout = (DiagonalLayout) rootView.findViewById(R.id.diagonalLayout);
}
项目:Mix    文件:BottomSheetActivity.java   
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btn_bottom_dialog_control:
            if (mBottomSheetDialog.isShowing()) {
                mBottomSheetDialog.dismiss();
            } else {
                mBottomSheetDialog.show();
            }
            break;
        case R.id.btn_bottom_sheet_control:
            //如果当前是收缩状态,变为延展状态;反之亦然

            if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
                mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            } else if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
                mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            }
            break;
        default:
            break;
    }
}
项目:bigjpg-app    文件:MainActivity.java   
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    if (savedInstanceState == null) {
        if (imgUri != null) { // 外部APP请求处理
            showImg(imgUri);
            tvAction.setEnabled(imgUri != null);
            return;
        }
        // 面板动画
        viewHintIcon.setAlpha(0);
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        tvAction.postDelayed(new Runnable() {
            @Override
            public void run() {
                collapsePanel();
            }
        }, 800);
    } else { // 屏幕方向旋转
        imgUri = savedInstanceState.getParcelable("imgUri");
        showImg(imgUri);
        tvAction.setEnabled(imgUri != null);
    }
}
项目:Android-Multi-Theme-UI    文件:ScrollingActivity.java   
@Override
public void onClick(View view) {
    switch (view.getId()){
        case R.id.theme_selected :
        case R.id.fab:
            // change the state of the bottom sheet
            switch (mBottomSheetBehavior.getState()){
                case BottomSheetBehavior.STATE_HIDDEN :
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                    break;

                case BottomSheetBehavior.STATE_COLLAPSED :
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                    break;

                case BottomSheetBehavior.STATE_EXPANDED :
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                    break;
            }
            break;
    }
}
项目:mvvm-template    文件:BaseBottomSheetDialog.java   
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
    LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
    View view = themeAwareInflater.inflate(layoutRes(), container, false);
    unbinder = ButterKnife.bind(this, view);
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            View parent = getDialog().findViewById(R.id.design_bottom_sheet);
            if (parent != null) {
                bottomSheetBehavior = BottomSheetBehavior.from(parent);
                if (bottomSheetBehavior != null) {
                    bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                }
            }
        }
    });
    return view;
}
项目:anitrend-app    文件:BottomSheetMessage.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog mSheet = super.onCreateDialog(savedInstanceState);
    View contentView = View.inflate(getContext(), R.layout.bottom_sheet_message, null);
    mSheet.setContentView(contentView);

    unbinder = ButterKnife.bind(this, mSheet);

    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = params.getBehavior();

    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        bottomSheetBehavior = (BottomSheetBehavior) behavior;
        bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }

    onPostCreate(this);
    return mSheet;
}
项目:anitrend-app    文件:BottomSheetMessage.java   
@Override
public void onStart() {
    super.onStart();
    mState.setOnClickListener(this);

    if(negative == 0)
        mNegative.setVisibility(View.GONE);
    else {
        mNegative.setOnClickListener(this);
        mNegative.setText(negative);
    }

    if(positive == 0)
        mPositive.setVisibility(View.GONE);
    else {
        mPositive.setOnClickListener(this);
        mPositive.setText(positive);
    }

    mTitle.setText(title);
    mText.setMovementMethod(LinkMovementMethod.getInstance());
    mText.setText(Html.fromHtml(getString(text)));
    if(bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED)
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:CoordinatorLayoutExample-master    文件:BottomSheetActivity.java   
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btnBehavior:
            int state = behavior.getState();
            if (state == BottomSheetBehavior.STATE_EXPANDED) {
                behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            } else if(state == BottomSheetBehavior.STATE_COLLAPSED){
                behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
            }else if(state == BottomSheetBehavior.STATE_HIDDEN){
                behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            }
            break;
        case R.id.btnDialog:
            BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
            bottomSheetDialog.setContentView(R.layout.include_bottom_sheet_layout);
            bottomSheetDialog.show();
            break;
        case R.id.btn_baidumap:
            readyGo(BaiduMapSample.class);
            break;
    }
}
项目:BottomSheetMenu    文件:BottomSheetMenu.java   
@SuppressLint("InflateParams")
private BottomSheetMenu(@NonNull Context context, BottomSheetMenuListener bottomSheetMenuListener) {
    super(context);
    mIconSize = context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_menu_item_icon_size);
    mBottomSheetMenuListener = bottomSheetMenuListener;

    setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            BottomSheetDialog d = (BottomSheetDialog) dialog;
            FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);

            if (bottomSheet != null) {
                BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
            }
        }
    });
}
项目:anitrend-app    文件:BottomSheetUsers.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog mSheet = super.onCreateDialog(savedInstanceState);
    View contentView = View.inflate(getContext(), R.layout.bottom_sheet_recycler, null);
    mSheet.setContentView(contentView);

    unbinder = ButterKnife.bind(this, mSheet);

    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = params.getBehavior();

    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        bottomSheetBehavior = (BottomSheetBehavior) behavior;
        bottomSheetBehavior.setPeekHeight(ScreenUtil.dip2px(getContext(), PEEK_HEIGHT));
        bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }

    mToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
    mToolbar.setNavigationOnClickListener(this);

    onPostCreate(this);
    return mSheet;
}
项目:anitrend-app    文件:MainActivity.java   
@Override
public void onBackPressed() {
    if (mDrawer.isDrawerOpen(GravityCompat.START))
        mDrawer.closeDrawer(GravityCompat.START);
    else if(mFilterBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
        mFilterBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    else if(!isClosing) {
        isClosing = true;
        mPresenter.createSuperToast(MainActivity.this,
                getString(R.string.text_confirm_exit),
                R.drawable.ic_info_outline_white_18dp,
                Style.TYPE_STANDARD, Style.DURATION_MEDIUM,
                PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_TEAL));
    }
    else
        super.onBackPressed();
}
项目:anitrend-app    文件:ComposerActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            break;
        case R.id.action_attach:
            mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            break;
        case R.id.action_send:
            if(!TextUtils.isEmpty(editText.getText())) {
                ImeAction.hideSoftKeyboard(this);
                startAction();
            } else
                Toast.makeText(this, R.string.warning_empty_input, Toast.LENGTH_SHORT).show();
            break;
        case R.id.action_preview:
            toggleModes();
            break;
    }
    return super.onOptionsItemSelected(item);
}
项目:anitrend-app    文件:ComposerActivity.java   
/**
 * Take care of popping the fragment back stack or finishing the activity
 * as appropriate.
 */
@Override
public void onBackPressed() {
    if(mBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
        mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    else if(editText.hasFocus())
        editText.clearFocus();
    else if(!isClosing) {
        isClosing = true;
        mPresenter.createSuperToast(ComposerActivity.this,
                getString(R.string.text_confirm_exit),
                R.drawable.ic_info_outline_white_18dp,
                Style.TYPE_STANDARD, Style.DURATION_MEDIUM,
                PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_TEAL));
    }
    else
        super.onBackPressed();
}
项目:anitrend-app    文件:UserReplyActivity.java   
private void onInit() {
    mCurrentUser = mPresenter.getCurrentUser();
    loaderManager = getLoaderManager();
    swipeRefreshLayout.setOnRefreshListener(this);
    recyclerView.setHasFixedSize(true); //originally set to fixed size true
    recyclerView.setNestedScrollingEnabled(false); //set to false if somethings fail to work properly
    mLayoutManager = new StaggeredGridLayoutManager(getResources().getInteger(R.integer.card_col_size_home), StaggeredGridLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(mLayoutManager);
    mActivityOrigin.setHasFixedSize(true);
    mActivityOrigin.setNestedScrollingEnabled(false);

    View bottomSheet = new BottomSheetBuilder(this, coordinatorLayout)
            .setMode(BottomSheetBuilder.MODE_GRID)
            .setBackgroundColorResource(R.color.colorDarkKnight)
            .setItemTextColorResource(R.color.white)
            .setMenu(R.menu.menu_attachments)
            .setItemClickListener(this).createView();

    mBehavior = BottomSheetBehavior.from(bottomSheet);
    mBehavior.setBottomSheetCallback(null);
    updateUI();
}
项目:Luhn    文件:Luhn.java   
private void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
    hideKeyboard();
    AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
    AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
    AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
    if (error) {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
    } else {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
    }

    infoHeader.setText(header);
    infoDesc.setText(desc);
    if (drawable != null)
        infoImg.setImageDrawable(drawable);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:CoordinatorLayoutExample-master    文件:BottomSheetActivity.java   
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btnBehavior:
            int state = behavior.getState();
            if (state == BottomSheetBehavior.STATE_EXPANDED) {
                behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            } else if(state == BottomSheetBehavior.STATE_COLLAPSED){
                behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
            }else if(state == BottomSheetBehavior.STATE_HIDDEN){
                behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            }
            break;
        case R.id.btnDialog:
            BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
            bottomSheetDialog.setContentView(R.layout.include_bottom_sheet_layout);
            bottomSheetDialog.show();
            break;
    }
}
项目:GitHub    文件:BoxingBottomSheetActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_boxing_bottom_sheet);
    createToolbar();

    FrameLayout bottomSheet = (FrameLayout) findViewById(R.id.content_layout);
    mBehavior = BottomSheetBehavior.from(bottomSheet);
    mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);

    mImage = (ImageView) findViewById(R.id.media_result);
    mImage.setOnClickListener(this);
}
项目:firefox-tv    文件:OpenWithFragment.java   
@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();
}
项目:AmenEye    文件:MainActivity.java   
@Override
    public void onBackPressed() {
//        super.onBackPressed();//不用父方法
//        Intent intent = new Intent(Intent.ACTION_MAIN);
//        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//        intent.addCategory(Intent.CATEGORY_HOME);
//        startActivity(intent);

        if (drawerOpen) {
            mDrawerLayout.closeDrawers();
            return;
        }

        if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
            mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }

        RxBus.getDefault().postWithCode(RxConstants.BACK_PRESSED_CODE, RxConstants.BACK_PRESSED_DATA);
        long secondTime = System.currentTimeMillis();
        if (secondTime - firstTime > 1500) {
            showLongToast(this, getString(R.string.back_again_exit));
            firstTime = secondTime;
        } else {
            System.exit(0);
        }

    }
项目:GitHub    文件:BoxingBottomSheetActivity.java   
private void toggleBottomSheet() {
    if (mBehavior == null) {
        return;
    }
    if (mBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    } else {
        mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    }
}
项目:GitHub    文件:SecondActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    createToolbar();
    findViewById(R.id.inside_bs_btn).setOnClickListener(this);
    mResultImg = (ImageView) findViewById(R.id.media_result);
    mResultImg.setOnClickListener(this);
    mInsideBottomSheet = (FrameLayout) findViewById(R.id.content_layout);
    BoxingBottomSheetFragment fragment = (BoxingBottomSheetFragment) getSupportFragmentManager().
            findFragmentByTag(BoxingBottomSheetFragment.TAG);
    if (fragment == null) {
        fragment = BoxingBottomSheetFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(R.id.content_layout, fragment, BoxingBottomSheetFragment.TAG).commit();

        BoxingConfig singleImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG);
        Boxing.of(singleImgConfig).setupFragment(fragment, new Boxing.OnBoxingFinishListener() {

            @Override
            public void onBoxingFinish(Intent intent, List<BaseMedia> medias) {
                BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
                behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
                if (medias != null && medias.size() > 0) {
                    BaseMedia media = mMedia = medias.get(0);
                    String path = media.getPath();
                    BoxingMediaLoader.getInstance().displayRaw(mResultImg, path, 1080, 720, null);
                }
            }
        });
    } else {
        fragment.setPresenter(new PickerPresenter(fragment));
    }
}
项目:GitHub    文件:SecondActivity.java   
private void showFragment() {
    if (mInsideBottomSheet != null) {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
        if (behavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
            behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        } else {
            behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        }
    }
}
项目:CoordinatorLayoutExample-master    文件:BottomSheetActivity.java   
@Override
protected void initView() {
    setOnClickListener(this, R.id.btnBehavior, R.id.btnDialog,R.id.btn_baidumap);

    View bottomSheet = findViewById(R.id.bottom_sheet);
    if (bottomSheet != null) {
        behavior = BottomSheetBehavior.from(bottomSheet);
        behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }
}
项目:adyo-android    文件:FilterFragment.java   
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
项目:boxing    文件:BoxingBottomSheetActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_boxing_bottom_sheet);
    createToolbar();

    FrameLayout bottomSheet = (FrameLayout) findViewById(R.id.content_layout);
    mBehavior = BottomSheetBehavior.from(bottomSheet);
    mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);

    mImage = (ImageView) findViewById(R.id.media_result);
    mImage.setOnClickListener(this);
}
项目:boxing    文件:BoxingBottomSheetActivity.java   
private boolean hideBottomSheet() {
    if (mBehavior != null && mBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        return true;
    }
    return false;
}
项目:boxing    文件:BoxingBottomSheetActivity.java   
private boolean collapseBottomSheet() {
    if (mBehavior != null && mBehavior.getState() != BottomSheetBehavior.STATE_COLLAPSED) {
        mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        return true;
    }
    return false;
}
项目:boxing    文件:BoxingBottomSheetActivity.java   
private void toggleBottomSheet() {
    if (mBehavior == null) {
        return;
    }
    if (mBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    } else {
        mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    }
}
项目:boxing    文件:SecondActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    createToolbar();
    findViewById(R.id.inside_bs_btn).setOnClickListener(this);
    mResultImg = (ImageView) findViewById(R.id.media_result);
    mResultImg.setOnClickListener(this);
    mInsideBottomSheet = (FrameLayout) findViewById(R.id.content_layout);
    BoxingBottomSheetFragment fragment = (BoxingBottomSheetFragment) getSupportFragmentManager().
            findFragmentByTag(BoxingBottomSheetFragment.TAG);
    if (fragment == null) {
        fragment = BoxingBottomSheetFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(R.id.content_layout, fragment, BoxingBottomSheetFragment.TAG).commit();

        BoxingConfig singleImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG)
                .withMediaPlaceHolderRes(R.drawable.ic_boxing_default_image).withAlbumPlaceHolderRes(R.drawable.ic_boxing_default_image);
        Boxing.of(singleImgConfig).setupFragment(fragment, new Boxing.OnBoxingFinishListener() {

            @Override
            public void onBoxingFinish(Intent intent, List<BaseMedia> medias) {
                BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
                behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
                if (medias != null && medias.size() > 0) {
                    BaseMedia media = mMedia = medias.get(0);
                    String path = media.getPath();
                    BoxingMediaLoader.getInstance().displayRaw(mResultImg, path, 1080, 720, null);
                }
            }
        });
    } else {
        fragment.setPresenter(new PickerPresenter(fragment));
    }
}
项目:boxing    文件:SecondActivity.java   
private void showFragment() {
    if (mInsideBottomSheet != null) {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
        if (behavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
            behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        } else {
            behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        }
    }
}
项目:Farmacias    文件:MapTabFragment.java   
@Override
public void onMapClick(LatLng latLng) {
    Projection projection = mMap.getProjection();
    Point point = projection.toScreenLocation(latLng);

    Rect rect = new Rect();
    bottomSheet.getGlobalVisibleRect(rect);
    if (!rect.contains(point.x, point.y)) {
        Utils.logD(LOG_TAG, "outside bottom sheet");
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }
}
项目:Farmacias    文件:MapTabFragment.java   
@Override
public boolean collapseBottomSheet() {
    if (isBottomSheetExpanded()) {
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        return true;
    }
    return false;
}