This commit is contained in:
laoyuyu
2018-11-05 21:13:58 +08:00
parent 0b095b9b11
commit 66b36b355a
43 changed files with 598 additions and 275 deletions

View File

@@ -1,75 +1,75 @@
package com.arialyy.simple.download
import android.os.Bundle
import android.os.Environment
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View
import com.arialyy.annotations.Download
import com.arialyy.aria.core.Aria
import com.arialyy.aria.core.download.DownloadTask
import com.arialyy.simple.R
import com.arialyy.simple.base.BaseActivity
/**
* Created by lyy on 2017/10/23.
*/
class KotlinDownloadActivity : AppCompatActivity() {
private val DOWNLOAD_URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"
private val TAG = "KotlinDownloadActivity";
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(setLayoutId())
}
fun setLayoutId(): Int {
return R.layout.activity_single
}
fun init(savedInstanceState: Bundle?) {
title = "单任务下载"
// val target = Aria.download(this).load(DOWNLOAD_URL)
// binding.progress = target.getPercent()
// if (target.getTaskState() == IEntity.STATE_STOP) {
// mStart.setText("恢复")
// mStart.setTextColor(resources.getColor(android.R.color.holo_blue_light))
// setBtState(true)
// } else if (target.isDownloading()) {
// setBtState(false)
//package com.arialyy.simple.download
//
//import android.os.Bundle
//import android.os.Environment
//import android.support.v7.app.AppCompatActivity
//import android.util.Log
//import android.view.View
//import com.arialyy.annotations.Download
//import com.arialyy.aria.core.Aria
//import com.arialyy.aria.core.download.DownloadTask
//import com.arialyy.simple.R
//import com.arialyy.simple.base.BaseActivity
//
///**
// * Created by lyy on 2017/10/23.
// */
//class KotlinDownloadActivity : AppCompatActivity() {
//
// private val DOWNLOAD_URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"
//
// private val TAG = "KotlinDownloadActivity";
//
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
// setContentView(setLayoutId())
// }
//
// fun setLayoutId(): Int {
// return R.layout.activity_single
// }
//
// fun init(savedInstanceState: Bundle?) {
// title = "单任务下载"
//// val target = Aria.download(this).load(DOWNLOAD_URL)
//// binding.progress = target.getPercent()
//// if (target.getTaskState() == IEntity.STATE_STOP) {
//// mStart.setText("恢复")
//// mStart.setTextColor(resources.getColor(android.R.color.holo_blue_light))
//// setBtState(true)
//// } else if (target.isDownloading()) {
//// setBtState(false)
//// }
//// binding.fileSize = target.getConvertFileSize()
// Aria.get(this).downloadConfig.maxTaskNum = 2
// Aria.download(this).register()
// }
//
// @Download.onTaskRunning
// protected fun running(task: DownloadTask) {
// Log.d(TAG, task.percent.toString() + "")
//// val len = task.fileSize
//// if (len == 0L) {
//// binding.progress = 0
//// } else {
//// binding.progress = task.percent
//// }
//// binding.speed = task.convertSpeed
// }
//
// fun onClick(view: View) {
// when (view.id) {
// R.id.start -> startD()
// R.id.stop -> Aria.download(this).load(DOWNLOAD_URL).stop()
// R.id.cancel -> Aria.download(this).load(DOWNLOAD_URL).cancel()
// }
// binding.fileSize = target.getConvertFileSize()
Aria.get(this).downloadConfig.maxTaskNum = 2
Aria.download(this).register()
}
@Download.onTaskRunning
protected fun running(task: DownloadTask) {
Log.d(TAG, task.percent.toString() + "")
// val len = task.fileSize
// if (len == 0L) {
// binding.progress = 0
// } else {
// binding.progress = task.percent
// }
// binding.speed = task.convertSpeed
}
fun onClick(view: View) {
when (view.id) {
R.id.start -> startD()
R.id.stop -> Aria.download(this).load(DOWNLOAD_URL).stop()
R.id.cancel -> Aria.download(this).load(DOWNLOAD_URL).cancel()
}
}
private fun startD() {
Aria.download(this)
.load(DOWNLOAD_URL)
.addHeader("groupName", "value")
.setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk")
.start()
}
}
// }
//
// private fun startD() {
// Aria.download(this)
// .load(DOWNLOAD_URL)
// .addHeader("groupName", "value")
// .setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk")
// .start()
// }
//}

View File

@@ -16,6 +16,7 @@
package com.arialyy.simple.download;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -49,7 +50,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private static final String DOWNLOAD_URL =
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apks";
//"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip";
//"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk";
//"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
@@ -248,7 +249,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private void startD() {
//Aria.get(this).setLogLevel(ALog.LOG_CLOSE);
//Aria.download(this).load("aaaa.apk");
String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg9.apk";
String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg10.apk";
//File file = new File(path);
//if (file.exists()){
// file.delete();

View File

@@ -31,7 +31,8 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
//String URL = "ftps://192.168.29.140:990/download/SDK_Demo-release.apk";
//String URL = "http://d.quanscreen.com/k/down/resourceDownLoad?resourceId=1994&clientId=A000011106034058176";
//String URL = "ftp://z:z@dygod18.com:21211/[电影天堂www.dy2018.com]猩球崛起3终极之战BD国英双语中英双字.mkv";
String URL = "https://app-dl.byfen.com//app//201810//ef0400d637e768e9c630b4d38633ee06.zip";
//String URL = "https://app-dl.byfen.com//app//201810//ef0400d637e768e9c630b4d38633ee06.zip";
String URL = "ftps://9.9.9.59:990/download/SDK_Demo-release.apk";
//private String URL = "https://www.bilibili.com/bangumi/play/ep77693";
//private String URL = "http://cn-hbsjz-cmcc-v-03.acgvideo.com/upgcxcode/63/82/5108263/5108263-1-80.flv?expires=1530178500&platform=pc&ssig=vr7gLl0duyqWqSMnIpzaDA&oi=3746029570&nfa=BpfiWF+i4mNW8KzjZFHzBQ==&dynamic=1&hfa=2030547937&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI=&trid=3476be01a9254115b15f8cc7198600fe&nfc=1";
@@ -52,8 +53,8 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
public void onClick(View view) {
switch (view.getId()) {
case R.id.start:
module.start(URL);
//module.startFtp(URL);
//module.start(URL);
module.startFtp(URL);
break;
case R.id.stop:
module.stop(URL);

View File

@@ -78,10 +78,10 @@ public class AnyRunnModule {
.loadFtp(url)
.login("lao", "123456")
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/Download/")
//.asFtps()
//.setStorePath("/mnt/sdcard/Download/server.crt")
//.setAlias("www.laoyuyu.me")
//.setStorePass("123456")
.asFtps()
.setStorePath("/mnt/sdcard/Download/server.crt")
.setAlias("www.laoyuyu.me")
.setStorePass("123456")
.start();
}