diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index cc71525b..6987c90c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -417,15 +417,7 @@ public class DownloadReceiver extends AbsReceiver { * @return 如果没有任务组列表,则返回null */ public List getGroupTaskList() { - List wrappers = DbEntity.findRelationData(DGEntityWrapper.class); - if (wrappers == null || wrappers.isEmpty()) { - return null; - } - List entities = new ArrayList<>(); - for (DGEntityWrapper wrapper : wrappers) { - entities.add(wrapper.groupEntity); - } - return entities; + return getGroupTaskList(1,10); } /** diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java index 4f0ba511..1128376f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java @@ -215,12 +215,15 @@ class DelegateFind extends AbsDelegate { } else { sql = sb.toString(); } + boolean paged=false; if (page != -1 && num != -1) { - sql = sql.concat(String.format(" LIMIT %s,%s", (page - 1) * num, num)); + paged=true; + sql = sql.concat(String.format(" Group by %s LIMIT %s,%s", pTableName.concat(".").concat(m.parentColumn()), (page - 1) * num, num)); } Cursor cursor = db.rawQuery(sql, null); List data = - newInstanceEntity(wrapperClazz, parentClazz, childClazz, cursor, pColumn, cColumn); + newInstanceEntity(wrapperClazz, parentClazz, childClazz, cursor, pColumn, cColumn,paged, db,m.entityColumn(),m.parentColumn()); + closeCursor(cursor); return data; } catch (ClassNotFoundException e) { @@ -243,7 +246,7 @@ class DelegateFind extends AbsDelegate { Class wrapperClazz, Class

parentClazz, Class childClazz, Cursor cursor, - List pColumn, List cColumn) { + List pColumn, List cColumn,boolean paged,SQLiteDatabase db,String entityColumn,String parentColumn) { List wrappers = new ArrayList<>(); SparseArray> childs = new SparseArray<>(); // 所有子表数据 SparseArray parents = new SparseArray<>(); // 所有父表数据 @@ -255,7 +258,12 @@ class DelegateFind extends AbsDelegate { childs.put(pRowId, new ArrayList()); parents.put(pRowId, createParent(pRowId, parentClazz, pColumn, cursor)); } - childs.get(pRowId).add(createChild(childClazz, cColumn, cursor)); + if(paged){ + childs.get(pRowId).addAll(createChildren(db,childClazz,pColumn,entityColumn,parentColumn,parents.get(pRowId))); + } + else { + childs.get(pRowId).add(createChild(childClazz, cColumn, cursor)); + } } List wFields = SqlUtil.getAllNotIgnoreField(wrapperClazz); @@ -285,7 +293,22 @@ class DelegateFind extends AbsDelegate { return wrappers; } + /** + * 创建子对象集合 + */ + private List createChildren(SQLiteDatabase db,Class childClazz, List pColumn, + String entityColumn,String parentColumn,DbEntity parents) + throws IllegalAccessException { + for (Field field : pColumn) { + field.setAccessible(true); + if(field.getName().equals(parentColumn)){ + Object o = field.get(parents); + return findData(db,childClazz,entityColumn+"='"+o+"'"); + } + } + return new ArrayList(); + } /** * 创建子对象 */