修复组任务进度为0的问题

pull/640/head
laoyuyu 5 years ago
parent a1fd63b5c6
commit 9cb6490da9
  1. 5
      Aria/src/main/java/com/arialyy/aria/core/download/CheckDGEntityUtil.java
  2. 8
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java
  3. 7
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java
  4. 6
      PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java
  5. 2
      PublicComponent/src/main/java/com/arialyy/aria/core/group/GroupRunState.java
  6. 21
      PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java
  7. 4
      app/src/main/assets/aria_config.xml
  8. 30
      app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java
  9. 2
      build.gradle

@ -15,7 +15,9 @@
*/ */
package com.arialyy.aria.core.download; package com.arialyy.aria.core.download;
import android.text.LoginFilter;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.common.controller.FeatureController; import com.arialyy.aria.core.common.controller.FeatureController;
import com.arialyy.aria.core.inf.ICheckEntityUtil; import com.arialyy.aria.core.inf.ICheckEntityUtil;
@ -240,9 +242,6 @@ public class CheckDGEntityUtil implements ICheckEntityUtil {
mWrapper.getSubNameTemp().remove(index); mWrapper.getSubNameTemp().remove(index);
} }
} }
mEntity.setGroupHash(CommonUtil.getMd5Code(mEntity.getUrls()));
return true; return true;
} }

@ -108,8 +108,14 @@ public final class HttpDGInfoTask implements IInfoTask {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override public void run() { @Override public void run() {
for (DTaskWrapper dTaskWrapper : wrapper.getSubTaskWrapper()) { for (DTaskWrapper dTaskWrapper : wrapper.getSubTaskWrapper()) {
if (dTaskWrapper.getEntity().getFileSize() > 0) { DownloadEntity subEntity = dTaskWrapper.getEntity();
if (subEntity.getFileSize() > 0) {
count.getAndIncrement(); count.getAndIncrement();
if (subEntity.getCurrentProgress() < subEntity.getFileSize()){
// 如果没有完成需要拷贝一份数据
cloneHeader(dTaskWrapper);
}
checkGetSizeComplete(count.get(), failCount.get());
continue; continue;
} }
cloneHeader(dTaskWrapper); cloneHeader(dTaskWrapper);

@ -54,13 +54,8 @@ final class HttpDGLoader extends AbsGroupLoader {
} }
onPostStart(); onPostStart();
for (DTaskWrapper wrapper : getWrapper().getSubTaskWrapper()) { for (DTaskWrapper wrapper : getWrapper().getSubTaskWrapper()) {
File subFile = new File(wrapper.getEntity().getFilePath());
if (wrapper.getEntity().getFileSize() > 0
&& subFile.exists()
&& subFile.length() == wrapper.getEntity().getFileSize()) {
continue;
}
DownloadEntity dEntity = wrapper.getEntity(); DownloadEntity dEntity = wrapper.getEntity();
startSubLoader(createSubLoader(wrapper, dEntity.getFileSize() < 0)); startSubLoader(createSubLoader(wrapper, dEntity.getFileSize() < 0));
} }
} }

@ -101,12 +101,12 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) { for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) {
long fileLen = checkFileExists(wrapper.getEntity().getFilePath()); long fileLen = checkFileExists(wrapper.getEntity().getFilePath());
if (wrapper.getEntity().getState() == IEntity.STATE_COMPLETE if (wrapper.getEntity().getState() == IEntity.STATE_COMPLETE
&& fileLen != -1 && fileLen > 0
&& fileLen == wrapper.getEntity().getFileSize()) { && fileLen == wrapper.getEntity().getFileSize()) {
mState.updateCompleteNum(); //mState.updateCompleteNum();
mCurrentLocation += wrapper.getEntity().getFileSize(); mCurrentLocation += wrapper.getEntity().getFileSize();
} else { } else {
if (fileLen == -1) { if (fileLen <= 0) {
wrapper.getEntity().setCurrentProgress(0); wrapper.getEntity().setCurrentProgress(0);
} }
wrapper.getEntity().setState(IEntity.STATE_POST_PRE); wrapper.getEntity().setState(IEntity.STATE_POST_PRE);

@ -17,6 +17,7 @@ package com.arialyy.aria.core.group;
import com.arialyy.aria.core.listener.IDGroupListener; import com.arialyy.aria.core.listener.IDGroupListener;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.ALog;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -26,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* 组合任务执行中的状态信息 * 组合任务执行中的状态信息
*/ */
public final class GroupRunState { public final class GroupRunState {
private String TAG = "GroupRunState";
/** /**
* 子任务数 * 子任务数
*/ */

@ -219,11 +219,13 @@ class DelegateFind extends AbsDelegate {
boolean paged = false; boolean paged = false;
if (page != -1 && num != -1) { if (page != -1 && num != -1) {
paged = true; paged = true;
sql = sql.concat(String.format(" Group by %s LIMIT %s,%s", pTableName.concat(".").concat(m.parentColumn()), (page - 1) * num, num)); 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); Cursor cursor = db.rawQuery(sql, null);
List<T> data = List<T> data =
newInstanceEntity(wrapperClazz, parentClazz, childClazz, cursor, pColumn, cColumn,paged, db,m.entityColumn(),m.parentColumn()); newInstanceEntity(wrapperClazz, parentClazz, childClazz, cursor, pColumn, cColumn,
paged, db, m.entityColumn(), m.parentColumn());
closeCursor(cursor); closeCursor(cursor);
return data; return data;
@ -247,7 +249,8 @@ class DelegateFind extends AbsDelegate {
Class<T> wrapperClazz, Class<P> parentClazz, Class<T> wrapperClazz, Class<P> parentClazz,
Class<C> childClazz, Class<C> childClazz,
Cursor cursor, Cursor cursor,
List<Field> pColumn, List<Field> cColumn,boolean paged,SQLiteDatabase db,String entityColumn,String parentColumn) { List<Field> pColumn, List<Field> cColumn, boolean paged, SQLiteDatabase db,
String entityColumn, String parentColumn) {
List<T> wrappers = new ArrayList<>(); List<T> wrappers = new ArrayList<>();
SparseArray<List<DbEntity>> childs = new SparseArray<>(); // 所有子表数据 SparseArray<List<DbEntity>> childs = new SparseArray<>(); // 所有子表数据
SparseArray<DbEntity> parents = new SparseArray<>(); // 所有父表数据 SparseArray<DbEntity> parents = new SparseArray<>(); // 所有父表数据
@ -260,11 +263,12 @@ class DelegateFind extends AbsDelegate {
parents.put(pRowId, createParent(pRowId, parentClazz, pColumn, cursor)); parents.put(pRowId, createParent(pRowId, parentClazz, pColumn, cursor));
} }
if (paged) { if (paged) {
List<C> list = createChildren(db, childClazz, pColumn, entityColumn, parentColumn, parents.get(pRowId)); List<C> list = createChildren(db, childClazz, pColumn, entityColumn, parentColumn,
if(list!=null) parents.get(pRowId));
if (list != null) {
childs.get(pRowId).addAll(list); childs.get(pRowId).addAll(list);
} }
else { } else {
childs.get(pRowId).add(createChild(childClazz, cColumn, cursor)); childs.get(pRowId).add(createChild(childClazz, cColumn, cursor));
} }
} }
@ -296,10 +300,12 @@ class DelegateFind extends AbsDelegate {
return wrappers; return wrappers;
} }
/** /**
* 创建子对象集合 * 创建子对象集合
*/ */
private <T extends DbEntity> List<T> createChildren(SQLiteDatabase db,Class<T> childClazz, List<Field> pColumn, private <T extends DbEntity> List<T> createChildren(SQLiteDatabase db, Class<T> childClazz,
List<Field> pColumn,
String entityColumn, String parentColumn, DbEntity parents) String entityColumn, String parentColumn, DbEntity parents)
throws IllegalAccessException { throws IllegalAccessException {
@ -315,6 +321,7 @@ class DelegateFind extends AbsDelegate {
} }
return new ArrayList<T>(); return new ArrayList<T>();
} }
/** /**
* 创建子对象 * 创建子对象
*/ */

@ -22,7 +22,7 @@
<download> <download>
<!--设置任务最大下载速度,0表示不限速,单位为:kb--> <!--设置任务最大下载速度,0表示不限速,单位为:kb-->
<maxSpeed value="200"/> <maxSpeed value="0"/>
<!-- <!--
多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用 多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用
@ -32,7 +32,7 @@
3、只对新的多线程下载任务有效 3、只对新的多线程下载任务有效
4、只对多线程的任务有效 4、只对多线程的任务有效
--> -->
<useBlock value="false"/> <useBlock value="true"/>
<!--设置下载线程数,下载线程数不能小于1 <!--设置下载线程数,下载线程数不能小于1
注意: 注意:

@ -32,15 +32,13 @@ public class GroupModule extends BaseModule {
public List<String> getUrls() { public List<String> getUrls() {
List<String> urls = new ArrayList<>(); List<String> urls = new ArrayList<>();
//urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924275&di=a7ea1497a4a2528a45ce7103bf61adf4&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fc2cec3fdfc03924590b2a9b58d94a4c27d1e2500.jpg"); String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
//urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg"); Collections.addAll(urls, str);
//String[] str = getContext().getResources().getStringArray(R.array.group_urls_1); //urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-9/fr/cp0/e15/q65/85148967_168821394550033_6164348723502514176_n.jpg?_nc_cat=105&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQni9wIDOcxkQGfqH7jFwLuRWV3cIi0We11MXp1V0_vfrQ3-SBV4Ue034aJXzzIzdNI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=14&oh=37829bbfd4f7179fcc3527a7a7971f53&oe=5F00FC35");
//Collections.addAll(urls, str); //urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/84206444_168821471216692_7979166053252988928_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQny1ZTkxw-sq4mSH2TThaQNRJB89uKG2cW9e3DgcI78qXE7b8Jlyox749lXkcngYBs&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6714e2c9b3d76e12eff960b6aa22cdfb&oe=5EEE640F");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-9/fr/cp0/e15/q65/85148967_168821394550033_6164348723502514176_n.jpg?_nc_cat=105&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQni9wIDOcxkQGfqH7jFwLuRWV3cIi0We11MXp1V0_vfrQ3-SBV4Ue034aJXzzIzdNI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=14&oh=37829bbfd4f7179fcc3527a7a7971f53&oe=5F00FC35"); //urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/86702402_168821534550019_6064732312896012288_n.jpg?_nc_cat=101&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQnfJfW55cqVfs0lzZOjEa8kGoxvrA--\\brjaelZgcf8MzqQUhjH3moqGoekMQlATXRM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=96f4f776c05b2c200cfb720fa36f938b&oe=5EFA310D");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/84206444_168821471216692_7979166053252988928_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQny1ZTkxw-sq4mSH2TThaQNRJB89uKG2cW9e3DgcI78qXE7b8Jlyox749lXkcngYBs&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6714e2c9b3d76e12eff960b6aa22cdfb&oe=5EEE640F"); //urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/85236032_168821577883348_2800973234302877696_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQlNvaTlYUspquMWBLnkgVOHdzG4pX2XW3NSHYxvVYsaJF8Ehy9tGn6R6Ned5UwcwAM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6fd5e6442712e4da111d09e8902c68c5&oe=5EFE1528");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/86702402_168821534550019_6064732312896012288_n.jpg?_nc_cat=101&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQnfJfW55cqVfs0lzZOjEa8kGoxvrA--\\brjaelZgcf8MzqQUhjH3moqGoekMQlATXRM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=96f4f776c05b2c200cfb720fa36f938b&oe=5EFA310D"); //urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p120x120/80398195_141232180642288_3692820603451998208_n.jpg?_nc_cat=109&_nc_sid=dbb9e7&efg=eyJpIjoidCJ9&_nc_oc=AQmsZxgvLgoObkqHbcKS8qIZ3w_QhssRwLSF5o-8P6q_kf962w32kmjLqcg6lH9qxWI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=269e655e7b901e8d07d9362142a0fdda&oe=5EF43734");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/85236032_168821577883348_2800973234302877696_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQlNvaTlYUspquMWBLnkgVOHdzG4pX2XW3NSHYxvVYsaJF8Ehy9tGn6R6Ned5UwcwAM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6fd5e6442712e4da111d09e8902c68c5&oe=5EFE1528");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p120x120/80398195_141232180642288_3692820603451998208_n.jpg?_nc_cat=109&_nc_sid=dbb9e7&efg=eyJpIjoidCJ9&_nc_oc=AQmsZxgvLgoObkqHbcKS8qIZ3w_QhssRwLSF5o-8P6q_kf962w32kmjLqcg6lH9qxWI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=269e655e7b901e8d07d9362142a0fdda&oe=5EF43734");
return urls; return urls;
} }
@ -55,13 +53,13 @@ public class GroupModule extends BaseModule {
List<String> getSubName() { List<String> getSubName() {
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
//String[] str = getContext().getResources().getStringArray(R.array.group_names); String[] str = getContext().getResources().getStringArray(R.array.group_names);
//Collections.addAll(names, str); Collections.addAll(names, str);
names.add("1.png"); //names.add("1.png");
names.add("2.png"); //names.add("2.png");
names.add("3.png"); //names.add("3.png");
names.add("4.png"); //names.add("4.png");
names.add("5.png"); //names.add("5.png");
return names; return names;
} }

@ -45,7 +45,7 @@ task clean(type: Delete) {
ext { ext {
versionCode = 387 versionCode = 387
versionName = '3.8.7-beta-4' versionName = '3.8.7-beta-5'
userOrg = 'arialyy' userOrg = 'arialyy'
groupId = 'com.arialyy.aria' groupId = 'com.arialyy.aria'
publishVersion = versionName publishVersion = versionName

Loading…
Cancel
Save