File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
javatests/dagger/hilt/android/processor/internal
java/dagger/hilt/android/processor/internal/androidentrypoint Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,6 @@ public void generate() {
8989 XFiler .Mode .Isolating );
9090 }
9191
92-
9392 /**
9493 * Returns a pass-through constructor matching the base class's provided constructorElement. The
9594 * generated constructor simply calls super(), then inject().
@@ -99,7 +98,9 @@ public void generate() {
9998 * <pre>
10099 * Hilt_$CLASS(Context context, ...) {
101100 * super(context, ...);
102- * inject();
101+ * if (!isInEditMode()) {
102+ * inject();
103+ * }
103104 * }
104105 * </pre>
105106 */
@@ -117,7 +118,9 @@ private MethodSpec constructorMethod(XConstructorElement constructor) {
117118 AnnotationSpec .builder (AndroidClassNames .TARGET_API ).addMember ("value" , "21" ).build ());
118119 }
119120
120- builder .addStatement ("inject()" );
121+ builder .beginControlFlow ("if(!isInEditMode())" )
122+ .addStatement ("inject()" )
123+ .endControlFlow ();
121124
122125 return builder .build ();
123126 }
Original file line number Diff line number Diff line change @@ -123,14 +123,18 @@ public void copyConstructorParametersConvertsAndroidInternalNullableToExternal()
123123 JOINER .join (
124124 " Hilt_MyView(Context p0, @Nullable AttributeSet p1) {" ,
125125 " super(p0, p1);" ,
126- " inject();" ,
126+ " if(!isInEditMode()) {" ,
127+ " inject();" ,
128+ " }" ,
127129 " }" ));
128130 } else {
129131 stringSubject .contains (
130132 JOINER .join (
131133 " Hilt_MyView(Context context, @Nullable AttributeSet attrs) {" ,
132134 " super(context, attrs);" ,
133- " inject();" ,
135+ " if(!isInEditMode()) {" ,
136+ " inject();" ,
137+ " }" ,
134138 " }" ));
135139 }
136140 });
You can’t perform that action at this time.
0 commit comments