fix bug https://github.com/AriaLyy/Aria/issues/423 https://github.com/AriaLyy/Aria/issues/426 https://github.com/AriaLyy/Aria/issues/427 https://github.com/AriaLyy/Aria/issues/428
parent
fdb607e10f
commit
062f124cae
@ -1,154 +1,154 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package com.arialyy.aria.core; |
||||
|
||||
import android.annotation.TargetApi; |
||||
import android.app.Activity; |
||||
import android.app.Application; |
||||
import android.app.Dialog; |
||||
import android.app.Service; |
||||
import android.content.Context; |
||||
import android.os.Build; |
||||
import android.support.v4.app.DialogFragment; |
||||
import android.support.v4.app.Fragment; |
||||
import android.widget.PopupWindow; |
||||
import com.arialyy.aria.core.download.DownloadReceiver; |
||||
import com.arialyy.aria.core.upload.UploadReceiver; |
||||
import com.arialyy.aria.util.ALog; |
||||
|
||||
/** |
||||
* Created by lyy on 2016/12/1. |
||||
* |
||||
* @see <a href="https://github.com/AriaLyy/Aria">Aria</a> |
||||
* @see <a href="https://aria.laoyuyu.me/aria_doc/">Aria doc</a> |
||||
* Aria启动,管理全局任务 |
||||
* <pre> |
||||
* <code> |
||||
* //下载
|
||||
* Aria.download(this) |
||||
* .load(URL) //下载地址,必填
|
||||
* //文件保存路径,必填
|
||||
* .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") |
||||
* .start(); |
||||
* </code> |
||||
* <code> |
||||
* //上传
|
||||
* Aria.upload(this) |
||||
* .load(filePath) //文件路径,必填
|
||||
* .setTempUrl(uploadUrl) //上传路径,必填
|
||||
* .setAttachment(fileKey) //服务器读取文件的key,必填
|
||||
* .start(); |
||||
* </code> |
||||
* </pre> |
||||
* |
||||
* 如果你需要在【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】 |
||||
* 之外的java中使用Aria,那么你应该在Application或Activity初始化的时候调用{@link #init(Context)}对Aria进行初始化 |
||||
* 然后才能使用{@link #download(Object)}、{@link #upload(Object)} |
||||
* |
||||
* <pre> |
||||
* <code> |
||||
* Aria.init(this); |
||||
* |
||||
* Aria.download(this) |
||||
* .load(URL) //下载地址,必填
|
||||
* //文件保存路径,必填
|
||||
* .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") |
||||
* .start(); |
||||
* |
||||
* </code> |
||||
* |
||||
* </pre> |
||||
*/ |
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) public class Aria { |
||||
|
||||
private Aria() { |
||||
} |
||||
|
||||
/** |
||||
* 下载,在当前类中调用Aria方法,参数需要使用this,否则将 |
||||
* 如果不是【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】对象,那么你 |
||||
* 需要在对象中初始化下载前,在Application或Activity初始化的时候调用{@link #init(Context)}对Aria进行初始化 |
||||
* |
||||
* @param obj 观察者对象,为本类对象,使用{@code this} |
||||
*/ |
||||
public static DownloadReceiver download(Object obj) { |
||||
if (AriaManager.getInstance() != null){ |
||||
return AriaManager.getInstance().download(obj); |
||||
} |
||||
return get(convertContext(obj)).download(obj); |
||||
} |
||||
|
||||
/** |
||||
* 上传 |
||||
* 如果不是【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】对象,那么你 |
||||
* 需要在对象中初始化下载前,在Application或Activity初始化的时候调用{@link #init(Context)}对Aria进行初始化 |
||||
* |
||||
* @param obj 观察者对象,为本类对象,使用{@code this} |
||||
*/ |
||||
public static UploadReceiver upload(Object obj) { |
||||
if (AriaManager.getInstance() != null){ |
||||
return AriaManager.getInstance().upload(obj); |
||||
} |
||||
return get(convertContext(obj)).upload(obj); |
||||
} |
||||
|
||||
/** |
||||
* 处理通用事件 |
||||
*/ |
||||
public static AriaManager get(Context context) { |
||||
if (context == null) { |
||||
throw new NullPointerException("context 无效,在非【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】," |
||||
+ "请参考【https://aria.laoyuyu.me/aria_doc/start/any_java.html】,参数请使用 download(this) 或 upload(this);" |
||||
+ "不要使用 download(getContext()) 或 upload(getContext())"); |
||||
} |
||||
return AriaManager.getInstance(context); |
||||
} |
||||
|
||||
/** |
||||
* 初始化Aria,如果你需要在【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】 |
||||
* 之外的java中使用Aria,那么你应该在Application或Activity初始化的时候调用本方法对Aria进行初始化 |
||||
* 只需要初始化一次就可以 |
||||
* {@link #download(Object)}、{@link #upload(Object)} |
||||
*/ |
||||
public static AriaManager init(Context context) { |
||||
return AriaManager.getInstance(context); |
||||
} |
||||
|
||||
private static Context convertContext(Object obj) { |
||||
if (obj instanceof Application) { |
||||
return (Application) obj; |
||||
} else if (obj instanceof Service) { |
||||
return (Service) obj; |
||||
} else if (obj instanceof Activity) { |
||||
return (Activity) obj; |
||||
} else if (obj instanceof DialogFragment) { |
||||
return ((DialogFragment) obj).getContext(); |
||||
} else if (obj instanceof android.app.DialogFragment) { |
||||
return ((android.app.DialogFragment) obj).getActivity(); |
||||
} else if (obj instanceof android.support.v4.app.Fragment) { |
||||
return ((Fragment) obj).getContext(); |
||||
} else if (obj instanceof android.app.Fragment) { |
||||
return ((android.app.Fragment) obj).getActivity(); |
||||
} else if (obj instanceof Dialog) { |
||||
return ((Dialog) obj).getContext(); |
||||
} else if (obj instanceof PopupWindow) { |
||||
return ((PopupWindow) obj).getContentView().getContext(); |
||||
} |
||||
ALog.e("Aria", "请使用download(this)或upload(this)"); |
||||
return null; |
||||
} |
||||
} |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package com.arialyy.aria.core; |
||||
|
||||
import android.annotation.TargetApi; |
||||
import android.app.Activity; |
||||
import android.app.Application; |
||||
import android.app.Dialog; |
||||
import android.app.Service; |
||||
import android.content.Context; |
||||
import android.os.Build; |
||||
import android.support.v4.app.DialogFragment; |
||||
import android.support.v4.app.Fragment; |
||||
import android.widget.PopupWindow; |
||||
import com.arialyy.aria.core.download.DownloadReceiver; |
||||
import com.arialyy.aria.core.upload.UploadReceiver; |
||||
import com.arialyy.aria.util.ALog; |
||||
|
||||
/** |
||||
* Created by lyy on 2016/12/1. |
||||
* |
||||
* @see <a href="https://github.com/AriaLyy/Aria">Aria</a> |
||||
* @see <a href="https://aria.laoyuyu.me/aria_doc/">Aria doc</a> |
||||
* Aria启动,管理全局任务 |
||||
* <pre> |
||||
* <code> |
||||
* //下载
|
||||
* Aria.download(this) |
||||
* .load(URL) //下载地址,必填
|
||||
* //文件保存路径,必填
|
||||
* .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") |
||||
* .start(); |
||||
* </code> |
||||
* <code> |
||||
* //上传
|
||||
* Aria.upload(this) |
||||
* .load(filePath) //文件路径,必填
|
||||
* .setTempUrl(uploadUrl) //上传路径,必填
|
||||
* .setAttachment(fileKey) //服务器读取文件的key,必填
|
||||
* .start(); |
||||
* </code> |
||||
* </pre> |
||||
* |
||||
* 如果你需要在【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】 |
||||
* 之外的java中使用Aria,那么你应该在Application或Activity初始化的时候调用{@link #init(Context)}对Aria进行初始化 |
||||
* 然后才能使用{@link #download(Object)}、{@link #upload(Object)} |
||||
* |
||||
* <pre> |
||||
* <code> |
||||
* Aria.init(this); |
||||
* |
||||
* Aria.download(this) |
||||
* .load(URL) //下载地址,必填
|
||||
* //文件保存路径,必填
|
||||
* .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") |
||||
* .start(); |
||||
* |
||||
* </code> |
||||
* |
||||
* </pre> |
||||
*/ |
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) public class Aria { |
||||
|
||||
private Aria() { |
||||
} |
||||
|
||||
/** |
||||
* 下载,在当前类中调用Aria方法,参数需要使用this,否则将 |
||||
* 如果不是【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】对象,那么你 |
||||
* 需要在对象中初始化下载前,在Application或Activity初始化的时候调用{@link #init(Context)}对Aria进行初始化 |
||||
* |
||||
* @param obj 观察者对象,为本类对象,使用{@code this} |
||||
*/ |
||||
public static DownloadReceiver download(Object obj) { |
||||
if (AriaManager.getInstance() != null){ |
||||
return AriaManager.getInstance().download(obj); |
||||
} |
||||
return get(convertContext(obj)).download(obj); |
||||
} |
||||
|
||||
/** |
||||
* 上传 |
||||
* 如果不是【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】对象,那么你 |
||||
* 需要在对象中初始化下载前,在Application或Activity初始化的时候调用{@link #init(Context)}对Aria进行初始化 |
||||
* |
||||
* @param obj 观察者对象,为本类对象,使用{@code this} |
||||
*/ |
||||
public static UploadReceiver upload(Object obj) { |
||||
if (AriaManager.getInstance() != null){ |
||||
return AriaManager.getInstance().upload(obj); |
||||
} |
||||
return get(convertContext(obj)).upload(obj); |
||||
} |
||||
|
||||
/** |
||||
* 处理通用事件 |
||||
*/ |
||||
public static AriaManager get(Context context) { |
||||
if (context == null) { |
||||
throw new NullPointerException("context 无效,在非【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】," |
||||
+ "请参考【https://aria.laoyuyu.me/aria_doc/start/any_java.html】,参数请使用 download(this) 或 upload(this);" |
||||
+ "不要使用 download(getContext()) 或 upload(getContext())"); |
||||
} |
||||
return AriaManager.getInstance(context); |
||||
} |
||||
|
||||
/** |
||||
* 初始化Aria,如果你需要在【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】 |
||||
* 之外的java中使用Aria,那么你应该在Application或Activity初始化的时候调用本方法对Aria进行初始化 |
||||
* 只需要初始化一次就可以 |
||||
* {@link #download(Object)}、{@link #upload(Object)} |
||||
*/ |
||||
public static AriaManager init(Context context) { |
||||
return AriaManager.getInstance(context); |
||||
} |
||||
|
||||
private static Context convertContext(Object obj) { |
||||
if (obj instanceof Application) { |
||||
return (Application) obj; |
||||
} else if (obj instanceof Service) { |
||||
return (Service) obj; |
||||
} else if (obj instanceof Activity) { |
||||
return (Activity) obj; |
||||
} else if (obj instanceof DialogFragment) { |
||||
return ((DialogFragment) obj).getContext(); |
||||
} else if (obj instanceof android.app.DialogFragment) { |
||||
return ((android.app.DialogFragment) obj).getActivity(); |
||||
} else if (obj instanceof android.support.v4.app.Fragment) { |
||||
return ((Fragment) obj).getContext(); |
||||
} else if (obj instanceof android.app.Fragment) { |
||||
return ((android.app.Fragment) obj).getActivity(); |
||||
} else if (obj instanceof Dialog) { |
||||
return ((Dialog) obj).getContext(); |
||||
} else if (obj instanceof PopupWindow) { |
||||
return ((PopupWindow) obj).getContentView().getContext(); |
||||
} |
||||
ALog.e("Aria", "请使用download(this)或upload(this)"); |
||||
return null; |
||||
} |
||||
} |
||||
|
@ -1,27 +1,27 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.upload; |
||||
|
||||
import com.arialyy.aria.core.inf.AbsTarget; |
||||
|
||||
/** |
||||
* Created by AriaL on 2017/6/29. |
||||
* 普通上传任务接收器 |
||||
*/ |
||||
abstract class AbsUploadTarget<TARGET extends AbsUploadTarget> extends AbsTarget<TARGET> { |
||||
|
||||
|
||||
} |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.upload; |
||||
|
||||
import com.arialyy.aria.core.inf.AbsTarget; |
||||
|
||||
/** |
||||
* Created by AriaL on 2017/6/29. |
||||
* 普通上传任务接收器 |
||||
*/ |
||||
abstract class AbsUploadTarget<TARGET extends AbsUploadTarget> extends AbsTarget<TARGET> { |
||||
|
||||
|
||||
} |
||||
|
@ -1,24 +1,24 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.exception; |
||||
|
||||
public class ParamException extends RuntimeException { |
||||
private static final String ARIA_NET_EXCEPTION = "Aria Params Exception:"; |
||||
|
||||
public ParamException(String message) { |
||||
super(String.format("%s%s", ARIA_NET_EXCEPTION, message)); |
||||
} |
||||
} |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.exception; |
||||
|
||||
public class ParamException extends RuntimeException { |
||||
private static final String ARIA_NET_EXCEPTION = "Aria Params Exception:"; |
||||
|
||||
public ParamException(String message) { |
||||
super(String.format("%s%s", ARIA_NET_EXCEPTION, message)); |
||||
} |
||||
} |
||||
|
@ -1,244 +1,244 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.simple.core.download; |
||||
|
||||
import android.os.Bundle; |
||||
import android.os.Environment; |
||||
import android.support.v7.widget.LinearLayoutManager; |
||||
import android.support.v7.widget.RecyclerView; |
||||
import android.view.Menu; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.widget.Button; |
||||
import android.widget.TextView; |
||||
import com.arialyy.annotations.Download; |
||||
import com.arialyy.aria.core.Aria; |
||||
import com.arialyy.aria.core.download.DownloadEntity; |
||||
import com.arialyy.aria.core.download.DownloadTarget; |
||||
import com.arialyy.aria.core.download.DownloadTask; |
||||
import com.arialyy.aria.core.inf.AbsEntity; |
||||
import com.arialyy.aria.core.inf.IEntity; |
||||
import com.arialyy.frame.util.show.L; |
||||
import com.arialyy.simple.R; |
||||
import com.arialyy.simple.base.BaseActivity; |
||||
import com.arialyy.simple.databinding.ActivityHighestPriorityBinding; |
||||
import com.arialyy.simple.core.download.multi_download.DownloadAdapter; |
||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; |
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/6/2. |
||||
* 最高优先级任务Demo |
||||
*/ |
||||
public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorityBinding> { |
||||
private HorizontalProgressBarWithNumber mPb; |
||||
private Button mStart; |
||||
private Button mStop; |
||||
private Button mCancel; |
||||
private TextView mSize; |
||||
private TextView mSpeed; |
||||
private RecyclerView mList; |
||||
|
||||
private String mTaskName = "光明大陆"; |
||||
private static final String DOWNLOAD_URL = |
||||
"https://res5.d.cn/6f78ee3bcfdd033e64892a8553a95814cf5b4a62b12a76d9eb2a694905f0dc30fa5c7f728806a4ee0b3479e7b26a38707dac92b136add91191ac1219aadb4a3aa70bfa6d06d2d8db.apk"; |
||||
private DownloadAdapter mAdapter; |
||||
private List<AbsEntity> mData = new ArrayList<>(); |
||||
private Set<String> mRecord = new HashSet<>(); |
||||
|
||||
@Override protected int setLayoutId() { |
||||
return R.layout.activity_highest_priority; |
||||
} |
||||
|
||||
@Override protected void init(Bundle savedInstanceState) { |
||||
super.init(savedInstanceState); |
||||
mPb = findViewById(R.id.progressBar); |
||||
mStart = findViewById(R.id.start); |
||||
mStop = findViewById(R.id.stop); |
||||
mCancel = findViewById(R.id.cancel); |
||||
mSize = findViewById(R.id.size); |
||||
mSpeed = findViewById(R.id.speed); |
||||
mList = findViewById(R.id.list); |
||||
|
||||
setTitle("最高优先级任务"); |
||||
getBinding().setTaskName("任务名:" + mTaskName + " (最高优先级任务)"); |
||||
initWidget(); |
||||
Aria.download(this).register(); |
||||
} |
||||
|
||||
private void initWidget() { |
||||
DownloadTarget target = Aria.download(this).load(DOWNLOAD_URL); |
||||
mPb.setProgress(target.getPercent()); |
||||
if (target.getTaskState() == IEntity.STATE_STOP) { |
||||
mStart.setText("恢复"); |
||||
mStart.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); |
||||
setBtState(true); |
||||
} else if (target.isRunning()) { |
||||
setBtState(false); |
||||
} |
||||
mSize.setText(target.getConvertFileSize()); |
||||
List<DownloadEntity> temp = Aria.download(this).getTaskList(); |
||||
if (temp != null && !temp.isEmpty()) { |
||||
for (DownloadEntity entity : temp) { |
||||
if (entity.getUrl().equals(DOWNLOAD_URL)) continue; |
||||
mData.add(entity); |
||||
mRecord.add(entity.getUrl()); |
||||
} |
||||
} |
||||
mAdapter = new DownloadAdapter(this, mData); |
||||
mList.setLayoutManager(new LinearLayoutManager(this)); |
||||
mList.setAdapter(mAdapter); |
||||
} |
||||
|
||||
@Override public boolean onCreateOptionsMenu(Menu menu) { |
||||
getMenuInflater().inflate(R.menu.menu_highest_priority, menu); |
||||
return super.onCreateOptionsMenu(menu); |
||||
} |
||||
|
||||
@Override public boolean onMenuItemClick(MenuItem item) { |
||||
switch (item.getItemId()) { |
||||
case R.id.add_task: |
||||
List<DownloadEntity> temp = getModule(DownloadModule.class).getHighestTestList(); |
||||
for (DownloadEntity entity : temp) { |
||||
String url = entity.getUrl(); |
||||
if (mRecord.contains(url)) { |
||||
continue; |
||||
} |
||||
mAdapter.addDownloadEntity(entity); |
||||
mRecord.add(url); |
||||
} |
||||
mAdapter.notifyDataSetChanged(); |
||||
break; |
||||
case R.id.help: |
||||
String title = "最高优先级任务介绍"; |
||||
String msg = " 将任务设置为最高优先级任务,最高优先级任务有以下特点:\n" |
||||
+ " 1、在下载队列中,有且只有一个最高优先级任务\n" |
||||
+ " 2、最高优先级任务会一直存在,直到用户手动暂停或任务完成\n" |
||||
+ " 3、任务调度器不会暂停最高优先级任务\n" |
||||
+ " 4、用户手动暂停或任务完成后,第二次重新执行该任务,该命令将失效\n" |
||||
+ " 5、如果下载队列中已经满了,则会停止队尾的任务,当高优先级任务完成后,该队尾任务将自动执行\n" |
||||
+ " 6、把任务设置为最高优先级任务后,将自动执行任务,不需要重新调用start()启动任务"; |
||||
showMsgDialog(title, msg); |
||||
break; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public void onClick(View view) { |
||||
switch (view.getId()) { |
||||
case R.id.start: |
||||
String text = ((TextView) view).getText().toString(); |
||||
if (text.equals("重新开始?") || text.equals("开始")) { |
||||
Aria.download(this) |
||||
.load(DOWNLOAD_URL) |
||||
.setFilePath(Environment.getExternalStorageDirectory().getPath() |
||||
+ "/Download/" |
||||
+ mTaskName |
||||
+ ".apk") |
||||
.setHighestPriority(); |
||||
} else if (text.equals("恢复")) { |
||||
Aria.download(this).load(DOWNLOAD_URL).resume(); |
||||
} |
||||
break; |
||||
case R.id.stop: |
||||
Aria.download(this).load(DOWNLOAD_URL).pause(); |
||||
break; |
||||
case R.id.cancel: |
||||
Aria.download(this).load(DOWNLOAD_URL).cancel(); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置start 和 stop 按钮状态 |
||||
*/ |
||||
private void setBtState(boolean state) { |
||||
mStart.setEnabled(state); |
||||
mStop.setEnabled(!state); |
||||
} |
||||
|
||||
@Download.onPre public void onPre(DownloadTask task) { |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskPre public void onTaskPre(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
mSize.setText(task.getConvertFileSize()); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskStart public void onTaskStart(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(false); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskResume public void onTaskResume(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(false); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskStop public void onTaskStop(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
mStart.setText("恢复"); |
||||
mStart.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
mStart.setText("开始"); |
||||
mPb.setProgress(0); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskFail public void onTaskFail(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
} else { |
||||
L.d(TAG, "download fail【" + task.getKey() + "】"); |
||||
} |
||||
} |
||||
|
||||
@Download.onTaskComplete public void onTaskComplete(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
mStart.setText("重新开始"); |
||||
mStart.setTextColor(getResources().getColor(android.R.color.holo_green_light)); |
||||
mPb.setProgress(100); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
mPb.setProgress(task.getPercent()); |
||||
mSpeed.setText(task.getConvertSpeed()); |
||||
} |
||||
mAdapter.setProgress(task.getDownloadEntity()); |
||||
} |
||||
} |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.simple.core.download; |
||||
|
||||
import android.os.Bundle; |
||||
import android.os.Environment; |
||||
import android.support.v7.widget.LinearLayoutManager; |
||||
import android.support.v7.widget.RecyclerView; |
||||
import android.view.Menu; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.widget.Button; |
||||
import android.widget.TextView; |
||||
import com.arialyy.annotations.Download; |
||||
import com.arialyy.aria.core.Aria; |
||||
import com.arialyy.aria.core.download.DownloadEntity; |
||||
import com.arialyy.aria.core.download.DownloadTarget; |
||||
import com.arialyy.aria.core.download.DownloadTask; |
||||
import com.arialyy.aria.core.inf.AbsEntity; |
||||
import com.arialyy.aria.core.inf.IEntity; |
||||
import com.arialyy.frame.util.show.L; |
||||
import com.arialyy.simple.R; |
||||
import com.arialyy.simple.base.BaseActivity; |
||||
import com.arialyy.simple.databinding.ActivityHighestPriorityBinding; |
||||
import com.arialyy.simple.core.download.multi_download.DownloadAdapter; |
||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; |
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/6/2. |
||||
* 最高优先级任务Demo |
||||
*/ |
||||
public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorityBinding> { |
||||
private HorizontalProgressBarWithNumber mPb; |
||||
private Button mStart; |
||||
private Button mStop; |
||||
private Button mCancel; |
||||
private TextView mSize; |
||||
private TextView mSpeed; |
||||
private RecyclerView mList; |
||||
|
||||
private String mTaskName = "光明大陆"; |
||||
private static final String DOWNLOAD_URL = |
||||
"https://res5.d.cn/6f78ee3bcfdd033e64892a8553a95814cf5b4a62b12a76d9eb2a694905f0dc30fa5c7f728806a4ee0b3479e7b26a38707dac92b136add91191ac1219aadb4a3aa70bfa6d06d2d8db.apk"; |
||||
private DownloadAdapter mAdapter; |
||||
private List<AbsEntity> mData = new ArrayList<>(); |
||||
private Set<String> mRecord = new HashSet<>(); |
||||
|
||||
@Override protected int setLayoutId() { |
||||
return R.layout.activity_highest_priority; |
||||
} |
||||
|
||||
@Override protected void init(Bundle savedInstanceState) { |
||||
super.init(savedInstanceState); |
||||
mPb = findViewById(R.id.progressBar); |
||||
mStart = findViewById(R.id.start); |
||||
mStop = findViewById(R.id.stop); |
||||
mCancel = findViewById(R.id.cancel); |
||||
mSize = findViewById(R.id.size); |
||||
mSpeed = findViewById(R.id.speed); |
||||
mList = findViewById(R.id.list); |
||||
|
||||
setTitle("最高优先级任务"); |
||||
getBinding().setTaskName("任务名:" + mTaskName + " (最高优先级任务)"); |
||||
initWidget(); |
||||
Aria.download(this).register(); |
||||
} |
||||
|
||||
private void initWidget() { |
||||
DownloadTarget target = Aria.download(this).load(DOWNLOAD_URL); |
||||
mPb.setProgress(target.getPercent()); |
||||
if (target.getTaskState() == IEntity.STATE_STOP) { |
||||
mStart.setText("恢复"); |
||||
mStart.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); |
||||
setBtState(true); |
||||
} else if (target.isRunning()) { |
||||
setBtState(false); |
||||
} |
||||
mSize.setText(target.getConvertFileSize()); |
||||
List<DownloadEntity> temp = Aria.download(this).getTaskList(); |
||||
if (temp != null && !temp.isEmpty()) { |
||||
for (DownloadEntity entity : temp) { |
||||
if (entity.getUrl().equals(DOWNLOAD_URL)) continue; |
||||
mData.add(entity); |
||||
mRecord.add(entity.getUrl()); |
||||
} |
||||
} |
||||
mAdapter = new DownloadAdapter(this, mData); |
||||
mList.setLayoutManager(new LinearLayoutManager(this)); |
||||
mList.setAdapter(mAdapter); |
||||
} |
||||
|
||||
@Override public boolean onCreateOptionsMenu(Menu menu) { |
||||
getMenuInflater().inflate(R.menu.menu_highest_priority, menu); |
||||
return super.onCreateOptionsMenu(menu); |
||||
} |
||||
|
||||
@Override public boolean onMenuItemClick(MenuItem item) { |
||||
switch (item.getItemId()) { |
||||
case R.id.add_task: |
||||
List<DownloadEntity> temp = getModule(DownloadModule.class).getHighestTestList(); |
||||
for (DownloadEntity entity : temp) { |
||||
String url = entity.getUrl(); |
||||
if (mRecord.contains(url)) { |
||||
continue; |
||||
} |
||||
mAdapter.addDownloadEntity(entity); |
||||
mRecord.add(url); |
||||
} |
||||
mAdapter.notifyDataSetChanged(); |
||||
break; |
||||
case R.id.help: |
||||
String title = "最高优先级任务介绍"; |
||||
String msg = " 将任务设置为最高优先级任务,最高优先级任务有以下特点:\n" |
||||
+ " 1、在下载队列中,有且只有一个最高优先级任务\n" |
||||
+ " 2、最高优先级任务会一直存在,直到用户手动暂停或任务完成\n" |
||||
+ " 3、任务调度器不会暂停最高优先级任务\n" |
||||
+ " 4、用户手动暂停或任务完成后,第二次重新执行该任务,该命令将失效\n" |
||||
+ " 5、如果下载队列中已经满了,则会停止队尾的任务,当高优先级任务完成后,该队尾任务将自动执行\n" |
||||
+ " 6、把任务设置为最高优先级任务后,将自动执行任务,不需要重新调用start()启动任务"; |
||||
showMsgDialog(title, msg); |
||||
break; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public void onClick(View view) { |
||||
switch (view.getId()) { |
||||
case R.id.start: |
||||
String text = ((TextView) view).getText().toString(); |
||||
if (text.equals("重新开始?") || text.equals("开始")) { |
||||
Aria.download(this) |
||||
.load(DOWNLOAD_URL) |
||||
.setFilePath(Environment.getExternalStorageDirectory().getPath() |
||||
+ "/Download/" |
||||
+ mTaskName |
||||
+ ".apk") |
||||
.setHighestPriority(); |
||||
} else if (text.equals("恢复")) { |
||||
Aria.download(this).load(DOWNLOAD_URL).resume(); |
||||
} |
||||
break; |
||||
case R.id.stop: |
||||
Aria.download(this).load(DOWNLOAD_URL).pause(); |
||||
break; |
||||
case R.id.cancel: |
||||
Aria.download(this).load(DOWNLOAD_URL).cancel(); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置start 和 stop 按钮状态 |
||||
*/ |
||||
private void setBtState(boolean state) { |
||||
mStart.setEnabled(state); |
||||
mStop.setEnabled(!state); |
||||
} |
||||
|
||||
@Download.onPre public void onPre(DownloadTask task) { |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskPre public void onTaskPre(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
mSize.setText(task.getConvertFileSize()); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskStart public void onTaskStart(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(false); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskResume public void onTaskResume(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(false); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskStop public void onTaskStop(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
mStart.setText("恢复"); |
||||
mStart.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
mStart.setText("开始"); |
||||
mPb.setProgress(0); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskFail public void onTaskFail(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
} else { |
||||
L.d(TAG, "download fail【" + task.getKey() + "】"); |
||||
} |
||||
} |
||||
|
||||
@Download.onTaskComplete public void onTaskComplete(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
setBtState(true); |
||||
mStart.setText("重新开始"); |
||||
mStart.setTextColor(getResources().getColor(android.R.color.holo_green_light)); |
||||
mPb.setProgress(100); |
||||
} |
||||
mAdapter.updateState(task.getDownloadEntity()); |
||||
} |
||||
|
||||
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) { |
||||
if (task.getKey().equals(DOWNLOAD_URL)) { |
||||
mPb.setProgress(task.getPercent()); |
||||
mSpeed.setText(task.getConvertSpeed()); |
||||
} |
||||
mAdapter.setProgress(task.getDownloadEntity()); |
||||
} |
||||
} |
||||
|
@ -1,80 +1,80 @@ |
||||
package com.arialyy.simple.core.test; |
||||
|
||||
import android.os.Environment; |
||||
import android.view.View; |
||||
import com.arialyy.aria.core.Aria; |
||||
import com.arialyy.aria.core.common.QueueMod; |
||||
import com.arialyy.simple.R; |
||||
import com.arialyy.simple.base.BaseActivity; |
||||
import com.arialyy.simple.databinding.TestActivityMultiBinding; |
||||
|
||||
/** |
||||
* Created by AriaL on 2017/6/15. |
||||
*/ |
||||
|
||||
public class TestMutilTaskSysDownload extends BaseActivity<TestActivityMultiBinding> { |
||||
|
||||
@Override protected int setLayoutId() { |
||||
return R.layout.test_activity_multi; |
||||
} |
||||
|
||||
public void onClick(View view) { |
||||
String baseUrl = "http://file.bmob.cn/"; |
||||
String[] urlArray = { |
||||
"M02/3B/A4/oYYBAFaOeUSAc1QiAAFTbmA7AHs052.jpg", |
||||
"M02/3B/A4/oYYBAFaOeUaAfYC-AAFD8zf9NXc879.jpg", |
||||
"M02/3B/A4/oYYBAFaOeUuAOxhnAACSdmbqSac702.jpg", |
||||
"M02/3B/A4/oYYBAFaOeU2AFAIGAAFICximvXc924.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVCAPWMQAAFm2KWCq_E721.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVOAbiv9AAFfCTTgr94948.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVaAMR3tAAFf3yTuuCM577.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVmACEWhAAEt72ecbpg468.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVyAHHt4AAFg9e9bRio507.jpg", |
||||
"M02/3B/A4/oYYBAFaOeV-AClYXAAESLGY0gag424.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWKAA7N0AAF3omYOJUI703.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWWAD2lrAAFN7eRFxBs575.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWiAdCVEAAFg4273Dus313.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWyAJDm5AAF8JVoGVb0705.jpg", |
||||
"M02/3B/A4/oYYBAFaOeW-AUoA8AAGjKiHkXUo181.jpg", |
||||
"M02/3B/A4/oYYBAFaOeXKABIamAAFU7J7vraE265.jpg", |
||||
"M02/3B/A5/oYYBAFaOeXaAW09jAAFf37qdwDA457.jpg", |
||||
"M02/3B/A5/oYYBAFaOeXmAWmS7AAFtLNpWjgo967.jpg", |
||||
"M02/3B/A5/oYYBAFaOeX2AQf9cAAF2fhwS2UE145.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYCAKGnLAAFVAzks-qU937.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYOAMODNAAF6HjTTMq4819.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYeAbn8uAAFLSQLw48Q042.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYqAMJThAAFtrNe4UNM047.jpg", |
||||
"M02/3B/A5/oYYBAFaOeY2AbnQvAAFNSXWn0Dc026.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZCAIsr0AAFHZFEVhPc682.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZOAGvITAAFqPmfcc9c471.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZaATvjbAAFHDmALnhE003.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZmAJPuVAAFfPJC2wsE319.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZyAXtAmAAFfArJNwtM371.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZ-AGZN0AAFgqwYYCS8004.jpg", |
||||
"M02/3B/A5/oYYBAFaOeaOAbbrGAAFcq59JjUo205.jpg", |
||||
"M02/3B/A5/oYYBAFaOeaSAdFyoAACaxVxgUJA092.jpg" |
||||
}; |
||||
int maxNum = Aria.get(this).getDownloadConfig().getMaxTaskNum(); |
||||
Aria.get(this).setDownloadQueueMod(QueueMod.NOW); |
||||
for (int i = 0; i < urlArray.length; i++) { |
||||
Aria.download(this) |
||||
.load(baseUrl + urlArray[i]) |
||||
.setFilePath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg") |
||||
//.addHeader("Accept-Encoding", "gzip,deflate,sdcn")
|
||||
.start(); |
||||
//if (i < maxNum) {
|
||||
// Aria.download(this)
|
||||
// .load(baseUrl + urlArray[i])
|
||||
// .setDownloadPath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg")
|
||||
// //.addHeader("Accept-Encoding", "gzip,deflate,sdcn")
|
||||
// .start();
|
||||
//} else {
|
||||
// Aria.download(this)
|
||||
// .load(baseUrl + urlArray[i])
|
||||
// .setDownloadPath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg")
|
||||
// //.addHeader("Accept-Encoding", "gzip,deflate,sdcn")
|
||||
// .add();
|
||||
//}
|
||||
} |
||||
} |
||||
} |
||||
package com.arialyy.simple.core.test; |
||||
|
||||
import android.os.Environment; |
||||
import android.view.View; |
||||
import com.arialyy.aria.core.Aria; |
||||
import com.arialyy.aria.core.common.QueueMod; |
||||
import com.arialyy.simple.R; |
||||
import com.arialyy.simple.base.BaseActivity; |
||||
import com.arialyy.simple.databinding.TestActivityMultiBinding; |
||||
|
||||
/** |
||||
* Created by AriaL on 2017/6/15. |
||||
*/ |
||||
|
||||
public class TestMutilTaskSysDownload extends BaseActivity<TestActivityMultiBinding> { |
||||
|
||||
@Override protected int setLayoutId() { |
||||
return R.layout.test_activity_multi; |
||||
} |
||||
|
||||
public void onClick(View view) { |
||||
String baseUrl = "http://file.bmob.cn/"; |
||||
String[] urlArray = { |
||||
"M02/3B/A4/oYYBAFaOeUSAc1QiAAFTbmA7AHs052.jpg", |
||||
"M02/3B/A4/oYYBAFaOeUaAfYC-AAFD8zf9NXc879.jpg", |
||||
"M02/3B/A4/oYYBAFaOeUuAOxhnAACSdmbqSac702.jpg", |
||||
"M02/3B/A4/oYYBAFaOeU2AFAIGAAFICximvXc924.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVCAPWMQAAFm2KWCq_E721.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVOAbiv9AAFfCTTgr94948.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVaAMR3tAAFf3yTuuCM577.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVmACEWhAAEt72ecbpg468.jpg", |
||||
"M02/3B/A4/oYYBAFaOeVyAHHt4AAFg9e9bRio507.jpg", |
||||
"M02/3B/A4/oYYBAFaOeV-AClYXAAESLGY0gag424.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWKAA7N0AAF3omYOJUI703.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWWAD2lrAAFN7eRFxBs575.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWiAdCVEAAFg4273Dus313.jpg", |
||||
"M02/3B/A4/oYYBAFaOeWyAJDm5AAF8JVoGVb0705.jpg", |
||||
"M02/3B/A4/oYYBAFaOeW-AUoA8AAGjKiHkXUo181.jpg", |
||||
"M02/3B/A4/oYYBAFaOeXKABIamAAFU7J7vraE265.jpg", |
||||
"M02/3B/A5/oYYBAFaOeXaAW09jAAFf37qdwDA457.jpg", |
||||
"M02/3B/A5/oYYBAFaOeXmAWmS7AAFtLNpWjgo967.jpg", |
||||
"M02/3B/A5/oYYBAFaOeX2AQf9cAAF2fhwS2UE145.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYCAKGnLAAFVAzks-qU937.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYOAMODNAAF6HjTTMq4819.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYeAbn8uAAFLSQLw48Q042.jpg", |
||||
"M02/3B/A5/oYYBAFaOeYqAMJThAAFtrNe4UNM047.jpg", |
||||
"M02/3B/A5/oYYBAFaOeY2AbnQvAAFNSXWn0Dc026.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZCAIsr0AAFHZFEVhPc682.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZOAGvITAAFqPmfcc9c471.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZaATvjbAAFHDmALnhE003.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZmAJPuVAAFfPJC2wsE319.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZyAXtAmAAFfArJNwtM371.jpg", |
||||
"M02/3B/A5/oYYBAFaOeZ-AGZN0AAFgqwYYCS8004.jpg", |
||||
"M02/3B/A5/oYYBAFaOeaOAbbrGAAFcq59JjUo205.jpg", |
||||
"M02/3B/A5/oYYBAFaOeaSAdFyoAACaxVxgUJA092.jpg" |
||||
}; |
||||
int maxNum = Aria.get(this).getDownloadConfig().getMaxTaskNum(); |
||||
Aria.get(this).setDownloadQueueMod(QueueMod.NOW); |
||||
for (int i = 0; i < urlArray.length; i++) { |
||||
Aria.download(this) |
||||
.load(baseUrl + urlArray[i]) |
||||
.setFilePath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg") |
||||
//.addHeader("Accept-Encoding", "gzip,deflate,sdcn")
|
||||
.start(); |
||||
//if (i < maxNum) {
|
||||
// Aria.download(this)
|
||||
// .load(baseUrl + urlArray[i])
|
||||
// .setDownloadPath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg")
|
||||
// //.addHeader("Accept-Encoding", "gzip,deflate,sdcn")
|
||||
// .start();
|
||||
//} else {
|
||||
// Aria.download(this)
|
||||
// .load(baseUrl + urlArray[i])
|
||||
// .setDownloadPath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg")
|
||||
// //.addHeader("Accept-Encoding", "gzip,deflate,sdcn")
|
||||
// .add();
|
||||
//}
|
||||
} |
||||
} |
||||
} |
||||
|
@ -1,27 +1,27 @@ |
||||
## Project-wide Gradle settings. |
||||
# |
||||
# For more details on how to configure your build environment visit |
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html |
||||
# |
||||
# Specifies the JVM arguments used for the daemon process. |
||||
# The setting is particularly useful for tweaking memory settings. |
||||
# Default value: -Xmx1024m -XX:MaxPermSize=256m |
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 |
||||
# |
||||
# When configured, Gradle will run in incubating parallel mode. |
||||
# This option should only be used with decoupled projects. More details, visit |
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects |
||||
# org.gradle.parallel=true |
||||
#Wed Dec 07 20:19:22 CST 2016 |
||||
#org.gradle.daemon=true |
||||
#org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 |
||||
# gradle proxy https://chaosleong.github.io/2017/02/10/Configuring-Gradle-Proxy/ |
||||
#systemProp.socksProxyHost=127.0.0.1 |
||||
#systemProp.socksProxyPort=1080 |
||||
#systemprop.socksProxyVersion=5 |
||||
|
||||
#Pandroid.debug.obsoleteApi=true |
||||
|
||||
# androidx https://developer.android.com/studio/preview/features/?hl=zh-cn#androidx_migration |
||||
#android.useAndroidX=true |
||||
## Project-wide Gradle settings. |
||||
# |
||||
# For more details on how to configure your build environment visit |
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html |
||||
# |
||||
# Specifies the JVM arguments used for the daemon process. |
||||
# The setting is particularly useful for tweaking memory settings. |
||||
# Default value: -Xmx1024m -XX:MaxPermSize=256m |
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 |
||||
# |
||||
# When configured, Gradle will run in incubating parallel mode. |
||||
# This option should only be used with decoupled projects. More details, visit |
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects |
||||
# org.gradle.parallel=true |
||||
#Wed Dec 07 20:19:22 CST 2016 |
||||
#org.gradle.daemon=true |
||||
#org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 |
||||
# gradle proxy https://chaosleong.github.io/2017/02/10/Configuring-Gradle-Proxy/ |
||||
#systemProp.socksProxyHost=127.0.0.1 |
||||
#systemProp.socksProxyPort=1080 |
||||
#systemprop.socksProxyVersion=5 |
||||
|
||||
#Pandroid.debug.obsoleteApi=true |
||||
|
||||
# androidx https://developer.android.com/studio/preview/features/?hl=zh-cn#androidx_migration |
||||
#android.useAndroidX=true |
||||
#android.enableJetifier=true |
Loading…
Reference in new issue