Iโm an Android Engineer currently working at Joyn on Android TV apps.
I like contributing to open source projects and build helpful libraries here on Github.
Follow me on:
Latest blog post:
A simple library that creates BottomSheets according to the Material Design specs
License: Apache License 2.0
Iโm an Android Engineer currently working at Joyn on Android TV apps.
I like contributing to open source projects and build helpful libraries here on Github.
Follow me on:
Latest blog post:
A desirable enhancement would be for BottomSheetBuilder
to check the visibility status of a menu item before adding it to the list of BottomSheetItems
in method createMenuItems()
. In my use case, I have a single menu resource XML file that I configure after inflation by calling MenuItem.setVisible()
to make items visible or not depending on the context. When I pass the menu to BottomSheetBuilder.setMenu(Menu)
, the visibility status of the menu items is ignored.
Steps to reproduce:
Set icontintcolor to bottomsheetbuilder. Add a menu item without icon. Crashes.
Fix :
Check should be done if icon drawable is null before tinting it.
private void show() {
if (mBottomSheetDialog != null) {
mBottomSheetDialog.dismiss();
}
mBottomSheetDialog = new BottomSheetBuilder(this, R.style.BottomSheetBuilder_DialogStyle)
.setMode(BottomSheetBuilder.MODE_GRID)
.setMenu(R.menu.menu_share)
.expandOnStart(true)
.setItemClickListener(new BottomSheetItemClickListener() {
@Override
public void onBottomSheetItemClick(MenuItem item) {
CUtils.Toast(item.getTitle() + "");
}
})
.createDialog();
mBottomSheetDialog.show();
}
Nvr mind, got it.
issue as title
setMode is MODE_LIST
thank you ^^
Hello
First, nice work .
I was playing with a really basic builder with just 1 option and 1 Icon.
In a landscape mode, with my tablet TabA SM-P550 Android 5.0.1.
Trigger this issue everytime when .show() :
FATAL EXCEPTION: main java.lang.NoSuchFieldError: No static field imageView
in class Lcom/github/rubensousa/bottomsheetbuilder/R$id; or its superclasses at BottomSheetItemAdapter$ItemViewHolder.<init>(BottomSheetItemAdapter:183) at BottomSheetItemAdapter.onCreateViewHolder(BottomSheetItemAdapter.java:94) at BottomSheetItemAdapter.onCreateViewHolder(BottomSheetItemAdapter.java:32) at xx$Adapter.createViewHolder(RecyclerView.java:6519) at x.xx.Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.j:5706) at android.xx.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589) at android.xx.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585) at android.xx.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231) at android.xx.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518) at android.xx.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:747) at android.widget.LinearLayout.onMeasure(LinearLayout.java:629) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.xx.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:719) at android.xx.CoordinatorLayout.onMeasure(CoordinatorLayout.java:791) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.xxContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:747) at android.widget.LinearLayout.onMeasure(LinearLayout.java:629) at android.view.View.measure(View.java:20214) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at com.xx.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3083) at android.view.View.measure(View.java:20214) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2683) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1636)
I will try to fix it, just wanted to inform.
how can i solve this problem??
Hi Rubens, is there any way to add a options to .setItemColorTint or something like this? so i can avoid having more duplicate drawable for specific themes, i just need to set the tintColor
Hi @rubensousa ,
It would be possible to add the following features:
How can the colors of the two texts are different, one is black, the other is gray and then there is the separator.
The possibility to change color to:
a) ripple effect
b) Color of the item when it is selected
The ability to reduce the size of the container, not to take up all the space of the device.
Example, here it is performed on a tablet, but the same for a mobile device:
https://raw.githubusercontent.com/rubensousa/BottomSheetBuilder/master/screens/tablet_grid.png
Connected to 3), the possibility of having rounded corners at the top of the container.
a) You can also put the text that could change even under the main text, ex: Subtitle Language.
b) Give the possibility to leave no space between the container and the text, if there are no icons, in this case none has an icon.
c) As in Subtitle Display, the possibility to also put the check.
ย .addItem (0, "0", a)
ย .addItem (0, "0", a, false)
I add an item in my style file, but it didn't work.
When i call setItemBackground(someDrawable) - this drawable is set over default white rectangle, but not replacing it. For example you can not set the background with rounded top corners. How can i reach this?
android.view.WindowManagerGlobal.findViewLocked (WindowManagerGlobal.java:454)
android.view.WindowManagerGlobal.removeView (WindowManagerGlobal.java:380)
android.view.WindowManagerImpl.removeViewImmediate (WindowManagerImpl.java:140)
android.app.Dialog.dismissDialog (Dialog.java:701)
android.app.Dialog.dismiss (Dialog.java:684)
com.github.rubensousa.bottomsheetbuilder.BottomSheetMenuDialog.access$101 (BottomSheetMenuDialog.java:34)
com.github.rubensousa.bottomsheetbuilder.BottomSheetMenuDialog$3.onStateChanged (BottomSheetMenuDialog.java:201)
android.support.design.widget.BottomSheetBehavior.setStateInternal (BottomSheetBehavior.java:576)
android.support.design.widget.BottomSheetBehavior$SettleRunnable.run (BottomSheetBehavior.java:757)
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:7325)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Steps to reproduce :
Enable this option on your device: Settings -> Developer Options -> Don't keep Activities.
open bottomsheet, then click on any item which causes new activity to launch.
The old activity is removed, and causes the crash.
Hi, i would like to edit, add, remove menu items, submenus without creating a new view with the builder, dynamically. I think a class which allows editing List<BottomSheetItem> items
would solve it. The recyclerview could animate changes. What do you think? Is it possible?
Hi, Thanks for your library.
I am trying to show BottomSheet in a fragment but a problem occurs on onBottomSheetItemClick listener. Problem steps are;
1- User clicks edit button and BottomSheet opens
2- User clicks an item and BottomSheet dismisses
3- User clicks edit button again and BottomSheet opens
4- User clicks an item but BottomSheet doesn't close and onBottomSheetItemClick is not called.
I changed your sample code using a fragment and same problem occurs. BottomSheet dialog dismisses when user clicks outside of the dialog. In my fragment, there is no coordinatorlayout.
mShowingSimpleDialog = true;
mBottomSheetDialog = new BottomSheetBuilder(getActivity())
.setMode(BottomSheetBuilder.MODE_LIST)
.addTitleItem("Custom title")
.addItem(0, "Preview", R.drawable.ic_close_24dp)
.addItem(1, "Share", R.drawable.ic_close_24dp)
.addDividerItem()
.addItem(2, "Get link", R.drawable.ic_close_24dp)
.addItem(3, "Make a copy", R.drawable.ic_close_24dp)
.expandOnStart(true)
.setItemClickListener(new BottomSheetItemClickListener() {
@Override
public void onBottomSheetItemClick(MenuItem item) {
Log.d("Item click", item.getTitle() + "");
mShowingSimpleDialog = false;
}
})
.createDialog();
mBottomSheetDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mShowingSimpleDialog = false;
}
});
It is not exactly an issue.
I would recommend adding an option (waitDismissForBottomSheetItemClick(true)
) .
When I want to start an activity on ``onBottomSheetItemClick``` it gets some lag when the dialog is dismissing, causing a bad user experience.
I had to put a delay to wait for the BottomSheetDialog
to dismiss before starting my activity.
adding
android:maxLines="1"
android:ellipsize="end"
to
src/main/res/layout/bottomsheetbuilder_list_header.xml
will fix it. Thanks!!
hello there,
i really happy using di this library and userfull but i need some feature to add title and set coloumn grid mode because i want to make small icon menu in modal sheet.
is there way to make that..?
thank you
Currently the background, title, etc colors can be set by color resId only.
Using Attribute resId, would be more useful for theming purposes.
Or, option to provide resolved color values, would also do.
Error:No resource found that matches the given name: attr 'behavior_skipCollapsed
Hi, I tried to reuse dialog instance.
in BottomSheetMenuDialog::onBottomSheetItemClick
if (!mClicked) {
mClicked = true;
}
Because of this part, onBottomSheetItemClick is not called from second display.
Please consider supporting this case.
I'd like to change the color of the ripple effect, but setting a style attribute, or providing my own custom XML. How do I achieve that?
I see Material design guide https://material.io/guidelines/components/bottom-sheets.html#bottom-sheets-modal-bottom-sheets
Section Tablet, Long list visible with two columns
Hi!
How can i put rounded coners?
Thanks for the lib!
I want to be a able to control the visibility of my BottomSheetDialog, so I'm using the builder with a coordinatorlayout provided. It seems however, that with that setup I can't enable background-dim? Could you suggest any workaround for this? Thank you in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.