ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
149 stars 60 forks source link

Prevent NullPointerException when app closes and activity is null. #84

Closed Brian-McBride closed 9 years ago

Brian-McBride commented 9 years ago

This catches an instance where the activity has been destroyed but there is still a method call heading out.

manumaticx commented 9 years ago

Hi. Thanks for this. How can I test it?

Brian-McBride commented 9 years ago

In our case, we could close the Ti app. But we might also have a method that was calling setTitle(). For whatever reason, the race condition would end up that that the Activity would close out before setTitle() would be called. Resulting in a nullPointerException as the activity == null.

I also just added to this, a new method "getDrawableFromFont" as a helper and then added in the ability to use fonts in setHomeAsUpIcon.

I just check for a HashMap or String and adjust the icon accordingly.

manumaticx commented 9 years ago

Cool, I really like this. Before merging, can you please exclude all changes from the PR except for the changes on the code (ActionbarextrasModule.java)? I don't want the build.properties, gitignore etc. to be changed. Thanks!