diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java index a165c564..e8d59788 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java @@ -16,10 +16,11 @@ package com.arialyy.aria.core.download; import android.os.Handler; +import android.os.Looper; import com.arialyy.aria.core.AriaManager; +import com.arialyy.aria.core.common.IUtil; import com.arialyy.aria.core.download.downloader.DownloadGroupUtil; import com.arialyy.aria.core.download.downloader.FtpDirDownloadUtil; -import com.arialyy.aria.core.common.IUtil; import com.arialyy.aria.core.inf.AbsGroupTask; import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.scheduler.ISchedulers; @@ -44,7 +45,7 @@ public class DownloadGroupTask extends AbsGroupTask { * @param schedulers {@link ISchedulers} */ public Builder setOutHandler(ISchedulers schedulers) { - this.outHandler = new Handler(schedulers); + try { + outHandler = new Handler(schedulers); + } catch (Exception e) { + e.printStackTrace(); + outHandler = new Handler(Looper.getMainLooper(), schedulers); + } return this; } 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 75f30546..381d3967 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -18,7 +18,6 @@ package com.arialyy.simple.download; import android.os.Bundle; import android.os.Environment; -import android.os.Handler; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -27,11 +26,10 @@ import android.widget.RadioGroup; import android.widget.Toast; import butterknife.Bind; import com.arialyy.annotations.Download; -import com.arialyy.aria.core.download.DownloadTarget; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.download.DownloadTarget; import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.inf.IEntity; -import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.T; import com.arialyy.simple.R; import com.arialyy.simple.base.BaseActivity; @@ -114,7 +112,7 @@ public class SingleTaskActivity extends BaseActivity { setBtState(false); } - @Download.onTaskStart(DOWNLOAD_URL) void taskStart(DownloadTask task) { + @Download.onTaskStart void taskStart(DownloadTask task) { getBinding().setFileSize(task.getConvertFileSize()); } @@ -188,11 +186,12 @@ public class SingleTaskActivity extends BaseActivity { public void onClick(View view) { switch (view.getId()) { case R.id.start: - Aria.download(this) + Aria.download(SingleTaskActivity.this) .load(DOWNLOAD_URL) .addHeader("groupName", "value") .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/gggg.apk") .start(); + break; case R.id.stop: Aria.download(this).load(DOWNLOAD_URL).stop(); diff --git a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java index 669d8909..73d782db 100644 --- a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java @@ -48,7 +48,7 @@ public class HttpUploadActivity extends BaseActivity { } @OnClick(R.id.upload) void upload() { - Aria.upload(this) + Aria.upload(HttpUploadActivity.this) .load(FILE_PATH) .setUploadUrl("http://172.18.104.66:8080/upload/sign_file") .setAttachment("file") 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 438a4dc0..832f9521 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 @@ -83,7 +83,12 @@ public class UploadTask extends AbsNormalTask { private String mTargetName; public void setOutHandler(ISchedulers outHandler) { - mOutHandler = new Handler(outHandler); + try { + mOutHandler = new Handler(outHandler); + } catch (Exception e) { + e.printStackTrace(); + mOutHandler = new Handler(Looper.getMainLooper(), outHandler); + } } public void setUploadTaskEntity(UploadTaskEntity taskEntity) { diff --git a/build.gradle b/build.gradle index 3c54e7fd..133f0556 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.2.16' + publishVersion = '3.2.17' repoName='maven' desc = 'android 下载框架' website = 'https://github.com/AriaLyy/Aria'