Beispiel #1
0
 public static int initWindow(BaseActivity activity) throws Exception {
   try {
     Class<? extends BaseActivity> cls = activity.getClass();
     ELayout eView = cls.getAnnotation(ELayout.class);
     if (eView != null) {
       int id = eView.Layout();
       activity.setContentView(id);
       return id;
     } else {
       throw new Exception("XML File Not Found!");
     }
   } catch (Exception e) {
     if (LogConfig.Debug) Logs.logE(e);
     throw new Exception("XML File Not Found!");
   }
 }
Beispiel #2
0
 public static void initWidget(BaseActivity activity) {
   Field[] fields = activity.getClass().getDeclaredFields();
   if (fields != null && fields.length > 0) {
     for (Field field : fields) {
       EWidget viewInject = field.getAnnotation(EWidget.class);
       if (viewInject != null) {
         int viewId = viewInject.id();
         int parent = viewInject.parentId();
         try {
           field.setAccessible(true);
           if (parent == 0) {
             field.set(activity, activity.findViewById(viewId));
           } else {
             field.set(activity, activity.findViewById(parent).findViewById(viewId));
           }
         } catch (Exception e) {
           if (LogConfig.Debug) Logs.logE(e);
         }
       }
     }
   }
 }