|
|
@ -16,8 +16,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
package com.arialyy.simple.download; |
|
|
|
package com.arialyy.simple.download; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver; |
|
|
|
import android.content.ContentResolver; |
|
|
|
import android.content.ContentResolver; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.Intent; |
|
|
|
|
|
|
|
import android.content.IntentFilter; |
|
|
|
import android.net.Uri; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Environment; |
|
|
|
import android.os.Environment; |
|
|
@ -35,6 +38,7 @@ import com.arialyy.aria.core.common.RequestEnum; |
|
|
|
import com.arialyy.aria.core.download.DownloadTarget; |
|
|
|
import com.arialyy.aria.core.download.DownloadTarget; |
|
|
|
import com.arialyy.aria.core.download.DownloadTask; |
|
|
|
import com.arialyy.aria.core.download.DownloadTask; |
|
|
|
import com.arialyy.aria.core.inf.IEntity; |
|
|
|
import com.arialyy.aria.core.inf.IEntity; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.scheduler.ISchedulers; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
import com.arialyy.frame.util.show.L; |
|
|
|
import com.arialyy.frame.util.show.L; |
|
|
@ -43,6 +47,7 @@ import com.arialyy.simple.R; |
|
|
|
import com.arialyy.simple.base.BaseActivity; |
|
|
|
import com.arialyy.simple.base.BaseActivity; |
|
|
|
import com.arialyy.simple.databinding.ActivitySingleBinding; |
|
|
|
import com.arialyy.simple.databinding.ActivitySingleBinding; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
@ -51,22 +56,46 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
|
|
|
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
|
|
|
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
|
|
|
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
|
|
|
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apks";
|
|
|
|
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apks";
|
|
|
|
"http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zips"; |
|
|
|
//"http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zip";
|
|
|
|
//"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip";
|
|
|
|
//"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip";
|
|
|
|
//"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk";
|
|
|
|
//"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk";
|
|
|
|
//"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
|
|
|
|
//"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
|
|
|
|
//"https://static.donguo.me/video/ip/course/pfys_1.mp4";
|
|
|
|
//"https://static.donguo.me/video/ip/course/pfys_1.mp4";
|
|
|
|
//"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864";
|
|
|
|
//"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864";
|
|
|
|
//"https://d.pcs.baidu.com/file/a02c89a2d479d4fd2756f3313d42491d?fid=4232431903-250528-1114369760340736&dstime=1525491372&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-3C13vkOkuk4TqXvVYW05zj1K0ao%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=8651730921842106225&dp-callid=0&r=165533013";
|
|
|
|
//"https://d.pcs.baidu.com/file/a02c89a2d479d4fd2756f3313d42491d?fid=4232431903-250528-1114369760340736&dstime=1525491372&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-3C13vkOkuk4TqXvVYW05zj1K0ao%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=8651730921842106225&dp-callid=0&r=165533013";
|
|
|
|
//"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1";
|
|
|
|
//"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1";
|
|
|
|
//"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
|
|
|
|
//"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
|
|
|
|
//"http://9.9.9.59:5000/download/CentOS-7-x86_64-Minimal-1804.iso";
|
|
|
|
//"http://9.9.9.50:5000/download1";
|
|
|
|
|
|
|
|
"http://9.9.9.50:5000/download/CentOS-7-x86_64-Minimal-1804.iso"; |
|
|
|
//"https://firmwareapi.azurewebsites.net/firmware-overview?name=A19_Filament_W_IMG0038_00102411-encrypted.ota";
|
|
|
|
//"https://firmwareapi.azurewebsites.net/firmware-overview?name=A19_Filament_W_IMG0038_00102411-encrypted.ota";
|
|
|
|
@Bind(R.id.start) Button mStart; |
|
|
|
@Bind(R.id.start) Button mStart; |
|
|
|
@Bind(R.id.stop) Button mStop; |
|
|
|
@Bind(R.id.stop) Button mStop; |
|
|
|
@Bind(R.id.cancel) Button mCancel; |
|
|
|
@Bind(R.id.cancel) Button mCancel; |
|
|
|
@Bind(R.id.speeds) RadioGroup mRg; |
|
|
|
@Bind(R.id.speeds) RadioGroup mRg; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BroadcastReceiver receiver = new BroadcastReceiver() { |
|
|
|
|
|
|
|
@Override public void onReceive(Context context, Intent intent) { |
|
|
|
|
|
|
|
if (intent.getAction().equals(ISchedulers.ARIA_TASK_INFO_ACTION)) { |
|
|
|
|
|
|
|
ALog.d(TAG, "state = " + intent.getIntExtra(ISchedulers.TASK_STATE, -1)); |
|
|
|
|
|
|
|
ALog.d(TAG, "type = " + intent.getIntExtra(ISchedulers.TASK_TYPE, -1)); |
|
|
|
|
|
|
|
ALog.d(TAG, "speed = " + intent.getLongExtra(ISchedulers.TASK_SPEED, -1)); |
|
|
|
|
|
|
|
ALog.d(TAG, "percent = " + intent.getIntExtra(ISchedulers.TASK_PERCENT, -1)); |
|
|
|
|
|
|
|
ALog.d(TAG, "entity = " + intent.getParcelableExtra(ISchedulers.TASK_ENTITY).toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onResume() { |
|
|
|
|
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
//registerReceiver(receiver, new IntentFilter(ISchedulers.ARIA_TASK_INFO_ACTION));
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onDestroy() { |
|
|
|
|
|
|
|
super.onDestroy(); |
|
|
|
|
|
|
|
unregisterReceiver(receiver); |
|
|
|
|
|
|
|
Aria.download(this).unRegister(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onCreate(Bundle savedInstanceState) { |
|
|
|
@Override protected void onCreate(Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
Aria.download(this).register(); |
|
|
|
Aria.download(this).register(); |
|
|
@ -142,14 +171,14 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
@Download.onTaskRunning protected void running(DownloadTask task) { |
|
|
|
@Download.onTaskRunning protected void running(DownloadTask task) { |
|
|
|
ALog.d(TAG, String.format("%s_running_%s", getClass().getName(), hashCode())); |
|
|
|
ALog.d(TAG, String.format("%s_running_%s", getClass().getName(), hashCode())); |
|
|
|
//if (task.getKey().equals(DOWNLOAD_URL)) {
|
|
|
|
//if (task.getKey().equals(DOWNLOAD_URL)) {
|
|
|
|
//Log.d(TAG, task.getKey());
|
|
|
|
//Log.d(TAG, task.getKey());
|
|
|
|
long len = task.getFileSize(); |
|
|
|
long len = task.getFileSize(); |
|
|
|
if (len == 0) { |
|
|
|
if (len == 0) { |
|
|
|
getBinding().setProgress(0); |
|
|
|
getBinding().setProgress(0); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
getBinding().setProgress(task.getPercent()); |
|
|
|
getBinding().setProgress(task.getPercent()); |
|
|
|
} |
|
|
|
} |
|
|
|
getBinding().setSpeed(task.getConvertSpeed()); |
|
|
|
getBinding().setSpeed(task.getConvertSpeed()); |
|
|
|
//}
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -199,20 +228,20 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskComplete void taskComplete(DownloadTask task) { |
|
|
|
@Download.onTaskComplete void taskComplete(DownloadTask task) { |
|
|
|
//if (task.getKey().equals(DOWNLOAD_URL)) {
|
|
|
|
//if (task.getKey().equals(DOWNLOAD_URL)) {
|
|
|
|
getBinding().setProgress(100); |
|
|
|
getBinding().setProgress(100); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); |
|
|
|
mStart.setText("重新开始?"); |
|
|
|
mStart.setText("重新开始?"); |
|
|
|
//mCancel.setEnabled(false);
|
|
|
|
//mCancel.setEnabled(false);
|
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
L.d(TAG, "path ==> " + task.getDownloadEntity().getDownloadPath()); |
|
|
|
L.d(TAG, "path ==> " + task.getDownloadEntity().getDownloadPath()); |
|
|
|
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath()))); |
|
|
|
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath()))); |
|
|
|
L.d(TAG, "data ==> " + Aria.download(this).getDownloadEntity(DOWNLOAD_URL)); |
|
|
|
L.d(TAG, "data ==> " + Aria.download(this).getDownloadEntity(DOWNLOAD_URL)); |
|
|
|
//Intent install = new Intent(Intent.ACTION_VIEW);
|
|
|
|
//Intent install = new Intent(Intent.ACTION_VIEW);
|
|
|
|
//install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
//install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
//File apkFile = new File(task.getDownloadPath());
|
|
|
|
//File apkFile = new File(task.getDownloadPath());
|
|
|
|
//install.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
|
|
|
|
//install.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
|
|
|
|
//startActivity(install);
|
|
|
|
//startActivity(install);
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -271,6 +300,9 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
// file.delete();
|
|
|
|
// file.delete();
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
|
|
|
|
params.put("key", "value"); |
|
|
|
|
|
|
|
params.put("filename", "CentOS-7-x86_64-Minimal-1804.iso"); |
|
|
|
Aria.download(SingleTaskActivity.this) |
|
|
|
Aria.download(SingleTaskActivity.this) |
|
|
|
.load(DOWNLOAD_URL) |
|
|
|
.load(DOWNLOAD_URL) |
|
|
|
//.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
|
|
|
|
//.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
|
|
|
@ -279,7 +311,9 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
//.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0")
|
|
|
|
//.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0")
|
|
|
|
.useServerFileName(true) |
|
|
|
.useServerFileName(true) |
|
|
|
.setFilePath(path, true) |
|
|
|
.setFilePath(path, true) |
|
|
|
//.asPost().setParam("key", "value")
|
|
|
|
//.asGet()
|
|
|
|
|
|
|
|
.asPost() |
|
|
|
|
|
|
|
.setParams(params) |
|
|
|
//.setExtendField("{\n"
|
|
|
|
//.setExtendField("{\n"
|
|
|
|
// + "\"id\":\"你的样子\"\n< > "
|
|
|
|
// + "\"id\":\"你的样子\"\n< > "
|
|
|
|
// + "}")
|
|
|
|
// + "}")
|
|
|
@ -288,11 +322,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
//.add();
|
|
|
|
//.add();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onDestroy() { |
|
|
|
|
|
|
|
super.onDestroy(); |
|
|
|
|
|
|
|
//Aria.download(this).unRegister();
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onStop() { |
|
|
|
@Override protected void onStop() { |
|
|
|
super.onStop(); |
|
|
|
super.onStop(); |
|
|
|
//Aria.download(this).unRegister();
|
|
|
|
//Aria.download(this).unRegister();
|
|
|
|