Skip to content

Commit

Permalink
Avoid nullpointer exception when optional extras are left out
Browse files Browse the repository at this point in the history
  • Loading branch information
emilsjolander committed Jun 28, 2015
1 parent 64bc38f commit c778b7e
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ private TypeSpec getBuilderSpec(Element annotatedElement) {
.addStatement("$T extras = intent.getExtras()", Bundle.class);
for (Element e : all) {
String paramName = e.getSimpleName().toString();
injectMethod.beginControlFlow("if (extras.containsKey($S))", paramName);
injectMethod.addStatement("activity.$N = ($T) extras.get($S)", paramName, e.asType(), paramName);
injectMethod.endControlFlow();
}
builder.addMethod(injectMethod.build());

Expand Down

0 comments on commit c778b7e

Please sign in to comment.