Fix LayoutlibTestCallback.getResourceId

Return null instead of triggering a NPE when there are no resource of
the asked type.

Test: RenderTests.testFonts
Change-Id: Ib45ebdf2178e62cbd987082512fcbb009de3f1b2
This commit is contained in:
Jerome Gaillard
2017-02-15 15:59:04 +00:00
parent 4211358c74
commit 3a73332350

View File

@@ -132,7 +132,11 @@ public class LayoutLibTestCallback extends LayoutlibCallback {
@Override
public Integer getResourceId(ResourceType type, String name) {
return mResources.get(type).get(name);
Map<String, Integer> resName2Id = mResources.get(type);
if (resName2Id == null) {
return null;
}
return resName2Id.get(name);
}
@Override