Coder Social home page Coder Social logo

heinrichreimer / material-drawer Goto Github PK

View Code? Open in Web Editor NEW
599.0 39.0 133.0 17.01 MB

Custom drawer implementation for Material design apps.

License: MIT License

Java 100.00%
android android-library jitpack material-drawer java custom-drawer material-design material-components

material-drawer's Introduction

Icon

material-drawer

Android Arsenal JitPack Build Status License

Custom drawer implementation for Material design apps.

Demo

A demo app is available on Google Play:

Get it on Google Play

Screenshots

material-drawer material-drawer material-drawer
Fixed items Select profile Custom theme

Dependency

material-drawer is available on jitpack.io

Gradle dependency:

repositories {
    // ...
    maven { url 'https://jitpack.io' }
}
dependencies {
    compile 'com.heinrichreimersoftware:material-drawer:2.3.3'
}

Get the latest dependency at jitpack.io.

How-To-Use

Step 1: Let your Activity extend DrawerActivity:

public class MainActivity extends DrawerActivity {}

Step 2: Set your content:

setContentView(R.layout.activity_main);

Step 3: Add a profile:

addProfile(
        new DrawerProfile()
                .setRoundedAvatar((BitmapDrawable)getResources().getDrawable(R.drawable.profile_avatar))
                .setBackground(getResources().getDrawable(R.drawable.profile_cover))
                .setName(getString(R.string.profile_name))
                .setDescription(getString(R.string.profile_description))
                .setOnProfileClickListener(new DrawerProfile.OnProfileClickListener() {
                    @Override
                    public void onClick(DrawerProfile drawerProfile, long id) {
                        Toast.makeText(MainActivity.this, "Clicked profile #" + id, Toast.LENGTH_SHORT).show();
                    }
                })
        );

Step 4: Populate your drawer list:

addItem(
        new DrawerItem()
                .setImage(getResources().getDrawable(R.drawable.ic_first_item))
                .setTextPrimary(getString(R.string.title_first_item))
                .setTextSecondary(getString(R.string.description_first_item))
                .setOnItemClickListener(new DrawerItem.OnItemClickListener() {
                    @Override
                    public void onClick(DrawerItem drawerItem, long id, int position) {
                        Toast.makeText(MainActivity.this, "Clicked first item #" + id, Toast.LENGTH_SHORT).show();
                    }
                })
        );
addDivider();
addItem(
        new DrawerItem()
                .setImage(getResources().getDrawable(R.drawable.ic_second_item))
                .setTextPrimary(getString(R.string.title_second_item))
                .setOnItemClickListener(new DrawerItem.OnItemClickListener() {
                    @Override
                    public void onClick(DrawerItem drawerItem, long id, int position) {
                        Toast.makeText(MainActivity.this, "Clicked second item #" + id, Toast.LENGTH_SHORT).show();
                    }
                })
        );

Step 5: Add actionBarStyle to your theme:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/color_primary</item>
    <item name="colorPrimaryDark">@color/color_primary_dark</item>
    <item name="colorAccent">@color/color_accent</item>
    <item name="actionBarStyle">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>

Step 6 (Optional): Change the drawer theme:

The drawer gets themed based on your selected app theme but you can also modify it.

setDrawerTheme(
        new DrawerTheme(this)
                .setBackgroundColorRes(R.color.background)
                .setTextColorPrimaryRes(R.color.primary_text)
                .setTextColorSecondaryRes(R.color.secondary_text)
                .setTextColorPrimaryInverseRes(R.color.primary_text_inverse)
                .setTextColorSecondaryInverseRes(R.color.secondary_text_inverse)
                .setHighlightColorRes(R.color.highlight)
);

Step 7 (Optional): Set your own Toolbar:

You can set your own Toolbar as you do with ActionBarActivity.

setSupportActionBar(toolbar);

Pro Tip: Lollipop status bar

Step 1: Make your status bar transparent:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

That's it! material-drawer takes care of the rest.

Of course you can use DrawerFrameLayout and DrawerView alone too. See the comments in the Java files for further information.

Open source libraries

material-drawer uses the following open source libraries or files:

License

Copyright 2015 Heinrich Reimer

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.

material-drawer's People

Contributors

gilm787 avatar heinrichreimer avatar i906 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

material-drawer's Issues

DrawerLayout implementation

Add DrawerLayout implementation which holds exactly one view in XML and automatically adds a DrawerView:

<com.heinrichreimersoftware.material_drawer.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    ...

</com.heinrichreimersoftware.material_drawer.DrawerLayout>

Add bottomItem

As per Google design guidelines: "Settings and support are located at the bottom of the scrolling list, in-line with the rest of the list content."

This items should not scroll with the rest of the drawer items (in other words, should be bottom fixed).

Support multiple profiles

It looks like only a single profile can be specified, for apps (like most of Googles) that support multiple accounts it would be useful to have the drawer profile able to switch between them.

Add Drawer Shadow

IT'd be awesome if you create a method to easily set the drawer shadow on the drawer. Regardless this is great work and progress so far!! keep it up

CloseDrawer Lag

Hey, first of all thanks for this great library, I just have 2 small problems:

  • I start new activites in the OnItemClickListener for each item and want to close the drawer beforehand. Unfortunately the animation isnt finished when the new activity is started and it get stuck for a brief moment. Is it possible to "wait" for the animation to finish? I'm not sure if im doing something wrong, here is the code for one item:
        drawer.addFixedItem(
                new DrawerItem()
                        .setImage(getResources().getDrawable(R.drawable.ic_format_line_spacing_grey600_48dp))
                        .setTextPrimary(getString(R.string.drawer_sixth_item))
                        .setTextSecondary(getString(R.string.drawer_sixth_description))
                        .setOnItemClickListener(new DrawerItem.OnItemClickListener() {
                            @Override
                            public void onClick(DrawerItem drawerItem, int i, int position) {
                                drawerLayout.closeDrawer(drawer);
                                intent = new Intent(getApplicationContext(), Swipe.class);
                                intent.putExtra("toGo", 0);
                                startActivity(intent);
                            }
                        })

        );

What is a good practice to get the drawer in every fragment or activity? Right now I created a base class and let every activity extend it, is this a good idea?

  • Debug Log is getting spammed with methodcalls:
03-02 15:56:53.298  21730-21730/com.example D/DrawerView﹕ DrawerView()
03-02 15:56:53.298  21730-21730/com.example D/DrawerView﹕ init()
03-02 15:56:53.308  21730-21730/com.example D/DrawerView﹕ findViews()
03-02 15:56:53.308  21730-21730/com.example D/DrawerView﹕ updateProfile()
03-02 15:56:53.308  21730-21730/com.example D/DrawerView﹕ updateList()
03-02 15:56:53.308  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.308  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.308  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.318  21730-21730/com.example D/DrawerView﹕ updateProfile()
03-02 15:56:53.318  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.318  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.318  21730-21730/com.example D/DrawerView﹕ updateList()
03-02 15:56:53.328  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.358  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.358  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.378  21730-21730/com.example D/DrawerView﹕ updateList()
03-02 15:56:53.378  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.418  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.418  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.438  21730-21730/com.example D/DrawerView﹕ updateList()
03-02 15:56:53.438  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.498  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.498  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.568  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.568  21730-21730/com.example D/DrawerView﹕ updateListSpacing()
03-02 15:56:53.628  21730-21730/com.example D/DrawerView﹕ updateFixedList()
03-02 15:56:53.628  21730-21730/com.example D/DrawerView﹕ updateListSpacing()

Thanks for any help!

compatible with eclipse?

I've added this to my project in eclipse, but it won't let me import the DrawerView from step 2 in the ReadMe. Am i doing something wrong?

Drawer profile without profile Information

When setting a drawer profile with
drawer.setProfile(
new DrawerProfile()
.setBackground(getResources().getDrawable(R.drawable.profile_background)));

The background image is not displayed correctly, it fill's at full height.
Tested on both 4.4 & 5.0

Profile List opening after updateProfile - and getting in front of DrawerListItem

After updating the profile, sometimes the Profile list opens and gets in front (or behind) the DrawerList.

screenshot 2015-02-11 14 19 14

The log:

02-11 16:23:38.645    2537-2537/br.com.intelie.live D/DrawerView﹕ DrawerView()
02-11 16:23:38.645    2537-2537/br.com.intelie.live D/DrawerView﹕ init()
02-11 16:23:38.659    2537-2537/br.com.intelie.live D/DrawerView﹕ findViews()
02-11 16:23:38.659    2537-2654/br.com.intelie.live D/Retrofit﹕ ---> HTTP GET
02-11 16:23:38.661    2537-2537/br.com.intelie.live D/DrawerView﹕ updateListVisibility()
02-11 16:23:38.661    2537-2654/br.com.intelie.live D/Retrofit﹕ ---> END HTTP (no body)
02-11 16:23:38.682    2537-2537/br.com.intelie.live D/DrawerView﹕ updateProfile()
02-11 16:23:38.685    2537-2537/br.com.intelie.live D/DrawerView﹕ updateProfile()
02-11 16:23:38.691    2537-2537/br.com.intelie.live D/DrawerView﹕ updateList()
02-11 16:23:38.693    2537-2537/br.com.intelie.live D/DrawerView﹕ updateListVisibility()
02-11 16:23:38.705    2537-2537/br.com.intelie.live D/DrawerView﹕ updateFixedList()
02-11 16:23:38.707    2537-2537/br.com.intelie.live D/DrawerView﹕ updateListVisibility()
02-11 16:23:38.725    2537-2537/br.com.intelie.live D/DrawerView﹕ updateFixedList()
02-11 16:23:38.802    2537-2654/br.com.intelie.live D/Retrofit﹕ <--- HTTP 200
### My Profile object
02-11 16:23:38.808    2537-2654/br.com.intelie.live D/Retrofit﹕ <--- END HTTP (192-byte body)
02-11 16:23:38.861    2537-2537/br.com.intelie.live D/DrawerView﹕ onSizeChanged(750, 1701, 0, 0)
02-11 16:23:38.861    2537-2537/br.com.intelie.live D/DrawerView﹕ updateListVisibility()
02-11 16:23:38.861    2537-2537/br.com.intelie.live D/DrawerView﹕ updateDrawerWidth()
02-11 16:23:38.861    2537-2537/br.com.intelie.live D/DrawerView﹕ updateProfileSpacing()
02-11 16:23:38.861    2537-2537/br.com.intelie.live D/DrawerView﹕ updateDrawerWidth()
02-11 16:23:38.861    2537-2537/br.com.intelie.live D/DrawerView﹕ updateProfileSpacing()
02-11 16:23:39.089    2537-2537/br.com.intelie.live D/DrawerView﹕ updateProfile()
02-11 16:23:39.091    2537-2537/br.com.intelie.live D/DrawerView﹕ updateProfile()

Is it really right to call the methods a lot of times?
Another question: how can I don't have the white circle if I don't want the profile picture?

Drawer header without a profile

Without the profile header, the drawer looks kinda blank. But my app doesn't have user accounts.

I know the guidelines for material design say the top of the drawer should contain profiles, but if there aren't any in the app, it should be possible to set a header image/drawable without profiles.

As it is right now, the profile top will not show up at all if there is not a profile image and name set (not even empty strings are allowed), so it's not possible to re-use that part.

Adding large number of items slow

When I try to add a large number of items to the drawer (couple hundred for example, use case similar to gmail app having the list of labels in the drawer) it takes a long time (minutes) to finish drawing the drawer. The logcat shows D/DrawerView: updateList() over and over.

Project refresh failed

Hello,
upon importing your project into Android Studio, I get the following error:

Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer

Please advise.

Profile not showing

When I add a profile to the drawer, it doesn't show up. The 'empty' profile disappears and the list with items is pushed to the top. If I interpret the pull request by jkwiecien correctly, his changes should fix this problem (#8).

screenshot-drawer

NullPointerException when attempting to add DrawerItem

I'm trying to get the library working in my project, but I'm getting the error below when I attempt to add the first item to the drawer after the profile. I'm only using setTextPrimary and setOnItemClickListener on the DrawerItem, but a quick review of the source seems to indicate this is supported.

If I only add the DrawerProfile, I do not get the exception, but I don't see the profile section at the top of the drawer, either. Perhaps this is a related issue?

I have gone through the README multiple times, so I'm fairly certain I'm doing things correctly. The only slight difference in my case is my `DrawerView

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
            at com.heinrichreimersoftware.material_drawer.DrawerAdapter.getView(DrawerAdapter.java:74)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView.setupChildren(LinearListView.java:269)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView.access$000(LinearListView.java:35)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView$1.onChanged(LinearListView.java:53)
            at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
            at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
            at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:286)
            at android.widget.ArrayAdapter.add(ArrayAdapter.java:182)
            at com.heinrichreimersoftware.material_drawer.DrawerView.addItem(DrawerView.java:228)
            at com.chaione.gameplan.sdk.ui.NavigationDrawerFragment.onViewCreated(NavigationDrawerFragment.java:64)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:961)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1243)
            at android.app.Activity.performStart(Activity.java:5969)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)

Bibliotek/Bugs/Crash

Guten Tag,ich benutze dieser Bibliotek in meinem App
Das App crasht on Method onCreate ich habe das Bibliotek auf diese Gerate getestet
-Sony Xperia miro 4.0.4 Fliegt raus
-Samsung Galaxy Tab PRO 4.4.4-Funktioniert Gut
-LG G2 4.2.2 Fliegt raus...
Viele benutzer haben bei mich gemeldet
Ich erwarte von innen Unterstützung für Android 4.0+ bzw.fur Sony,LG,usw.

Additional drawer items in account switch list

Like the gmail drawer, pressing the arrow displays the list of accounts to switch to, would be nice to be able to add additional items for "add account" or "manage accounts" type use cases.

Can't add item with pre rendered icon

I would like to add an item whose icon is coloured, but keep the same dimensions as a regular icon.
If I choose to draw as a DrawerItem.AVATAR, the image will look the way I want, but the row will be taller. If I choose DrawerItem.ICON, the height will be as I want, but the icon will not be rendered with colours.

Is it possible to have a third option that features what I described?

NPE when switch profile

version: 2.0

E/AndroidRuntime( 2441): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:533)
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:410)
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:538)
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:928)
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:951)
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.ObjectAnimator.start(ObjectAnimator.java:385)
E/AndroidRuntime( 2441):        at com.nineoldandroids.animation.AnimatorSet.start(AnimatorSet.java:502)
E/AndroidRuntime( 2441):        at com.heinrichreimersoftware.materialdrawer.DrawerView.animateToProfile(DrawerView.java:687)
E/AndroidRuntime( 2441):        at com.heinrichreimersoftware.materialdrawer.DrawerView.selectProfile(DrawerView.java:895)
E/AndroidRuntime( 2441):        at com.heinrichreimersoftware.materialdrawer.DrawerView$3.onItemClick(DrawerView.java:172)
E/AndroidRuntime( 2441):        at com.heinrichreimersoftware.materialdrawer.widget.LinearListView$InternalOnClickListener.onClick(LinearListView.java:283)
E/AndroidRuntime( 2441):        at android.view.View.performClick(View.java:4756)
E/AndroidRuntime( 2441):        at android.view.View$PerformClick.run(View.java:19749)
E/AndroidRuntime( 2441):        at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime( 2441):        at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 2441):        at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 2441):        at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 2441):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2441):        at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 2441):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 2441):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Background color

Can we set background color of a drawer somehow? Can't find it in current implementation

Single profile optimize

In some use cases there is only one profile, no need to switch among profiles. Now there is still a arrow on right of user name to pull down only one option, and a empty white circle on top-right. I like the user profile as clean as possible without the arrow and white circle.

Can't add fixed items.

It's impossible to add a fixed Item from DrawerFrameLayout. There's no method for it.

I think this would do the trick

    /**
     * Adds a fixed item to the drawer
     *
     * @param item Item to add
     */
    public DrawerFrameLayout addFixedItem(DrawerItem item) {
        mDrawer.addFixedItem(item);
        return this;
    }

Profile functionality

Hey I was wondering when the profile functionality in 2.0 will be ready?

Thanks in regards

Demo app

Add a demo add to show how the drawer looks

Can't change width of the drawer

Hi, I'm trying to use your library in my app since it looks great. However, the navigation drawer is completely filling the screen of my phone. Is this supposed to happen or is there any way I can set the width of the drawer myself?

It's pretty odd though, I did the same exact thing as you did in the sample application.

Please let me know, thanks.

Turning on MinifyEnabled will crash app

Reproduced on production build.

03-12 14:40:52.251 29987-29987/com.remu.ootdapp E/PropertyValuesHolder﹕ Couldn't find setter/getter for property colorMatrix with value type class android.graphics.ColorMatrix
03-12 14:40:52.252 29987-29987/com.remu.ootdapp E/PropertyValuesHolder﹕ Couldn't find no-arg method for property colorMatrix: java.lang.NoSuchMethodException: getColorMatrix []
03-12 14:40:52.252 29987-29987/com.remu.ootdapp D/AndroidRuntime﹕ Shutting down VM
03-12 14:40:52.253 29987-29987/com.remu.ootdapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.remu.ootdapp, PID: 29987
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
at com.c.a.aj.a(Unknown Source)
at com.c.a.t.d(Unknown Source)
at com.c.a.ao.d(Unknown Source)
at com.c.a.ao.a(Unknown Source)
at com.c.a.ao.a(Unknown Source)
at com.c.a.t.a(Unknown Source)
at com.c.a.d.a(Unknown Source)
at com.heinrichreimersoftware.materialdrawer.DrawerView.c(Unknown Source)
at com.heinrichreimersoftware.materialdrawer.DrawerView.b(Unknown Source)
at com.heinrichreimersoftware.materialdrawer.b.d.k(Unknown Source)
at com.heinrichreimersoftware.materialdrawer.b.d.a(Unknown Source)
at com.puppylab.firstapp.cj.a(Unknown Source)
at com.d.a.b.c.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Add list headers

Please, add an option for adding a subtitle like addTitle/ addSubtitle.

Issue: Text color change

So, yes, this is probably the most stupidest issue but I legit, am having diffculties changing the text colour in the drawer. Whats the easiest way to change the text color?

Android studio preview

Exception raised during rendering: com.android.layoutlib.bridge.android.BridgeContext cannot be cast to android.app.Activity java.lang.ClassCastException: com.android.

Crash with no profile

As of 2.0 it looks like a force close happens if a profile is not added, or not added soon enough in the activity lifecycle.

Problem: Back Arrow Instead of Hamgurger Icon

I am facing two issues implementing this the library.

  1. The hamburger Icon to open the the drawer doesn't show up normally. If I use set Navigation icon property of the toolbar, Back Arrow Icon shows up, irrespective of what Icon I choose. Though I can pull out the drawer, I can't open it using icon on the toolbar.
  2. I can't seem to be able to set profile background. Irrespective what drawable/bitmap I choose, the background

is a grey.

I have attached screenshots for both the issues.

screenshot_2015-01-04-12-43-11
screenshot_2015-01-04-12-41-21

MeasureSpec.EXACTLY crash

I'm using the latest library and getting the following in log cat:

java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY. at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:814) at android.view.View.measure(View.java:16628) at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:866) at android.view.View.measure(View.java:16628) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16628) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16628) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16628) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16628) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16628) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2298) at android.view.View.measure(View.java:16628) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5610) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:212) at android.app.ActivityThread.main(ActivityThread.java:5137) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718) at dalvik.system.NativeStart.main(Native Method)

Activated state tinting

Automatically tint icon and text for activated style.

drawer.setActivated(position);

or

drawer.getItem(position).setActivated();

Also reffering to #4.

NullPointerException when attempting to add DrawerItem

I'm trying to get the library working in my project, but I'm getting the error below when I attempt to add the first item to the drawer after the profile. I'm only using setTextPrimary and setOnItemClickListener on the DrawerItem, but a quick review of the source seems to indicate this is supported.

If I only add the DrawerProfile, I do not get the exception, but I don't see the profile section at the top of the drawer, either. Perhaps this is a related issue?

I have gone through the README multiple times, so I'm fairly certain I'm doing things correctly. The only slight difference in my case is that my DrawerView is contained in a dynamically added fragment rather than being a direct child of the DrawerLayout. I briefly tried moving the code out of the fragment and into the activity and its content view, but that didn't change any of the above issues.

Thanks for any help you can provide and also for the time saving library!

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
            at com.heinrichreimersoftware.material_drawer.DrawerAdapter.getView(DrawerAdapter.java:74)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView.setupChildren(LinearListView.java:269)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView.access$000(LinearListView.java:35)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView$1.onChanged(LinearListView.java:53)
            at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
            at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
            at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:286)
            at android.widget.ArrayAdapter.add(ArrayAdapter.java:182)
            at com.heinrichreimersoftware.material_drawer.DrawerView.addItem(DrawerView.java:228)
            at com.chaione.gameplan.sdk.ui.NavigationDrawerFragment.onViewCreated(NavigationDrawerFragment.java:64)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:961)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1243)
            at android.app.Activity.performStart(Activity.java:5969)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)

RTL support for the drawer (open drawer from right of the screen)

Can you explain how can I implement this great navigation drawer to be opened from right to left of the screen. I have tried many ways like android:layout_gravity:right, getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);, or giving LayoutParams to the drawer object but none of them worked for me.

NullPointerException when attempting to add DrawerItem

I'm trying to get the library working in my project, but I'm getting the error below when I attempt to add the first item to the drawer after the profile. I'm only using setTextPrimary and setOnItemClickListener on the `DrawerItem

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
            at com.heinrichreimersoftware.material_drawer.DrawerAdapter.getView(DrawerAdapter.java:74)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView.setupChildren(LinearListView.java:269)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView.access$000(LinearListView.java:35)
            at com.heinrichreimersoftware.material_drawer.widget.LinearListView$1.onChanged(LinearListView.java:53)
            at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
            at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
            at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:286)
            at android.widget.ArrayAdapter.add(ArrayAdapter.java:182)
            at com.heinrichreimersoftware.material_drawer.DrawerView.addItem(DrawerView.java:228)
            at com.chaione.gameplan.sdk.ui.NavigationDrawerFragment.onViewCreated(NavigationDrawerFragment.java:64)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:961)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1243)
            at android.app.Activity.performStart(Activity.java:5969)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)

Method to make drawer appear?

Would be nice if there's a function we can call to surface the drawer other than the slide gesture. I am thinking of adding a button on the footer for users less familiar with android design guideline.

Secondary text and item height

Why don't you make drawer item height dynamic, so we don't have to worry if the secondary text is too long to fit one line? Sure I can change to 2 or 3 lines as I see, but over translations there will be differences. One language will need more lines than another

Single profile avatar

In 2.0, having just a single profile with no avatar set still draws a white circle where the avatar would be. I would expect no avatar or placeholder to be drawn.

Profile don't have mDrawerView

When I update anything on a Profile the notifyDataChanged is never called because the profile isn't attached to a DrawerView. So, looking at the Items code, I would call the mProfile.attachTo(mDrawerProfile), but this trigger a infinite loop between attachTo, notifyDataChanged and setProfile.

I don't think we need the notifyDataChanged on the profile.attachTo, so I removed it. Don't know if this is the best alternative, but it is working 👍

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.