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() {
89
89
XFiler .Mode .Isolating );
90
90
}
91
91
92
-
93
92
/**
94
93
* Returns a pass-through constructor matching the base class's provided constructorElement. The
95
94
* generated constructor simply calls super(), then inject().
@@ -99,7 +98,9 @@ public void generate() {
99
98
* <pre>
100
99
* Hilt_$CLASS(Context context, ...) {
101
100
* super(context, ...);
102
- * inject();
101
+ * if (!isInEditMode()) {
102
+ * inject();
103
+ * }
103
104
* }
104
105
* </pre>
105
106
*/
@@ -117,7 +118,9 @@ private MethodSpec constructorMethod(XConstructorElement constructor) {
117
118
AnnotationSpec .builder (AndroidClassNames .TARGET_API ).addMember ("value" , "21" ).build ());
118
119
}
119
120
120
- builder .addStatement ("inject()" );
121
+ builder .beginControlFlow ("if(!isInEditMode())" )
122
+ .addStatement ("inject()" )
123
+ .endControlFlow ();
121
124
122
125
return builder .build ();
123
126
}
Original file line number Diff line number Diff line change @@ -123,14 +123,18 @@ public void copyConstructorParametersConvertsAndroidInternalNullableToExternal()
123
123
JOINER .join (
124
124
" Hilt_MyView(Context p0, @Nullable AttributeSet p1) {" ,
125
125
" super(p0, p1);" ,
126
- " inject();" ,
126
+ " if(!isInEditMode()) {" ,
127
+ " inject();" ,
128
+ " }" ,
127
129
" }" ));
128
130
} else {
129
131
stringSubject .contains (
130
132
JOINER .join (
131
133
" Hilt_MyView(Context context, @Nullable AttributeSet attrs) {" ,
132
134
" super(context, attrs);" ,
133
- " inject();" ,
135
+ " if(!isInEditMode()) {" ,
136
+ " inject();" ,
137
+ " }" ,
134
138
" }" ));
135
139
}
136
140
});
You can’t perform that action at this time.
0 commit comments