Skip to content

Commit

Permalink
fix field access problem
Browse files Browse the repository at this point in the history
  • Loading branch information
zillachan committed Oct 11, 2017
1 parent a5bfcd2 commit e0522f8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions valizilla/src/main/java/pub/zilla/validzilla/ValiZilla.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public int compare(ValiModel o1, ValiModel o2) {
try {
Class fieldType = model.getField().getType();
if (textInputLayout.isAssignableFrom(fieldType)) {//if is TextInputLayout or extends from TextInputLayout.
Field field = model.getField();
field.setAccessible(true);
TextInputLayout targetField = (TextInputLayout) model.getField().get(target);
String result = targetField.getEditText().getText().toString();//result
if (TextUtils.isEmpty(model.getReg())) {//not null check fail
Expand Down Expand Up @@ -99,6 +101,7 @@ private static ValiWapper getFieldsFromCache(Class c) {
NotNull notNull;
Reg reg;
for (Field field : cFields) {
field.setAccessible(true);
notNull = field.getAnnotation(NotNull.class);
reg = field.getAnnotation(Reg.class);
if (notNull != null || reg != null) {
Expand Down

0 comments on commit e0522f8

Please sign in to comment.