JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 526 forks source link

Drawables returning as null #99

Closed MatthewBooth closed 9 years ago

MatthewBooth commented 9 years ago

Using the below code:

menuItem.setIcon(new IconDrawable(this, Iconify.IconValue.fa_refresh)
                .colorRes(typedArray.getResourceId(0, Color.BLACK))
                .sizeDp(16));

As of 1.0.10 for some reason this returns null and throws an exception. If I replace that with a resource id (R.drawable.something_here) the icon (something_here) shows. So I've narrowed this down exactly to Iconify. The same code was working before 1.0.10, but I was forced to update to 1.0.10 due to a missing font, for whatever reason that happened.

MatthewBooth commented 9 years ago

Where are my manners, here's a snippet of the logcat

 java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable()' on a null object reference
            at android.support.design.internal.NavigationMenuItemView.setIcon(NavigationMenuItemView.java:113)
            at android.support.design.internal.NavigationMenuItemView.initialize(NavigationMenuItemView.java:72)
            at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.getView(NavigationMenuPresenter.java:305)
            at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
            at android.widget.AbsListView.obtainView(AbsListView.java:2347)
            at android.widget.ListView.makeAndAddView(ListView.java:1864)
MatthewBooth commented 9 years ago

The typedArray works fine, btw, also. Just ruling that out.

MatthewBooth commented 9 years ago

Nevermind, this was fixed by reverting to support libraries: 22.2.0. My bad.

JoanZapata commented 9 years ago

93 for reference.

MatthewBooth commented 9 years ago

How on earth did I miss #93 :/

Cheers!