|
18 | 18 | import java.lang.annotation.Annotation; |
19 | 19 |
|
20 | 20 | import javax.lang.model.element.Element; |
| 21 | +import javax.lang.model.type.TypeMirror; |
21 | 22 |
|
22 | 23 | import com.googlecode.androidannotations.annotations.Id; |
23 | 24 | import com.googlecode.androidannotations.model.AndroidRes; |
24 | 25 | import com.googlecode.androidannotations.rclass.IRClass; |
25 | 26 | import com.googlecode.androidannotations.rclass.IRClass.Res; |
26 | 27 | import com.googlecode.androidannotations.rclass.IRInnerClass; |
27 | 28 | import com.sun.codemodel.JBlock; |
| 29 | +import com.sun.codemodel.JClass; |
28 | 30 | import com.sun.codemodel.JCodeModel; |
29 | 31 | import com.sun.codemodel.JExpr; |
30 | 32 | import com.sun.codemodel.JFieldRef; |
@@ -63,14 +65,23 @@ public void process(Element element, JCodeModel codeModel, ActivitiesHolder acti |
63 | 65 | } |
64 | 66 |
|
65 | 67 | JBlock methodBody = holder.beforeSetContentView.body(); |
66 | | - |
67 | | - if (holder.resources == null) { |
68 | | - holder.resources = methodBody.decl(holder.refClass("android.content.res.Resources"), "resources_", JExpr.invoke("getResources")); |
| 68 | + |
| 69 | + TypeMirror fieldTypeMirror = element.asType(); |
| 70 | + String fieldType = fieldTypeMirror.toString(); |
| 71 | + |
| 72 | + // Special case for loading animations |
| 73 | + if ("android.view.animation.Animation".equals(fieldType)) { |
| 74 | + JClass animationUtils = holder.refClass("android.view.animation.AnimationUtils"); |
| 75 | + methodBody.assign(JExpr.ref(fieldName), animationUtils.staticInvoke("loadAnimation").arg(JExpr._this()).arg(idRef)); |
| 76 | + } else { |
| 77 | + if (holder.resources == null) { |
| 78 | + holder.resources = methodBody.decl(holder.refClass("android.content.res.Resources"), "resources_", JExpr.invoke("getResources")); |
| 79 | + } |
| 80 | + |
| 81 | + String resourceMethodName = androidValue.getResourceMethodName(); |
| 82 | + |
| 83 | + methodBody.assign(JExpr.ref(fieldName), JExpr.invoke(holder.resources, resourceMethodName).arg(idRef)); |
69 | 84 | } |
70 | | - |
71 | | - String resourceMethodName = androidValue.getResourceMethodName(); |
72 | | - |
73 | | - methodBody.assign(JExpr.ref(fieldName), JExpr.invoke(holder.resources, resourceMethodName).arg(idRef)); |
74 | 85 |
|
75 | 86 | } |
76 | 87 |
|
|
0 commit comments