增加速度限制说明

pull/330/head
AriaLyy 8 years ago
parent 2c0954ab75
commit 66f4a7e6ba
  1. 4
      Aria/build.gradle
  2. 7
      Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java
  3. BIN
      img/11.gif
  4. BIN
      img/max_speed.gif
  5. BIN
      img/popupwindow_use.gif

@ -22,8 +22,8 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:appcompat-v7:23.1.1'
// compile project(':AriaCompiler') compile project(':AriaCompiler')
compile project(':AriaAnnotations') // compile project(':AriaAnnotations')
} }
//apply from: 'bintray-release.gradle' //apply from: 'bintray-release.gradle'
//apply from: 'jcenter.gradle' //apply from: 'jcenter.gradle'

@ -44,10 +44,6 @@ final class SingleThreadTask implements Runnable {
private int mBufSize; private int mBufSize;
private IDownloadListener mListener; private IDownloadListener mListener;
private DownloadStateConstance CONSTANCE; private DownloadStateConstance CONSTANCE;
/**
* speed = (bufSize / 1024) * CoresNum / sleepTime; (8192 / 1024) * 4 / 1= 32 kb/s
*/
private long mSleepTime = 0; private long mSleepTime = 0;
SingleThreadTask(DownloadStateConstance constance, IDownloadListener listener, SingleThreadTask(DownloadStateConstance constance, IDownloadListener listener,
@ -71,8 +67,7 @@ final class SingleThreadTask implements Runnable {
} else { } else {
BigDecimal db = new BigDecimal( BigDecimal db = new BigDecimal(
((mBufSize / 1024) * (filterVersion() ? 1 : CONSTANCE.THREAD_NUM) / maxSpeed) * 1000); ((mBufSize / 1024) * (filterVersion() ? 1 : CONSTANCE.THREAD_NUM) / maxSpeed) * 1000);
db.setScale(0, BigDecimal.ROUND_HALF_UP); mSleepTime = db.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
mSleepTime = db.longValue();
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 KiB

Loading…
Cancel
Save