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);
}
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);
}
});
}
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;
}
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");
}
});
}
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) {
}
});
}
Aggregations