From c402dde329cfcd615be71735ce32c1d0b0415518 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 23 May 2017 22:07:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9F=E5=BA=A6=E5=8D=95=E4=BD=8D=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/modules.xml | 2 +- .../com/arialyy/aria/core/ConfigHelper.java | 13 +++ .../com/arialyy/aria/core/Configuration.java | 15 +++ .../aria/core/download/DownloadEntity.java | 27 ++--- .../aria/core/download/DownloadTask.java | 72 +++++++----- .../java/com/arialyy/aria/core/inf/ITask.java | 8 ++ .../aria/core/upload/UploadEntity.java | 11 ++ .../arialyy/aria/core/upload/UploadTask.java | 104 ++++++++++++------ .../java/com/arialyy/aria/orm/DBConfig.java | 2 +- app/src/main/assets/aria_config.xml | 2 +- .../simple/download/DownloadDialog.java | 6 +- .../simple/download/SingleTaskActivity.java | 2 +- .../fragment_download/DownloadFragment.java | 2 +- .../multi_download/DownloadAdapter.java | 3 +- gradle.properties | 4 - 15 files changed, 189 insertions(+), 84 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 9f4bd159..5f6de159 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,8 @@ - + diff --git a/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java b/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java index dcb9cb68..28065ee7 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java @@ -80,10 +80,23 @@ public class ConfigHelper extends DefaultHandler { String caPath = attributes.getValue("path"); loadCA(caName, caPath); break; + case "convertSpeed": + loadConvertSpeed(value); + break; } } } + private void loadConvertSpeed(String value) { + boolean open = Boolean.parseBoolean(value); + if (isDownloadConfig) { + mDownloadConfig.isConvertSpeed = open; + } + if (isUploadConfig) { + mUploadConfig.isConvertSpeed = open; + } + } + private void loadReTryInterval(String value) { int time = 2 * 1000; if (!TextUtils.isEmpty(value)) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/Configuration.java b/Aria/src/main/java/com/arialyy/aria/core/Configuration.java index 260281ac..ccc040c0 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/Configuration.java +++ b/Aria/src/main/java/com/arialyy/aria/core/Configuration.java @@ -63,6 +63,11 @@ class Configuration { */ int connectTimeOut = 5000; + /** + * 是否需要转换速度单位,转换完成后为:1b/s、1k/s、1m/s、1g/s、1t/s,如果不需要将返回byte长度 + */ + boolean isConvertSpeed = false; + public boolean isOpenBreadCast() { return isOpenBreadCast; } @@ -105,6 +110,16 @@ class Configuration { return this; } + public boolean isConvertSpeed() { + return isConvertSpeed; + } + + public BaseConfig setConvertSpeed(boolean convertSpeed) { + isConvertSpeed = convertSpeed; + saveKey("isConvertSpeed", isConvertSpeed + ""); + return this; + } + public int getConnectTimeOut() { return connectTimeOut; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java index f2ddb057..65dcfc28 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java @@ -31,6 +31,7 @@ import com.arialyy.aria.orm.DbEntity; */ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { @Ignore private long speed = 0; //下载速度 + @Ignore private String convertSpeed = "0b/s"; @Ignore private int failNum = 0; private String downloadUrl = ""; //下载路径 private String downloadPath = ""; //保存路径 @@ -43,19 +44,10 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { private long completeTime; //完成时间 private boolean isRedirect = false; private String redirectUrl = ""; //重定向链接 - private int threadNum; //下载线程数 public DownloadEntity() { } - public int getThreadNum() { - return threadNum; - } - - public void setThreadNum(int threadNum) { - this.threadNum = threadNum; - } - public String getStr() { return str; } @@ -131,6 +123,14 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { isDownloadComplete = downloadComplete; } + public String getConvertSpeed() { + return convertSpeed; + } + + public void setConvertSpeed(String convertSpeed) { + this.convertSpeed = convertSpeed; + } + public long getSpeed() { return speed; } @@ -171,6 +171,9 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { return "DownloadEntity{" + "speed=" + speed + + ", convertSpeed='" + + convertSpeed + + '\'' + ", failNum=" + failNum + ", downloadUrl='" @@ -200,8 +203,6 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { + ", redirectUrl='" + redirectUrl + '\'' - + ", threadNum=" - + threadNum + '}'; } @@ -211,6 +212,7 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeLong(this.speed); + dest.writeString(this.convertSpeed); dest.writeInt(this.failNum); dest.writeString(this.downloadUrl); dest.writeString(this.downloadPath); @@ -223,11 +225,11 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { dest.writeLong(this.completeTime); dest.writeByte(this.isRedirect ? (byte) 1 : (byte) 0); dest.writeString(this.redirectUrl); - dest.writeInt(this.threadNum); } protected DownloadEntity(Parcel in) { this.speed = in.readLong(); + this.convertSpeed = in.readString(); this.failNum = in.readInt(); this.downloadUrl = in.readString(); this.downloadPath = in.readString(); @@ -240,7 +242,6 @@ public class DownloadEntity extends DbEntity implements Parcelable, IEntity { this.completeTime = in.readLong(); this.isRedirect = in.readByte() != 0; this.redirectUrl = in.readString(); - this.threadNum = in.readInt(); } @Ignore public static final Creator CREATOR = new Creator() { diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java index 35645c25..059db183 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java @@ -40,32 +40,53 @@ public class DownloadTask implements ITask { */ private String mTargetName; private DownloadEntity mEntity; - private DownloadTaskEntity mTaskEntity; private IDownloadListener mListener; private Handler mOutHandler; private IDownloadUtil mUtil; private Context mContext; private DownloadTask(DownloadTaskEntity taskEntity, Handler outHandler) { - mTaskEntity = taskEntity; mEntity = taskEntity.downloadEntity; mOutHandler = outHandler; mContext = AriaManager.APP; - init(); - } - - private void init() { mListener = new DListener(mContext, this, mOutHandler); - mUtil = new DownloadUtil(mContext, mTaskEntity, mListener); + mUtil = new DownloadUtil(mContext, taskEntity, mListener); } /** - * 获取下载速度 + * @return 返回原始byte速度,需要你在配置文件中配置 + *
+   *   
+   *    ...
+   *    
+   *   
+   *
+   *  或在代码中设置
+   *  Aria.get(this).getDownloadConfig().setConvertSpeed(false);
+   * 
+ * 才能生效 */ @Override public long getSpeed() { return mEntity.getSpeed(); } + /** + * @return 返回转换单位后的速度,需要你在配置文件中配置,转换完成后为:1b/s、1k/s、1m/s、1g/s、1t/s + *
+   *   
+   *    ...
+   *    
+   *   
+   *
+   *  或在代码中设置
+   *  Aria.get(this).getDownloadConfig().setConvertSpeed(true);
+   * 
+ * 才能生效 + */ + @Override public String getConvertSpeed() { + return mEntity.getConvertSpeed(); + } + /** * 获取文件大小 */ @@ -182,7 +203,6 @@ public class DownloadTask implements ITask { public static class Builder { DownloadTaskEntity taskEntity; Handler outHandler; - int threadNum = 3; String targetName; public Builder(String targetName, DownloadTaskEntity taskEntity) { @@ -201,14 +221,6 @@ public class DownloadTask implements ITask { return this; } - /** - * 设置线程数 - */ - public Builder setThreadNum(int threadNum) { - this.threadNum = threadNum; - return this; - } - public DownloadTask build() { DownloadTask task = new DownloadTask(taskEntity, outHandler); task.setTargetName(targetName); @@ -225,7 +237,6 @@ public class DownloadTask implements ITask { WeakReference wTask; Context context; Intent sendIntent; - long INTERVAL = 1024 * 10; //10k大小的间隔 long lastLen = 0; //上一次发送长度 long lastTime = 0; long INTERVAL_TIME = 1000; //1m更新周期 @@ -233,6 +244,7 @@ public class DownloadTask implements ITask { DownloadEntity downloadEntity; DownloadTask task; boolean isOpenBroadCast = false; + boolean isConvertSpeed = false; DListener(Context context, DownloadTask task, Handler outHandler) { this.context = context; @@ -242,7 +254,9 @@ public class DownloadTask implements ITask { this.downloadEntity = this.task.getDownloadEntity(); sendIntent = CommonUtil.createIntent(context.getPackageName(), Aria.ACTION_RUNNING); sendIntent.putExtra(Aria.ENTITY, downloadEntity); - isOpenBroadCast = AriaManager.getInstance(context).getDownloadConfig().isOpenBreadCast(); + final AriaManager manager = AriaManager.getInstance(context); + isOpenBroadCast = manager.getDownloadConfig().isOpenBreadCast(); + isConvertSpeed = manager.getDownloadConfig().isConvertSpeed(); } @Override public void supportBreakpoint(boolean support) { @@ -289,11 +303,10 @@ public class DownloadTask implements ITask { sendIntent.putExtra(Aria.CURRENT_SPEED, speed); lastTime = System.currentTimeMillis(); if (isFirst) { - downloadEntity.setSpeed(0); + speed = 0; isFirst = false; - } else { - downloadEntity.setSpeed(speed); } + handleSpeed(speed); downloadEntity.setCurrentProgress(currentLocation); lastLen = currentLocation; sendInState2Target(DownloadSchedulers.RUNNING); @@ -304,7 +317,7 @@ public class DownloadTask implements ITask { @Override public void onStop(long stopLocation) { super.onStop(stopLocation); downloadEntity.setState(DownloadEntity.STATE_STOP); - downloadEntity.setSpeed(0); + handleSpeed(0); sendInState2Target(DownloadSchedulers.STOP); sendIntent(Aria.ACTION_STOP, stopLocation); } @@ -312,6 +325,7 @@ public class DownloadTask implements ITask { @Override public void onCancel() { super.onCancel(); downloadEntity.setState(DownloadEntity.STATE_CANCEL); + handleSpeed(0); sendInState2Target(DownloadSchedulers.CANCEL); sendIntent(Aria.ACTION_CANCEL, -1); downloadEntity.deleteData(); @@ -321,7 +335,7 @@ public class DownloadTask implements ITask { super.onComplete(); downloadEntity.setState(DownloadEntity.STATE_COMPLETE); downloadEntity.setDownloadComplete(true); - downloadEntity.setSpeed(0); + handleSpeed(0); sendInState2Target(DownloadSchedulers.COMPLETE); sendIntent(Aria.ACTION_COMPLETE, downloadEntity.getFileSize()); } @@ -330,11 +344,19 @@ public class DownloadTask implements ITask { super.onFail(); downloadEntity.setFailNum(downloadEntity.getFailNum() + 1); downloadEntity.setState(DownloadEntity.STATE_FAIL); - downloadEntity.setSpeed(0); + handleSpeed(0); sendInState2Target(DownloadSchedulers.FAIL); sendIntent(Aria.ACTION_FAIL, -1); } + private void handleSpeed(long speed) { + if (isConvertSpeed) { + downloadEntity.setConvertSpeed(CommonUtil.formatFileSize(speed) + "/s"); + } else { + downloadEntity.setSpeed(speed); + } + } + /** * 将任务状态发送给下载器 * diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java b/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java index e9b75864..d8aa1607 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java @@ -44,8 +44,16 @@ public interface ITask { public void cancel(); + /** + * 原始byte速度 + */ public long getSpeed(); + /** + * 转换单位后的速度 + */ + public String getConvertSpeed(); + public long getFileSize(); public long getCurrentProgress(); diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java index dd4a54eb..816cb24c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java @@ -34,8 +34,17 @@ public class UploadEntity extends DbEntity implements IEntity, Parcelable { private long currentProgress = 0; private boolean isComplete = false; @Ignore private long speed = 0; //下载速度 + @Ignore private String convertSpeed = "0/s"; @Ignore private int failNum = 0; + public String getConvertSpeed() { + return convertSpeed; + } + + public void setConvertSpeed(String convertSpeed) { + this.convertSpeed = convertSpeed; + } + public boolean isComplete() { return isComplete; } @@ -115,6 +124,7 @@ public class UploadEntity extends DbEntity implements IEntity, Parcelable { dest.writeLong(this.currentProgress); dest.writeByte(this.isComplete ? (byte) 1 : (byte) 0); dest.writeLong(this.speed); + dest.writeString(this.convertSpeed); dest.writeInt(this.failNum); } @@ -126,6 +136,7 @@ public class UploadEntity extends DbEntity implements IEntity, Parcelable { this.currentProgress = in.readLong(); this.isComplete = in.readByte() != 0; this.speed = in.readLong(); + this.convertSpeed = in.readString(); this.failNum = in.readInt(); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java index 8772b9fd..bc5c2d76 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java @@ -36,19 +36,17 @@ import java.lang.ref.WeakReference; public class UploadTask implements ITask { private static final String TAG = "UploadTask"; private Handler mOutHandler; - private UploadTaskEntity mTaskEntity; private UploadEntity mUploadEntity; private String mTargetName; private UploadUtil mUtil; private UListener mListener; - UploadTask(UploadTaskEntity taskEntity, Handler outHandler) { - mTaskEntity = taskEntity; + private UploadTask(UploadTaskEntity taskEntity, Handler outHandler) { mOutHandler = outHandler; - mUploadEntity = mTaskEntity.uploadEntity; + mUploadEntity = taskEntity.uploadEntity; mListener = new UListener(mOutHandler, this); - mUtil = new UploadUtil(mTaskEntity, mListener); + mUtil = new UploadUtil(taskEntity, mListener); } @Override public void setTargetName(String targetName) { @@ -110,10 +108,41 @@ public class UploadTask implements ITask { return mTargetName; } + /** + * @return 返回原始byte速度,需要你在配置文件中配置 + *
+   *   
+   *    ...
+   *    
+   *   
+   *
+   *  或在代码中设置
+   *  Aria.get(this).getUploadConfig().setConvertSpeed(false);
+   * 
+ * 才能生效 + */ @Override public long getSpeed() { return mUploadEntity.getSpeed(); } + /** + * @return 返回转换单位后的速度,需要你在配置文件中配置,转换完成后为:1b/s、1k/s、1m/s、1g/s、1t/s + *
+   *   
+   *    ...
+   *    
+   *   
+   *
+   *  或在代码中设置
+   *  Aria.get(this).getUploadConfig().setConvertSpeed(true);
+   * 
+ * + * 才能生效 + */ + @Override public String getConvertSpeed() { + return mUploadEntity.getConvertSpeed(); + } + @Override public long getFileSize() { return mUploadEntity.getFileSize(); } @@ -129,43 +158,46 @@ public class UploadTask implements ITask { long lastTime = 0; long INTERVAL_TIME = 1000; //1m更新周期 boolean isFirst = true; - UploadEntity entity; + UploadEntity uploadEntity; Intent sendIntent; boolean isOpenBroadCast = false; + boolean isConvertSpeed = false; Context context; UListener(Handler outHandle, UploadTask task) { this.outHandler = new WeakReference<>(outHandle); this.task = new WeakReference<>(task); - entity = this.task.get().getUploadEntity(); + uploadEntity = this.task.get().getUploadEntity(); sendIntent = CommonUtil.createIntent(AriaManager.APP.getPackageName(), Aria.ACTION_RUNNING); - sendIntent.putExtra(Aria.ENTITY, entity); + sendIntent.putExtra(Aria.ENTITY, uploadEntity); context = AriaManager.APP; - isOpenBroadCast = AriaManager.getInstance(context).getUploadConfig().isOpenBreadCast(); + final AriaManager manager = AriaManager.getInstance(context); + isOpenBroadCast = manager.getUploadConfig().isOpenBreadCast(); + isConvertSpeed = manager.getUploadConfig().isConvertSpeed(); } @Override public void onPre() { - entity.setState(IEntity.STATE_PRE); + uploadEntity.setState(IEntity.STATE_PRE); sendIntent(Aria.ACTION_PRE, -1); sendInState2Target(ISchedulers.PRE); } @Override public void onStart(long fileSize) { - entity.setFileSize(fileSize); - entity.setState(IEntity.STATE_RUNNING); + uploadEntity.setFileSize(fileSize); + uploadEntity.setState(IEntity.STATE_RUNNING); sendIntent(Aria.ACTION_PRE, -1); sendInState2Target(ISchedulers.START); } @Override public void onResume(long resumeLocation) { - entity.setState(DownloadEntity.STATE_RUNNING); + uploadEntity.setState(DownloadEntity.STATE_RUNNING); sendInState2Target(DownloadSchedulers.RESUME); sendIntent(Aria.ACTION_RESUME, resumeLocation); } @Override public void onStop(long stopLocation) { - entity.setState(DownloadEntity.STATE_STOP); - entity.setSpeed(0); + uploadEntity.setState(DownloadEntity.STATE_STOP); + handleSpeed(0); sendInState2Target(DownloadSchedulers.STOP); sendIntent(Aria.ACTION_STOP, stopLocation); } @@ -177,12 +209,11 @@ public class UploadTask implements ITask { sendIntent.putExtra(Aria.CURRENT_SPEED, speed); lastTime = System.currentTimeMillis(); if (isFirst) { - entity.setSpeed(0); + speed = 0; isFirst = false; - } else { - entity.setSpeed(speed); } - entity.setCurrentProgress(currentLocation); + handleSpeed(speed); + uploadEntity.setCurrentProgress(currentLocation); lastLen = currentLocation; sendInState2Target(DownloadSchedulers.RUNNING); AriaManager.APP.sendBroadcast(sendIntent); @@ -190,28 +221,37 @@ public class UploadTask implements ITask { } @Override public void onCancel() { - entity.setState(DownloadEntity.STATE_CANCEL); + uploadEntity.setState(DownloadEntity.STATE_CANCEL); + handleSpeed(0); sendInState2Target(DownloadSchedulers.CANCEL); sendIntent(Aria.ACTION_CANCEL, -1); - entity.deleteData(); + uploadEntity.deleteData(); } @Override public void onComplete() { - entity.setState(DownloadEntity.STATE_COMPLETE); - entity.setComplete(true); - entity.setSpeed(0); + uploadEntity.setState(DownloadEntity.STATE_COMPLETE); + uploadEntity.setComplete(true); + handleSpeed(0); sendInState2Target(DownloadSchedulers.COMPLETE); - sendIntent(Aria.ACTION_COMPLETE, entity.getFileSize()); + sendIntent(Aria.ACTION_COMPLETE, uploadEntity.getFileSize()); } @Override public void onFail() { - entity.setFailNum(entity.getFailNum() + 1); - entity.setState(DownloadEntity.STATE_FAIL); - entity.setSpeed(0); + uploadEntity.setFailNum(uploadEntity.getFailNum() + 1); + uploadEntity.setState(DownloadEntity.STATE_FAIL); + handleSpeed(0); sendInState2Target(DownloadSchedulers.FAIL); sendIntent(Aria.ACTION_FAIL, -1); } + private void handleSpeed(long speed) { + if (isConvertSpeed) { + uploadEntity.setConvertSpeed(CommonUtil.formatFileSize(speed) + "/s"); + } else { + uploadEntity.setSpeed(speed); + } + } + /** * 将任务状态发送给下载器 * @@ -224,12 +264,12 @@ public class UploadTask implements ITask { } private void sendIntent(String action, long location) { - entity.setComplete(action.equals(Aria.ACTION_COMPLETE)); - entity.setCurrentProgress(location); - entity.update(); + uploadEntity.setComplete(action.equals(Aria.ACTION_COMPLETE)); + uploadEntity.setCurrentProgress(location); + uploadEntity.update(); if (!isOpenBroadCast) return; Intent intent = CommonUtil.createIntent(context.getPackageName(), action); - intent.putExtra(Aria.ENTITY, entity); + intent.putExtra(Aria.ENTITY, uploadEntity); if (location != -1) { intent.putExtra(Aria.CURRENT_LOCATION, location); } diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java index d380c879..8f2ed69c 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -28,7 +28,7 @@ import java.util.Map; public class DBConfig { static Map mapping = new HashMap<>(); static String DB_NAME; - static int VERSION = 3; + static int VERSION = 2; static { if (TextUtils.isEmpty(DB_NAME)) { diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index f80e558e..c6ca4927 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -32,7 +32,7 @@ - + diff --git a/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java b/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java index c88904b6..1f18dc73 100644 --- a/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java +++ b/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java @@ -110,14 +110,14 @@ public class DownloadDialog extends AbsDialog { @Override public void onTaskStop(DownloadTask task) { super.onTaskStop(task); setBtState(true); - mSpeed.setText("0.0kb/s"); + mSpeed.setText(task.getConvertSpeed()); } @Override public void onTaskCancel(DownloadTask task) { super.onTaskCancel(task); setBtState(true); mPb.setProgress(0); - mSpeed.setText("0.0kb/s"); + mSpeed.setText(task.getConvertSpeed()); } @Override public void onTaskRunning(DownloadTask task) { @@ -129,7 +129,7 @@ public class DownloadDialog extends AbsDialog { } else { mPb.setProgress((int) ((current * 100) / len)); } - mSpeed.setText(CommonUtil.formatFileSize(task.getSpeed()) + "/s"); + mSpeed.setText(task.getConvertSpeed()); } } } diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index b06e5e91..7b4dd7d6 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -91,7 +91,7 @@ public class SingleTaskActivity extends BaseActivity { } else { mPb.setProgress((int) ((current * 100) / len)); } - mSpeed.setText(CommonUtil.formatFileSize(task.getSpeed()) + "/s"); + mSpeed.setText(task.getConvertSpeed()); break; case DOWNLOAD_PRE: mSize.setText(CommonUtil.formatFileSize((Long) msg.obj)); diff --git a/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java b/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java index 661032d1..afb2f068 100644 --- a/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java +++ b/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java @@ -134,7 +134,7 @@ public class DownloadFragment extends AbsFragment { } else { mPb.setProgress((int) ((current * 100) / len)); } - mSpeed.setText(CommonUtil.formatFileSize(task.getSpeed()) + "/s"); + mSpeed.setText(task.getConvertSpeed()); } } } diff --git a/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java b/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java index 646e8e1e..7d5bb80f 100644 --- a/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java +++ b/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java @@ -103,7 +103,6 @@ final class DownloadAdapter extends AbsRVAdapter