diff --git a/Aria/build.gradle b/Aria/build.gradle index 1e811256..c28c0ade 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionCode 313 - versionName "3.1.3" + versionCode 314 + versionName "3.1.4" } buildTypes { release { diff --git a/Aria/src/main/java/com/arialyy/aria/core/Aria.java b/Aria/src/main/java/com/arialyy/aria/core/Aria.java index 4b3fb688..241c0fb6 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/Aria.java +++ b/Aria/src/main/java/com/arialyy/aria/core/Aria.java @@ -174,6 +174,15 @@ import com.arialyy.aria.core.upload.UploadTask; */ public static class UploadSchedulerListener implements ISchedulerListener { + /** + * 预处理,有时有些地址链接比较慢,这时可以先在这个地方出来一些界面上的UI,如按钮的状态。 + * + * @param url 任务上传地址 + */ + @Override public void onPre(String url) { + + } + @Override public void onTaskPre(UploadTask task) { } @@ -212,6 +221,14 @@ import com.arialyy.aria.core.upload.UploadTask; */ public static class DownloadSchedulerListener implements IDownloadSchedulerListener { + /** + * 预处理,有时有些地址链接比较慢,这时可以先在这个地方出来一些界面上的UI,如按钮的状态。 + * + * @param url 任务下载地址 + */ + @Override public void onPre(String url) { + + } @Override public void onTaskPre(DownloadTask task) { 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 385220f5..bb394588 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 @@ -302,6 +302,7 @@ public class DownloadTask implements ITask { @Override public void onPre() { super.onPre(); downloadEntity.setState(DownloadEntity.STATE_PRE); + sendInState2Target(ISchedulers.PRE); sendIntent(Aria.ACTION_PRE, -1); } @@ -309,21 +310,21 @@ public class DownloadTask implements ITask { super.onPostPre(fileSize); downloadEntity.setFileSize(fileSize); downloadEntity.setState(DownloadEntity.STATE_POST_PRE); - sendInState2Target(DownloadSchedulers.PRE); + sendInState2Target(ISchedulers.POST_PRE); sendIntent(Aria.ACTION_POST_PRE, -1); } @Override public void onResume(long resumeLocation) { super.onResume(resumeLocation); downloadEntity.setState(DownloadEntity.STATE_RUNNING); - sendInState2Target(DownloadSchedulers.RESUME); + sendInState2Target(ISchedulers.RESUME); sendIntent(Aria.ACTION_RESUME, resumeLocation); } @Override public void onStart(long startLocation) { super.onStart(startLocation); downloadEntity.setState(DownloadEntity.STATE_RUNNING); - sendInState2Target(DownloadSchedulers.START); + sendInState2Target(ISchedulers.START); sendIntent(Aria.ACTION_START, startLocation); } @@ -341,7 +342,7 @@ public class DownloadTask implements ITask { handleSpeed(speed); downloadEntity.setCurrentProgress(currentLocation); lastLen = currentLocation; - sendInState2Target(DownloadSchedulers.RUNNING); + sendInState2Target(ISchedulers.RUNNING); context.sendBroadcast(sendIntent); } } @@ -350,7 +351,7 @@ public class DownloadTask implements ITask { super.onStop(stopLocation); downloadEntity.setState(DownloadEntity.STATE_STOP); handleSpeed(0); - sendInState2Target(DownloadSchedulers.STOP); + sendInState2Target(ISchedulers.STOP); sendIntent(Aria.ACTION_STOP, stopLocation); } @@ -358,7 +359,7 @@ public class DownloadTask implements ITask { super.onCancel(); downloadEntity.setState(DownloadEntity.STATE_CANCEL); handleSpeed(0); - sendInState2Target(DownloadSchedulers.CANCEL); + sendInState2Target(ISchedulers.CANCEL); sendIntent(Aria.ACTION_CANCEL, -1); downloadEntity.deleteData(); } @@ -368,7 +369,7 @@ public class DownloadTask implements ITask { downloadEntity.setState(DownloadEntity.STATE_COMPLETE); downloadEntity.setDownloadComplete(true); handleSpeed(0); - sendInState2Target(DownloadSchedulers.COMPLETE); + sendInState2Target(ISchedulers.COMPLETE); sendIntent(Aria.ACTION_COMPLETE, downloadEntity.getFileSize()); } @@ -377,7 +378,7 @@ public class DownloadTask implements ITask { downloadEntity.setFailNum(downloadEntity.getFailNum() + 1); downloadEntity.setState(DownloadEntity.STATE_FAIL); handleSpeed(0); - sendInState2Target(DownloadSchedulers.FAIL); + sendInState2Target(ISchedulers.FAIL); sendIntent(Aria.ACTION_FAIL, -1); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java index f6bd01a3..24645a08 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.Properties; +import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -367,7 +368,18 @@ class DownloadUtil implements IDownloadUtil, Runnable { if (pro.isEmpty()) { handleNewTask(); } else { - THREAD_NUM = pro.keySet().size(); + Set keys = pro.keySet(); + int num = 0; + for (Object key : keys) { + if (String.valueOf(key).contains("_record_")) { + num++; + } + } + if (num == 0){ + handleNewTask(); + return pro; + } + THREAD_NUM = num; for (int i = 0; i < THREAD_NUM; i++) { if (pro.getProperty(mDownloadFile.getName() + "_record_" + i) == null) { Object state = pro.getProperty(mDownloadFile.getName() + "_state_" + i); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/IDownloadListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/IDownloadListener.java index 8d60217c..0e805e35 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/IDownloadListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/IDownloadListener.java @@ -39,7 +39,7 @@ interface IDownloadListener { public void onFail(); /** - * 预处理 + * 预处理,有时有些地址链接比较慢,这时可以先在这个地方出来一些界面上的UI,如按钮的状态 */ public void onPre(); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java index 1ca9fe1b..65ceba81 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java @@ -113,8 +113,7 @@ final class SingleThreadTask implements Runnable { //支持断点的处理 if (mConfigEntity.isSupportBreakpoint) { Log.i(TAG, "线程【" + mConfigEntity.THREAD_ID + "】下载完毕"); - writeConfig(mConfigEntity.TEMP_FILE.getName() + "_state_" + mConfigEntity.THREAD_ID, - 1 + ""); + writeConfig(mConfigEntity.TEMP_FILE.getName() + "_state_" + mConfigEntity.THREAD_ID, 1); mListener.onChildComplete(mConfigEntity.END_LOCATION); CONSTANCE.COMPLETE_THREAD_NUM++; if (CONSTANCE.isComplete()) { @@ -151,13 +150,12 @@ final class SingleThreadTask implements Runnable { try { if (mConfigEntity.isSupportBreakpoint) { CONSTANCE.STOP_NUM++; - String location = String.valueOf(mChildCurrentLocation); Log.d(TAG, "thread_" + mConfigEntity.THREAD_ID + "_stop, stop location ==> " + mChildCurrentLocation); writeConfig(mConfigEntity.TEMP_FILE.getName() + "_record_" + mConfigEntity.THREAD_ID, - location); + mChildCurrentLocation); if (CONSTANCE.isStop()) { Log.d(TAG, "++++++++++++++++ onStop +++++++++++++++++"); CONSTANCE.isDownloading = false; @@ -226,10 +224,8 @@ final class SingleThreadTask implements Runnable { Log.e(TAG, CommonUtil.getPrintException(ex)); } if (mConfigEntity.isSupportBreakpoint) { - if (currentLocation != -1) { - String location = String.valueOf(currentLocation); - writeConfig(dEntity.TEMP_FILE.getName() + "_record_" + dEntity.THREAD_ID, location); - } + writeConfig(dEntity.TEMP_FILE.getName() + "_record_" + dEntity.THREAD_ID, + currentLocation); if (CONSTANCE.isFail()) { Log.d(TAG, "++++++++++++++++ onFail +++++++++++++++++"); mListener.onFail(); @@ -247,10 +243,12 @@ final class SingleThreadTask implements Runnable { /** * 将记录写入到配置文件 */ - private void writeConfig(String key, String record) throws IOException { - File configFile = new File(mConfigFPath); - Properties pro = CommonUtil.loadConfig(configFile); - pro.setProperty(key, record); - CommonUtil.saveConfig(configFile, pro); + private void writeConfig(String key, long record) throws IOException { + if (record != -1 && record != 0) { + File configFile = new File(mConfigFPath); + Properties pro = CommonUtil.loadConfig(configFile); + pro.setProperty(key, String.valueOf(record)); + CommonUtil.saveConfig(configFile, pro); + } } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java index 90eaa811..620138d8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java @@ -128,6 +128,12 @@ public class DownloadSchedulers implements ISchedulers { return; } switch (state) { + case PRE: + listener.onPre(task.getKey()); + break; + case POST_PRE: + listener.onTaskPre(task); + break; case RUNNING: listener.onTaskRunning(task); break; @@ -140,9 +146,6 @@ public class DownloadSchedulers implements ISchedulers { case RESUME: listener.onTaskResume(task); break; - case PRE: - listener.onTaskPre(task); - break; case CANCEL: listener.onTaskCancel(task); break; diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulerListener.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulerListener.java index 8bb54b2e..7a37277c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulerListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulerListener.java @@ -22,7 +22,13 @@ import com.arialyy.aria.core.inf.ITask; */ public interface ISchedulerListener { /** - * 任务预加载 + * 预处理,有时有些地址链接比较慢,这时可以先在这个地方出来一些界面上的UI,如按钮的状态。 + * 在这个回调中,任务是获取不到文件大小,下载速度等参数 + */ + public void onPre(String url); + + /** + * 任务预加载完成 */ public void onTaskPre(TASK task); diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java index 908d0861..5722eb87 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java @@ -27,39 +27,44 @@ public interface ISchedulers extends Handler.Callback { /** * 断点支持 */ - public static final int SUPPORT_BREAK_POINT = 8; + public static final int SUPPORT_BREAK_POINT = 9; /** * 任务预加载 */ public static final int PRE = 0; + /** + * 任务预加载完成 + */ + public static final int POST_PRE = 1; + /** * 任务开始 */ - public static final int START = 1; + public static final int START = 2; /** * 任务停止 */ - public static final int STOP = 2; + public static final int STOP = 3; /** * 任务失败 */ - public static final int FAIL = 3; + public static final int FAIL = 4; /** * 任务取消 */ - public static final int CANCEL = 4; + public static final int CANCEL = 5; /** * 任务完成 */ - public static final int COMPLETE = 5; + public static final int COMPLETE = 6; /** * 任务处理中 */ - public static final int RUNNING = 6; + public static final int RUNNING = 7; /** * 恢复任务 */ - public static final int RESUME = 7; + public static final int RESUME = 8; /** * 注册下载器监听,一个观察者只能注册一次监听 diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/UploadSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/UploadSchedulers.java index ef6b0b72..349954f6 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/UploadSchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/UploadSchedulers.java @@ -131,6 +131,12 @@ public class UploadSchedulers implements ISchedulers { return; } switch (state) { + case PRE: + listener.onPre(task.getKey()); + break; + case POST_PRE: + listener.onTaskPre(task); + break; case RUNNING: listener.onTaskRunning(task); break; @@ -143,9 +149,6 @@ public class UploadSchedulers implements ISchedulers { case RESUME: listener.onTaskResume(task); break; - case PRE: - listener.onTaskPre(task); - break; case CANCEL: listener.onTaskCancel(task); break; diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/IUploadListener.java b/Aria/src/main/java/com/arialyy/aria/core/upload/IUploadListener.java index f8044a39..5f51824b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/IUploadListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/IUploadListener.java @@ -26,10 +26,15 @@ public interface IUploadListener { */ public void onPre(); + /** + * 预处理完成 + */ + public void onPostPre(long fileSize); + /** * 开始上传 */ - public void onStart(long fileSize); + public void onStart(); /** * 恢复上传 diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadListener.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadListener.java index 94dce03d..59c71b8e 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadListener.java @@ -24,7 +24,11 @@ public class UploadListener implements IUploadListener { } - @Override public void onStart(long fileSize) { + @Override public void onPostPre(long fileSize) { + + } + + @Override public void onStart() { } 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 f8146a41..d4d555bd 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 @@ -214,10 +214,17 @@ public class UploadTask implements ITask { sendInState2Target(ISchedulers.PRE); } - @Override public void onStart(long fileSize) { + @Override public void onPostPre(long fileSize) { + super.onPostPre(fileSize); uploadEntity.setFileSize(fileSize); + uploadEntity.setState(IEntity.STATE_POST_PRE); + sendIntent(Aria.ACTION_POST_PRE, 0); + sendInState2Target(ISchedulers.POST_PRE); + } + + @Override public void onStart() { uploadEntity.setState(IEntity.STATE_RUNNING); - sendIntent(Aria.ACTION_PRE, -1); + sendIntent(Aria.ACTION_START, 0); sendInState2Target(ISchedulers.START); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java index 5126660d..228dc97d 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java @@ -99,6 +99,8 @@ final class UploadUtil implements Runnable { } mOutputStream = mHttpConn.getOutputStream(); + mListener.onPostPre(uploadFile.length()); + PrintWriter writer = new PrintWriter(new OutputStreamWriter(mOutputStream, mTaskEntity.charset), true); @@ -107,7 +109,7 @@ final class UploadUtil implements Runnable { for (String key : keys) { addFormField(writer, key, mTaskEntity.formFields.get(key)); } - mListener.onStart(uploadFile.length()); + mListener.onStart(); uploadFile(writer, mTaskEntity.attachment, uploadFile); Log.d(TAG, finish(writer) + ""); } catch (IOException e) { diff --git a/README.md b/README.md index 0cb11dd4..992c5e3a 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Aria怎样使用? ## 下载 [![Download](https://api.bintray.com/packages/arialyy/maven/Aria/images/download.svg)](https://bintray.com/arialyy/maven/Aria/_latestVersion)
```java -compile 'com.arialyy.aria:Aria:3.1.3' +compile 'com.arialyy.aria:Aria:3.1.4' ``` ## 示例 @@ -266,6 +266,7 @@ Aria.download(this).removeAllTask(); ## 开发日志 + + v_3.1.4 修复快速切换,暂停、恢复功能时,概率性出现的重新下载问题,添加onPre()回调,onPre()用于请求地址之前执行界面UI更新操作。 + v_3.1.2 优化代码结构 + v_3.1.0 添加Aria配置文件,优化代码 + v_3.0.3 修复暂停后删除任务,闪退问题,添加删除记录的api 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 ffc5e6ef..e4a92340 100644 --- a/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java +++ b/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java @@ -44,7 +44,7 @@ public class DownloadDialog extends AbsDialog { @Bind(R.id.speed) TextView mSpeed; private static final String DOWNLOAD_URL = - "http://clashroyalecdn.static.kunlun.com/Clash_Royale-1.2.6-kunlun_landing_page-release.apk.apk"; + "http://static.gaoshouyou.com/d/4b/d7/e04b308d9cd7f0ad4cac18d1a514544c.apk"; public DownloadDialog(Context context) { super(context); @@ -77,7 +77,7 @@ public class DownloadDialog extends AbsDialog { case R.id.start: Aria.download(this) .load(DOWNLOAD_URL) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/daialog.apk") + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/飞机大战.apk") .start(); break; case R.id.stop: @@ -122,14 +122,10 @@ public class DownloadDialog extends AbsDialog { @Override public void onTaskRunning(DownloadTask task) { super.onTaskRunning(task); - long current = task.getCurrentProgress(); - long len = task.getFileSize(); - if (len == 0) { - mPb.setProgress(0); - } else { - mPb.setProgress((int) ((current * 100) / len)); + if (task.getKey().equals(DOWNLOAD_URL)) { + mPb.setProgress(task.getPercent()); + mSpeed.setText(task.getConvertSpeed()); } - mSpeed.setText(task.getConvertSpeed()); } } } diff --git a/app/src/main/java/com/arialyy/simple/download/DownloadModule.java b/app/src/main/java/com/arialyy/simple/download/DownloadModule.java index 8269134b..f87865c1 100644 --- a/app/src/main/java/com/arialyy/simple/download/DownloadModule.java +++ b/app/src/main/java/com/arialyy/simple/download/DownloadModule.java @@ -178,7 +178,7 @@ public class DownloadModule extends BaseModule { case Aria.ACTION_POST_PRE: DownloadEntity entity = intent.getParcelableExtra(Aria.DOWNLOAD_ENTITY); len = entity.getFileSize(); - L.d(TAG, "download pre"); + L.d(TAG, "download onPre"); handler.obtainMessage(SingleTaskActivity.DOWNLOAD_PRE, len).sendToTarget(); break; case Aria.ACTION_START: diff --git a/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java b/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java index 538f320d..b82de2bc 100644 --- a/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java +++ b/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java @@ -46,7 +46,7 @@ public class DownloadPopupWindow extends AbsPopupWindow { @Bind(R.id.speed) TextView mSpeed; private static final String DOWNLOAD_URL = - "http://static.gaoshouyou.com/d/3a/93/573ae1db9493a801c24bf66128b11e39.apk"; + "http://static.gaoshouyou.com/d/25/57/2e25bd9d4557ba31e9beebacfaf9e804.apk"; public DownloadPopupWindow(Context context) { super(context, new ColorDrawable(Color.WHITE)); @@ -79,7 +79,7 @@ public class DownloadPopupWindow extends AbsPopupWindow { case R.id.start: Aria.download(this) .load(DOWNLOAD_URL) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/daialog.apk") + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/消消乐.apk") .start(); break; case R.id.stop: diff --git a/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java b/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java index 9adcd304..39cc5d8e 100644 --- a/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java +++ b/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java @@ -30,7 +30,7 @@ import com.arialyy.simple.R; public class SimpleNotification { private static final String DOWNLOAD_URL = - "http://static.gaoshouyou.com/d/6e/e5/ff6ecaaf45e532e6d07747af82357472.apk"; + "http://static.gaoshouyou.com/d/cb/38/f0cb1b2c57388fe14342eecd64bbae65.apk"; private NotificationManager mManager; private Context mContext; @@ -58,7 +58,7 @@ public class SimpleNotification { .load(DOWNLOAD_URL) .setDownloadName("notification_test.apk") .setDownloadPath( - Environment.getExternalStorageDirectory() + "/Download/notification_test.apk") + Environment.getExternalStorageDirectory() + "/Download/消灭星星.apk") .start(); } 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 7b4dd7d6..b61773ab 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -24,6 +24,7 @@ import android.os.Environment; import android.os.Handler; import android.os.Message; import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.RadioGroup; @@ -243,6 +244,11 @@ public class SingleTaskActivity extends BaseActivity { private class MySchedulerListener extends Aria.DownloadSchedulerListener { + @Override public void onPre(String url) { + super.onPre(url); + Log.d(TAG, "url ==> " + url); + } + @Override public void onNoSupportBreakPoint(DownloadTask task) { super.onNoSupportBreakPoint(task); T.showShort(SingleTaskActivity.this, "该下载链接不支持断点"); 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 bb90e783..3365a4be 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 @@ -45,7 +45,7 @@ public class DownloadFragment extends AbsFragment { @Bind(R.id.speed) TextView mSpeed; private static final String DOWNLOAD_URL = - "http://rs.0.gaoshouyou.com/d/90/d7/7490c6fd6cd733bef336e766778507c5.apk"; + "http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk"; @Override protected void init(Bundle savedInstanceState) { if (Aria.download(this).taskExists(DOWNLOAD_URL)) { @@ -73,7 +73,7 @@ public class DownloadFragment extends AbsFragment { case R.id.start: Aria.download(this) .load(DOWNLOAD_URL) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/daialog.apk") + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/兰空VOEZ.apk") .start(); break; case R.id.stop: 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 7d5bb80f..4342f4d2 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 @@ -70,7 +70,7 @@ final class DownloadAdapter extends AbsRVAdapter= mData.size()) { return; } mData.set(position, entity); @@ -81,7 +81,7 @@ final class DownloadAdapter extends AbsRVAdapter= mData.size()) { return; } @@ -169,6 +169,7 @@ final class DownloadAdapter extends AbsRVAdapter { + private static final String TAG = "UploadActivity"; @Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; private static final int START = 0; private static final int STOP = 1; @@ -106,6 +108,16 @@ public class UploadActivity extends BaseActivity { this.handler = new WeakReference<>(handler); } + @Override public void onPre(String url) { + super.onPre(url); + L.e(TAG, "url ==> " + url); + } + + @Override public void onTaskPre(UploadTask task) { + super.onTaskPre(task); + L.d(TAG, "fileSize = " + task.getConvertFileSize()); + } + @Override public void onTaskStart(UploadTask task) { super.onTaskStart(task); handler.get().obtainMessage(START, task).sendToTarget();