Fix isThemeAppCompat NPE when using an invalid theme

When the theme does not longer exists on the Android Studio side,
getDefaultTheme will return null causing isThemeAppCompat to crash.

Change-Id: I5a5c17126dce72e9872522643219b9438666bc04
This commit is contained in:
Diego Perez
2015-04-21 11:33:55 +01:00
parent 220f360e02
commit 6aa5a44d9b

View File

@@ -1199,15 +1199,15 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
// between Theme.AppCompat.Light and Theme.AppCompat is Theme.Material (for v21).
boolean isThemeAppCompat = false;
for (int i = 0; i < 50; i++) {
if (defaultTheme == null) {
break;
}
// for loop ensures that we don't run into cyclic theme inheritance.
if (defaultTheme.getName().startsWith("Theme.AppCompat")) {
isThemeAppCompat = true;
break;
}
defaultTheme = resources.getParent(defaultTheme);
if (defaultTheme == null) {
break;
}
}
mIsThemeAppCompat = isThemeAppCompat;
}