修复无法自动识别含有账号的ftpurl地址 https://github.com/AriaLyy/Aria/issues/146
parent
fd57d3ffe9
commit
29bcf0aa15
@ -0,0 +1,53 @@ |
||||
package com.arialyy.aria.core; |
||||
|
||||
import java.net.InetAddress; |
||||
|
||||
/** |
||||
* Created by Aria.Lao on 2017/10/24. |
||||
* ftp url 信息链接实体 |
||||
*/ |
||||
public class FtpUrlEntity { |
||||
|
||||
public String remotePath; |
||||
|
||||
public String account; |
||||
|
||||
/** |
||||
* 原始url |
||||
*/ |
||||
public String url; |
||||
|
||||
/** |
||||
* ftp协议 |
||||
*/ |
||||
public String protocol; |
||||
|
||||
/** |
||||
* 用户 |
||||
*/ |
||||
public String user; |
||||
/** |
||||
* 密码 |
||||
*/ |
||||
public String password; |
||||
|
||||
/** |
||||
* 端口 |
||||
*/ |
||||
public String port; |
||||
|
||||
/** |
||||
* 主机域名 |
||||
*/ |
||||
public String hostName; |
||||
|
||||
/** |
||||
* 是否需要登录 |
||||
*/ |
||||
public boolean needLogin = false; |
||||
|
||||
/** |
||||
* 有效的ip地址 |
||||
*/ |
||||
public InetAddress validAddr; |
||||
} |
@ -0,0 +1,28 @@ |
||||
package com.arialyy.aria.util; |
||||
|
||||
/** |
||||
* Created by Aria.Lao on 2017/10/24. |
||||
* 正则表达式 |
||||
*/ |
||||
public interface Regular { |
||||
/** |
||||
* ftp地址 |
||||
*/ |
||||
String REG_FTP_URL = "(\\w+)://(.*):(\\d*)/(.*)"; |
||||
|
||||
/** |
||||
* ftp主机、用户、密码分割 |
||||
*/ |
||||
String REG_FTP_HOST_NAME = "(\\w+):?(\\w+)?@(.*)"; |
||||
|
||||
/** |
||||
* 获取文件名 |
||||
*/ |
||||
String REG_FILE_NAME = "[/|\\\\|//]"; |
||||
|
||||
/** |
||||
* IPV4地址匹配 |
||||
*/ |
||||
String REG_IP_V4 = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])"; |
||||
|
||||
} |
@ -0,0 +1,73 @@ |
||||
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 Aria.Lao 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.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, true) |
||||
.addHeader("groupName", "value") |
||||
.setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk") |
||||
.start() |
||||
} |
||||
} |
Loading…
Reference in new issue