Giter Site home page Giter Site logo

soarcn / bottomsheet Goto Github PK

View Code? Open in Web Editor NEW
2.2K 90.0 409.0 777 KB

One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation.

Home Page: http://soarcn.github.io/BottomSheet

Java 100.00%

bottomsheet's Introduction

BottomSheet

Build Status Android Arsenal

Google introduced official bottomsheets implementation in Support library 23.2.0,thus this library is no longer activly being developed. I will continuely fix defects been found and accept good PR but No more new feature will be developed. Thanks for your support!

One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation.

https://www.google.com/design/spec/components/bottom-sheets.html

This library works on android api 14+

Sample Sample Sample Sample Sample Sample

How to use this library

  • Download this library, import to your IDE (eclipse...) as a library project.
  • Using Gradle
    compile 'com.cocosw:bottomsheet:1.+@aar'
  • Using Maven
<dependency>
    <groupId>com.cocosw</groupId>
    <artifactId>bottomsheet</artifactId>
    <version>1.x</version>
    <type>apklib</type>
</dependency>
  • Version if you use Android support library - 1.4.0 if you use Androidx - 1.5.0

API

  • Define actions in menu xml (Tip: divider tag has been replaced by group tag from 1.1.0)
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/share" android:title="@string/share" android:icon="@drawable/perm_group_messages"/>
    <item android:id="@+id/upload" android:title="@string/upload" android:icon="@drawable/perm_group_system_clock"/>
    <item android:id="@+id/call" android:title="@string/call" android:icon="@drawable/perm_group_phone_calls"/>
    <group android:id="@+id/helpgroup">
         <item android:id="@+id/help" android:title="@string/help" android:icon="@drawable/perm_group_system_tools"/>
    </group>
</menu>
  • Show it just like showing a dialog.
new BottomSheet.Builder(this).title("title").sheet(R.menu.list).listener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                            case R.id.help:
                                q.toast("Help me!");
                                break;
                        }
                    }
                }).show();
  • You can also add action items in builder.

Action items manipulate

You can get a menu object from bottomsheet instance from 1.1.0, and change it as you want, exactly like you're manipulating an android menu or actionbar actionitems. Please be aware that if you change the menu after showing the bottomsheet, you must call invalidate(), or no changes will be applied and your app might crash. Please check example application for more info.

Style

  • Invoke darkTheme() to show the built-in dark theme
  • Or define your style in your application, and call bottomsheet by using new BottomSheet.Builder(this,R.style.BottomSheet_StyleDialog)....
    <style name="BottomSheet.StyleDialog" parent="BottomSheet.Dialog">
        <item name="android:backgroundDimAmount">0.5</item>
        <item name="android:windowAnimationStyle">@style/BottomSheet.Animation</item>
        <item name="android:textColorPrimary">#DDffffff</item>
        <item name="android:textColorSecondary">#8Affffff</item>
        <item name="android:textColorHint">#42ffffff</item>
        <item name="bs_dialogBackground">@color/abc_search_url_text_normal</item>
        <item name="bs_dividerColor">@color/abc_search_url_text_pressed</item>
        <item name="bs_numColumns">4</item>
        <item name="bs_listStyle">@style/BottomSheet.StyleList</item>
    </style>
  • Or set bottomesheet style in your activity theme
    <style name="StyleTheme" parent="Theme.AppCompat">
        <item name="bs_bottomSheetStyle">@style/BottomSheet.StyleDialog</item>
    </style>

Contribute

  • Feel free to fork it

About me

I'm Kai, an 32 years old android developer based in Sydney.

License

Copyright 2011, 2015 Kai Liao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

bottomsheet's People

Contributors

anatoly-lp avatar caio-yassoyama-movile avatar hannesa2 avatar joeykrim avatar kennyc1012 avatar sidlatau avatar soarcn avatar toshmeston avatar vovkab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bottomsheet's Issues

Does not build out of the box

There are some issues with the build. When forking, it does not build out of the box:

$ gradlew clean package

FAILURE: Build failed with an exception.

* Where:
Script 'https://raw.githubusercontent.com/soarcn/gradle/master/maven_push.gradle' line: 60

* What went wrong:
A problem occurred evaluating script.
> Could not find property 'nexusUsername' on project ':library'.

Fixing this locally does not work because the build scripts are referenced from https://raw.githubusercontent.com/soarcn/gradle/master/android-library.gradle and others.

And Android Studio has another message:
Error:No such property: POM_LICENCE_NAME for class: org.gradle.api.publication.maven.internal.CustomModelBuilder

In order to contribute, building should be simplified and it should build out-of-the-box.

BottomSheet crashing on Android 4.1.2 (Galaxy S3)

Testing with a Nexus 5 and Android 5.1 everything works wonderfully. However, when testing it with a Samsung Galaxy S3 mini with Android 4.1.2 BottomSheet keeps crashing when trying to open it.
(we're using BottomSheet version 0.9)

The error is:
06-22 22:33:18.937 2329-2329/ch.post.it.epof.android.client.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #9: Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
...
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010038 a=-1}
at android.content.res.Resources.loadDrawable(Resources.java:1925)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.(View.java:3405)
at android.view.ViewGroup.(ViewGroup.java:432)
at android.widget.LinearLayout.(LinearLayout.java:176)
at android.widget.LinearLayout.(LinearLayout.java:172)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
            at android.view.LayoutInflater.createView(LayoutInflater.java:587)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
            at android.view.View.inflate(View.java:16235)
            at com.cocosw.bottomsheet.BottomSheet.init(BottomSheet.java:265)
            at com.cocosw.bottomsheet.BottomSheet.onCreate(BottomSheet.java:523)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:351)
            at android.app.Dialog.show(Dialog.java:256)
            at com.cocosw.bottomsheet.BottomSheet$Builder.show(BottomSheet.java:830)
            at ch.post.it.epof.android.client.ui.fragments.ItemListFragment.showAddItemDialog(ItemListFragment.java:361)
            at ch.post.it.epof.android.client.ui.fragments.ItemListFragment.AddItemClick(ItemListFragment.java:211)
            at ch.post.it.epof.android.client.ui.fragments.ItemListFragment_$1.onClick(ItemListFragment_.java:94)
            at android.view.View.performClick(View.java:4162)
            at android.view.View$PerformClick.run(View.java:17082)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4867)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
            at dalvik.system.NativeStart.main(Native Method)

Since it works perfectly on the Nexus 5 with the same code I assume it must be an error in BottomSheet.

Any ideas? Thank you.
...

device-2015-05-13-153404

EditText inside Sheet

Anyway to sneak an EditText and A Button inside that bottomSheet?

Thanks for your awesome work BTW!

Swipe up and down

I would suggest the following well known and widely used solution instead of the ClosableSlidingLayoutyou now have (actually, the horizontal swipe could be removed from it completely). This handles the swipe easily and nicely and could be used for both directions, to open up from More and to close down:

public class SwipeFrameLayout extends android.widget.FrameLayout {
  private final GestureDetector gestureDetector;
  protected OnHorizontalSwipe horizontalListener;
  protected OnVerticalSwipe verticalListener;

  public interface OnHorizontalSwipe {
    public boolean onSwipeLeft();

    public boolean onSwipeRight();
  }

  public interface OnVerticalSwipe {
    public boolean onSwipeUp();

    public boolean onSwipeDown();
  }

  public SwipeFrameLayout(Context context) {
    super(context);
    gestureDetector = new GestureDetector(context, new GestureListener());
  }

  public SwipeFrameLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    gestureDetector = new GestureDetector(context, new GestureListener());
  }

  public SwipeFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    gestureDetector = new GestureDetector(context, new GestureListener());
  }

  @Override
  public boolean dispatchTouchEvent(MotionEvent e) {
    gestureDetector.onTouchEvent(e);
    return super.dispatchTouchEvent(e);
  }

  public void setHorizontalListener(OnHorizontalSwipe horizontalListener) {
    this.horizontalListener = horizontalListener;
  }

  public void setVerticalListener(OnVerticalSwipe verticalListener) {
    this.verticalListener = verticalListener;
  }

  private final class GestureListener extends SimpleOnGestureListener {
    private static final int SWIPE_DISTANCE_THRESHOLD = 100;
    private static final int SWIPE_VELOCITY_THRESHOLD = 100;

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
      float dX = e2.getX() - e1.getX();
      float dY = e2.getY() - e1.getY();
      if (Math.abs(dX) > Math.abs(dY) && Math.abs(dX) > SWIPE_DISTANCE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
        if (dX > 0) {
          if (horizontalListener != null)
            return horizontalListener.onSwipeRight();
        }
        else {
          if (horizontalListener != null)
            return horizontalListener.onSwipeLeft();
        }
      }
      else if (Math.abs(dY) > Math.abs(dX) && Math.abs(dY) > SWIPE_DISTANCE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
        if (dY > 0) {
          if (verticalListener != null)
            return verticalListener.onSwipeDown();
        }
        else {
          if (verticalListener != null)
            return verticalListener.onSwipeUp();
        }
      }
      return false;
    }
  }

}

Click not detected properly

I'm seeing issues with click detection due to the recent swipe down to dismiss.
Depending on screen sensitivity, on some phones it becomes difficult to click on an item, or even impossible, since moving the finger dismisses the touch.

Between my testing phones, it is worst on a Samsung Galaxy S3, where detection is very buggy, and on a Sony Xperia U, where touching an item inmediately starts moving the sheet and I haven't been able to do a click at all. This doesn't happen on normal lists.

In library version 0.3 everything works fine.

I don't have time to debug it right now. I would be ok if I could simply disable the gesture.
Thanks

Animate sliding up and down

When the bottom sheet first appears, it should animate in from the bottom and rise to the top. When it is being dismissed, it should animate from the top and slide to the bottom of the screen.

Error: java.lang.IllegalArgumentException: You should set icon for each items in grid style

Hi, i added the library to gradle, copy/paste the style in my style.xml, added the menu in menu.xml, and on Main Class i added in the OnCreate() this snippet:
new BottomSheet.Builder(this).title("title").sheet(R.menu.list).listener(new DialogInterface.OnClickListener() {
@OverRide
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case R.id.help:
Toast.makeText(getApplicationContext(), "test help menu", Toast.LENGTH_LONG).show();
break;
}
}
}).show();

But AndroidStudio gives me this error: java.lang.IllegalArgumentException: You should set icon for each items in grid style.
Can you please help me to fix this error?

kind regards
Brus

You can also add action items in builder. How so?

I tried this.....

new BottomSheet.Builder(this).grid().
                sheet(R.id.home,new IconDrawable(this, Iconify.IconValue.fa_home), "home").
                .divider()
                .sheet(R.id.board, new IconDrawable(this, Iconify.IconValue.fa_home), "board")
                .sheet(R.id.laundromat, new IconDrawable(this, Iconify.IconValue.fa_home), "laundromat")
                .sheet(R.id.laundromat, new IconDrawable(this, Iconify.IconValue.fa_home), "post")
                .listener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                            case R.id.home:
                                break;
                        }
                    }
                }).show();

It worked....It shows all the icons on the sheet, BUT it always creates four sheets behind each other.

How to create the action items in code but only 1 sheet?

thanks!

Robolectric tests fail because ClosableSlidingLayout is not public

(PR to follow)

Currently, Robolectric throws an exception because ClosableSlidingLayout is not public.

Caused by: java.lang.IllegalAccessException: Class android.view.LayoutInflater can not access a member of class com.cocosw.bottomsheet.ClosableSlidingLayout with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
at java.lang.reflect.Constructor.newInstance(Constructor.java:412)
at android.view.LayoutInflater.$$robo$$createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createView(LayoutInflater.java)
at android.view.LayoutInflater.$$robo$$createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)

gridview access in code.

would be good to have access to the gridview in the code to change it properties like column number,....

Allowing own View and own Adapters with RecyclerView

For more flexibility this would allow to use this library in more or less any case. For example in my app I need to be able to show a variable list of items depending on the current state of the app.

  • Allow usage of RecyclerView (we get better Lists and Grids!)
  • Allow Custom Adapters
  • Allow setting own View
  • Adjust callbacks for above (maybe multiple callbacks or custom callbacks?)

I will most likely start working on this soon :). If you have any things you want to tell me to do while doing it, or what to watch out for, please let me know. Of course I will send a pull request in the end.

This might go into the same pull request as #24 because it will probably as well change the Dialog to a DialogFragment.

Styles Being Overridden

I have a style set for BottomSheet as followed:

<style name="BottomSheet.StyleDialog" parent="BottomSheet.Dialog">
        <item name="android:backgroundDimAmount">0.5</item>
        <item name="android:windowAnimationStyle">@style/BottomSheet.Animation</item>
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:textColorSecondary">@android:color/white</item>
        <item name="android:textColorHint">@android:color/white</item>
        <item name="bs_dialogBackground">?colorPrimaryDark</item>
    </style>

But it seems that my application style is overriding the attributes in the above style, mainly the text colors. The base for my style is :
<style name="Theme_Light">
        <item name="android:windowBackground">@color/background_material_light</item>
        <item name="android:textColorSecondary">@color/secondary_text_default_material_light</item>
        <item name="android:textColor">@color/primary_text_default_material_light</item>
  </style> 

The Dialog is being shown as followed:
 new BottomSheet.Builder(this, R.style.BottomSheet_StyleDialog)
                .title(R.string.options)
                .grid()
                .sheet(R.menu.comment_menu)
                .listener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int which) {
                        // CODE
                })
                .setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        // Code
                    }
                }).show();

Orientation change looses dialog

Title says everything.

But don't bother yet. I think I will start working on this and send you a pull request. I think mainly it should be switched from Dialog to DialogFragment. That will require the support library. But I guess that is okay, right? Or both could be supported, but requires more work.

Option to disable menu options floating in animation

Setting windowAnimationStyle to @null didn't seem to have any effect. I would like to disable the items in the bottom sheet "floating in" at different speeds without disabling the slide in animation on the bottom sheet, to match the Android Lollipop share intent animation and Google Drive's bottom sheet.

Support for orientation change

Hey,
It looks like because BottomSheet extends Dialog and not DialogFragment, there is no easy way to support orientation changes. The only way I can think of is to keep a flag in the parent activity's saved instance state bundle, and re-open it if it was previously opened, but this is weird because of the slide-in animation.
Any solution for this?
Thanks!

setCancelable(false) and setCanceledOnTouchOutside(false) doesn't work

Hello!

Greate library, thank you!

Currently I need to create dialog which cannot be cloused by back button, swipe or touch outside. In my case it can be cloused only when user choose one of item on a sheet. But here is a problem: methods setCancelable(false) and setCanceledOnTouchOutside(false) doesn't work. Is there way to fix it? How to make sheet uncancelable?

Grid item not getting clicked

I haven't noticed this until now but I'm creating a bottom sheet that contains items in a grid with a corresponding listener.

There are no items that can be clicked but it just opens the collapsed items into the expanded grid like what would happen if you click "more" item.

Please let me know how this can be fixed as this is very critical

Suppressing InflateParams

Minor issue but don't use @SuppressLint("InflateParams"). The proper way is to call:

convertView = inflater.inflate(R.layout.bs_grid_entry, parent, false);

You won't pass a null that way, there will be no warning, but you won't get errors in obscure cases if you simply get used to this call pattern.

Make the Sheet scrollable

Currently when in Landscape mode the sheet quickly fills up the entire screen. Even worse, some action items are cut off. I could go to Grid mode, but on small screens even that won't help.

error from inflating the sheet

04-28 12:13:39.496    1697-1697/com.hb.editoral E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.hb.editoral, PID: 1697
    android.view.InflateException: Binary XML file line #39: Error inflating class android.widget.GridView
            at android.view.LayoutInflater.createView(LayoutInflater.java:633)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at android.view.View.inflate(View.java:18524)
            at com.cocosw.bottomsheet.BottomSheet.init(BottomSheet.java:265)
            at com.cocosw.bottomsheet.BottomSheet.onCreate(BottomSheet.java:523)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:373)
            at android.app.Dialog.show(Dialog.java:274)
            at com.cocosw.bottomsheet.BottomSheet$Builder.show(BottomSheet.java:831)
            at com.hkm.editorial.ArticlePage$2.onClick(ArticlePage.java:89)
            at android.view.View.performClick(View.java:4785)
            at android.view.View$PerformClick.run(View.java:19858)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:155)
            at android.app.ActivityThread.main(ActivityThread.java:5696)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
            at android.view.LayoutInflater.createView(LayoutInflater.java:607)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at android.view.View.inflate(View.java:18524)
            at com.cocosw.bottomsheet.BottomSheet.init(BottomSheet.java:265)
            at com.cocosw.bottomsheet.BottomSheet.onCreate(BottomSheet.java:523)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:373)
            at android.app.Dialog.show(Dialog.java:274)
            at com.cocosw.bottomsheet.BottomSheet$Builder.show(BottomSheet.java:831)
            at com.hkm.editorial.ArticlePage$2.onClick(ArticlePage.java:89)
            at android.view.View.performClick(View.java:4785)
            at android.view.View$PerformClick.run(View.java:19858)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:155)
            at android.app.ActivityThread.main(ActivityThread.java:5696)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
     Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable/actionbar_bg_hb_white.xml"
            at java.lang.Integer.invalidInt(Integer.java:138)
            at java.lang.Integer.parse(Integer.java:410)
            at java.lang.Integer.parseInt(Integer.java:367)
            at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:128)
            at android.content.res.TypedArray.getInt(TypedArray.java:322)
            at android.view.animation.Animation.<init>(Animation.java:246)
            at android.view.animation.AnimationSet.<init>(AnimationSet.java:81)
            at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:115)
            at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:93)
            at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:74)
            at android.view.animation.LayoutAnimationController.setAnimation(LayoutAnimationController.java:184)
            at android.view.animation.LayoutAnimationController.<init>(LayoutAnimationController.java:114)
            at android.view.animation.AnimationUtils.createLayoutAnimationFromXml(AnimationUtils.java:192)
            at android.view.animation.AnimationUtils.createLayoutAnimationFromXml(AnimationUtils.java:171)
            at android.view.animation.AnimationUtils.loadLayoutAnimation(AnimationUtils.java:152)
            at android.view.ViewGroup.initFromAttributes(ViewGroup.java:553)
            at android.view.ViewGroup.<init>(ViewGroup.java:493)
            at android.widget.AdapterView.<init>(AdapterView.java:238)
            at android.widget.AbsListView.<init>(AbsListView.java:904)
            at android.widget.GridView.<init>(GridView.java:129)
            at android.widget.GridView.<init>(GridView.java:125)
            at android.widget.GridView.<init>(GridView.java:121)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
            at android.view.LayoutInflater.createView(LayoutInflater.java:607)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at android.view.View.inflate(View.java:18524)
            at com.cocosw.bottomsheet.BottomSheet.init(BottomSheet.java:265)
            at com.cocosw.bottomsheet.BottomSheet.onCreate(BottomSheet.java:523)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:373)
            at android.app.Dialog.show(Dialog.java:274)
            at com.cocosw.bottomsheet.BottomSheet$Builder.show(BottomSheet.java:831)
            at com.hkm.editorial.ArticlePage$2.onClick(ArticlePage.java:89)
            at android.view.View.performClick(View.java:4785)
            at android.view.View$PerformClick.run(View.java:19858)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:155)
            at android.app.ActivityThread.main(ActivityThread.java:5696)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

im trying to create a grid like sheet from the bottom with the share provider content.. This is what I got in the app with Android 5.0 lilpop. Anyone can help me? I just dont know where to start fixing it.

Make BottomSheet.List layout animation configurable

In the current version it is possible to change the animation for the dialog as whole, however, it not possible to change the layout animation for the BottomSheet.List. It would be nice if it was a styleable attr.

菜单关闭回调监听无法正确回调

用中文可否

 @Override
        public void onViewDragStateChanged(int state) {
            if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE && dismissed) {
                if (mListener != null) {
                    mListener.onClosed();
                }
            }
        }

看这一个判断. dismissed 在触摸事件Down的时候会变更dismissed的值为false.
所以.当我把菜单下滑消失..注意.并且在消失的时候点击了屏幕.那么 mListener.onClosed();就无法被回调到了.

IllegalStateException when using grid sheet

I ma getting this exception
java.lang.IllegalArgumentException
at java.util.AbstractList.subList(AbstractList.java:736)
at com.cocosw.bottomsheet.BottomSheet.init(BottomSheet.java:293)
at com.cocosw.bottomsheet.BottomSheet.onCreate(BottomSheet.java:455)
at android.app.Dialog.dispatchOnCreate(Dialog.java:361)
at android.app.Dialog.show(Dialog.java:262)
at com.cocosw.bottomsheet.BottomSheet$Builder.show(BottomSheet.java:733)

Only when i show-cancel repeatedly these steps 3-4 times and am using grid style sheet

holoeverywhere

not work with holoeverywhere. crash on layout inflater.

Grid item not getting clicked

I haven't noticed this until now but I'm creating a bottom sheet that contains items in a grid with a corresponding listener.

There are no items that can be clicked but it just opens the collapsed items into the expanded grid like what would happen if you click "more" item.

Please let me know how this can be fixed as this is very critical

Bottom Sheet Form

Hello, Appreciate this great work, please is there a way to add Edittext to the bottom sheet and accept whatever user input???

NullPointerException caused by using BottomSheet#limit()

Description:
A NullPointerException is thrown when you set a menu resources with BottomSheet#sheet() that contains a small number (tested with 1~4) of items together with a limit, when clicking the item.

Code:

sheetScripts = new BottomSheet.Builder(getActivity()).sheet(R.menu.menu).listener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).grid().limit(R.integer.bs_initial_grid_row).show();

The value of R.integer.bs_initial_grid_row is 3

R.menu.menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/some_id" android:title="some_title" android:icon="@mipmap/ic_launcher"/>
</menu>

Log:

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.cocosw.bottomsheet.ActionMenu.removeInvisible()' on a null object reference
            at com.cocosw.bottomsheet.BottomSheet.updateSection(BottomSheet.java:457)
            at com.cocosw.bottomsheet.BottomSheet.showShortItems(BottomSheet.java:501)
            at com.cocosw.bottomsheet.BottomSheet.access$1800(BottomSheet.java:75)
            at com.cocosw.bottomsheet.BottomSheet$7.onDismiss(BottomSheet.java:559)
            at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1263)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Animates over Navigation Bar

When bottom sheet animates on to the screen it comes over the navigation bar. Appearing above the system navigation bar would be more desirable.

maxWidth option

Hi,

could you add an option to set the maxWidth of the BottomSheet.
Right now, on landscape mode it fill up the whole screen. I would like it to be more narrow (just like the menu options)

thanks

Custom Typeface

Is there any way to set custom typeface to the menu item?
Thanks

Resource not found when building with Proguard

I experience it on runtime. After I pressed the button that will run the show function it will crash with the exception resource not found..

It is working fine with no proguard. Can you help me set it up?

Thanks :)

Callback when click on CLOSE icon in Fullscreen mode

In your demo app, I choose FullScreen section, then click on any name to invoke BottomSheet with ShareAction. I see click on More... in GridView will show BottomSheet in fullscreen mode with bs_closeDrawable (X sign) in the top left. We can touch on bs_closeDrawable to showShortItems() while press BACK will close BottomSheet.

Could you please provide callback when click on bs_closeDrawable ? I want to close BottomSheet instead of showShortItems().

Partial number of items

How can I show the first items of the list after opening bottom sheet?
I like to show partial number of items and if I swipe up it will show me all items?

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.