Search in sources :

Example 1 with BottomSheetBehavior

use of android.support.design.widget.BottomSheetBehavior in project LeafPic by HoraApps.

the class SelectAlbumBuilder method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
    final RecyclerView mRecyclerView = contentView.findViewById(R.id.folders);
    final Spinner spinner = contentView.findViewById(R.id.storage_spinner);
    currentFolderPath = contentView.findViewById(R.id.bottom_sheet_sub_title);
    exploreModePanel = contentView.findViewById(R.id.ll_explore_mode_panel);
    imgExploreMode = contentView.findViewById(R.id.toggle_hidden_icon);
    theme = ThemeHelper.getInstanceLoaded(getContext());
    sdCardPath = StorageHelper.getSdcardPath(getContext());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, Measure.pxToDp(3, getContext()), true));
    adapter = new BottomSheetAlbumsAdapter();
    mRecyclerView.setAdapter(adapter);
    spinner.setAdapter(new VolumeSpinnerAdapter(contentView.getContext()));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
            switch(pos) {
                case INTERNAL_STORAGE:
                    displayContentFolder(Environment.getExternalStorageDirectory());
                    break;
                default:
                    // }
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    /**
     *SET UP THEME*
     */
    contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
    exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
    contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
    theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
    mRecyclerView.setBackgroundColor(theme.getBackgroundColor());
    fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
    fabDone.setBackgroundTintList(ColorStateList.valueOf(theme.getAccentColor()));
    fabDone.setImageDrawable(new IconicsDrawable(getContext()).icon(GoogleMaterial.Icon.gmd_done).color(Color.WHITE));
    fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
    fabDone.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
            onFolderSelected.folderSelected(currentFolderPath.getText().toString());
        }
    });
    ((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
    ((ThemedIcon) contentView.findViewById(R.id.create_new_folder_icon)).setColor(theme.getIconColor());
    contentView.findViewById(R.id.rl_create_new_folder).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final EditText editText = new EditText(getContext());
            AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
            insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
                    if (folderPath.mkdir())
                        displayContentFolder(folderPath);
                }
            });
            insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            insertTextDialog.show();
        }
    });
    contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!forzed) {
                toggleExplorerMode(!exploreMode);
                fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
            }
        }
    });
    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);
    }
    adapter.notifyDataSetChanged();
    toggleExplorerMode(exploreMode);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) EditText(android.widget.EditText) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ThemedIcon(org.horaapps.liz.ui.ThemedIcon) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) File(java.io.File) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 2 with BottomSheetBehavior

use of android.support.design.widget.BottomSheetBehavior in project Rocket by mozilla-tw.

the class TabTrayFragment method setupBottomSheetCallback.

private void setupBottomSheetCallback() {
    BottomSheetBehavior behavior = getBehavior(recyclerView);
    if (behavior == null) {
        return;
    }
    behavior.setBottomSheetCallback(new BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                dismiss();
            }
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            slideCoordinator.onSlide(slideOffset);
        }
    });
}
Also used : BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) BottomSheetCallback(android.support.design.widget.BottomSheetBehavior.BottomSheetCallback) View(android.view.View) WebView(android.webkit.WebView) TabView(org.mozilla.focus.tabs.TabView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 3 with BottomSheetBehavior

use of android.support.design.widget.BottomSheetBehavior in project Rocket by mozilla-tw.

the class ListPanelDialog method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_listpanel_dialog, container, false);
    scrollView = (NestedScrollView) v.findViewById(R.id.main_content);
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            final int pageSize = v.getMeasuredHeight();
            // When scrolled to end due to padding
            if (scrollY > oldScrollY && v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight() - scrollY < pageSize) {
                final PanelFragment pf = (PanelFragment) getChildFragmentManager().findFragmentById(R.id.main_content);
                if (pf != null && pf.isVisible()) {
                    new Thread(new Runnable() {

                        @Override
                        public void run() {
                            pf.tryLoadMore();
                        }
                    }).start();
                }
            }
        }
    });
    BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(scrollView);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                ListPanelDialog.this.dismiss();
            }
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
        }
    });
    v.findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    downloadsTouchArea = v.findViewById(R.id.downloads);
    downloadsTouchArea.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDownloads();
            TelemetryWrapper.showPanelDownload();
        }
    });
    historyTouchArea = v.findViewById(R.id.history);
    historyTouchArea.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showHistory();
            TelemetryWrapper.showPanelHistory();
        }
    });
    screenshotsTouchArea = v.findViewById(R.id.screenshots);
    screenshotsTouchArea.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showScreenshots();
            TelemetryWrapper.showPanelCapture();
        }
    });
    return v;
}
Also used : BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) NestedScrollView(android.support.v4.widget.NestedScrollView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 4 with BottomSheetBehavior

use of android.support.design.widget.BottomSheetBehavior in project AndroidStudy by tinggengyan.

the class BottomSheetSimpleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bottom_sheet_simple);
    NestedScrollView bottomSheet = (NestedScrollView) findViewById(R.id.bottomSheet);
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.floatingActionButton);
    final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
    // bottom sheet status callback
    bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
        }
    });
    floatingActionButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // switch the bottom sheet status
            // if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
            // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            // } else {
            // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            // }
            // display the fragment
            ModalBottomSheet modalBottomSheet = new ModalBottomSheet();
            modalBottomSheet.show(getSupportFragmentManager(), "bottom sheet");
        }
    });
}
Also used : BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) FloatingActionButton(android.support.design.widget.FloatingActionButton) NestedScrollView(android.support.v4.widget.NestedScrollView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 5 with BottomSheetBehavior

use of android.support.design.widget.BottomSheetBehavior in project ForPDA by RadiationX.

the class CustomBottomSheetDialogFragment method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    // super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.edit_post_reason, 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);
    }
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
        }
    });
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) DialogInterface(android.content.DialogInterface) View(android.view.View)

Aggregations

BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)17 View (android.view.View)14 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)9 TextView (android.widget.TextView)7 DialogInterface (android.content.DialogInterface)4 ImageView (android.widget.ImageView)4 Dialog (android.app.Dialog)3 RecyclerView (android.support.v7.widget.RecyclerView)3 NestedScrollView (android.support.v4.widget.NestedScrollView)2 AlertDialog (android.support.v7.app.AlertDialog)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)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 AlertDialog (android.app.AlertDialog)1 Intent (android.content.Intent)1 Point (android.graphics.Point)1