/* package */
 public DownloadManager(Context appContext) {
   LogUtils.allowD = true;
   ColumnConverterFactory.registerColumnConverter(
       HttpHandler.State.class, new HttpHandlerStateConverter());
   mContext = appContext;
   db = DbUtils.create(mContext);
   try {
     downloadInfoList = db.findAll(Selector.from(DownloadInfo.class));
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (downloadInfoList == null) {
     downloadInfoList = new ArrayList<DownloadInfo>();
   }
 }
예제 #2
0
  private static void addColumns2Map(
      Class<?> entityType, String primaryKeyFieldName, HashMap<String, Column> columnMap) {
    if (Object.class.equals(entityType)) return;
    try {
      Field[] fields = entityType.getDeclaredFields();
      for (Field field : fields) {
        if (ColumnUtils.isTransient(field) || Modifier.isStatic(field.getModifiers())) {
          continue;
        }
        if (ColumnConverterFactory.isSupportColumnConverter(field.getType())) {
          if (!field.getName().equals(primaryKeyFieldName)) {
            Column column = new Column(entityType, field);
            if (!columnMap.containsKey(column.getColumnName())) {
              columnMap.put(column.getColumnName(), column);
            }
          }
        } else if (ColumnUtils.isForeign(field)) {
          Foreign column = new Foreign(entityType, field);
          if (!columnMap.containsKey(column.getColumnName())) {
            columnMap.put(column.getColumnName(), column);
          }
        } else if (ColumnUtils.isFinder(field)) {
          Finder column = new Finder(entityType, field);
          if (!columnMap.containsKey(column.getColumnName())) {
            columnMap.put(column.getColumnName(), column);
          }
        }
      }

      if (!Object.class.equals(entityType.getSuperclass())) {
        addColumns2Map(entityType.getSuperclass(), primaryKeyFieldName, columnMap);
      }
    } catch (Throwable e) {
      LogUtils.e(e.getMessage(), e);
    }
  }