修复不能在线程中使用Aria的问题 https://github.com/AriaLyy/Aria/issues/89

pull/330/head
AriaLyy 7 years ago
parent a8f183363e
commit 335a14dfc4
  1. 10
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java
  2. 7
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
  3. 9
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  4. 2
      app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java
  5. 5
      aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java
  6. 2
      build.gradle

@ -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;
@ -93,7 +94,12 @@ public class DownloadGroupTask extends AbsGroupTask<DownloadGroupTaskEntity, Dow
* @param schedulers {@link ISchedulers}
*/
public DownloadGroupTask.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;
}

@ -164,7 +164,12 @@ public class DownloadTask extends AbsNormalTask<DownloadEntity> {
* @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;
}

@ -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<ActivitySingleBinding> {
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<ActivitySingleBinding> {
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();

@ -48,7 +48,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
}
@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")

@ -83,7 +83,12 @@ public class UploadTask extends AbsNormalTask<UploadEntity> {
private String mTargetName;
public void setOutHandler(ISchedulers outHandler) {
try {
mOutHandler = new Handler(outHandler);
} catch (Exception e) {
e.printStackTrace();
mOutHandler = new Handler(Looper.getMainLooper(), outHandler);
}
}
public void setUploadTaskEntity(UploadTaskEntity taskEntity) {

@ -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'

Loading…
Cancel
Save