|
|
@ -50,7 +50,7 @@ class KotlinDownloadActivity : BaseActivity<ActivitySingleKotlinBinding>() { |
|
|
|
private var mUrl: String? = null |
|
|
|
private var mUrl: String? = null |
|
|
|
private var mFilePath: String? = null |
|
|
|
private var mFilePath: String? = null |
|
|
|
private var mModule: HttpDownloadModule? = null |
|
|
|
private var mModule: HttpDownloadModule? = null |
|
|
|
private val mTaskId: Long = -1 |
|
|
|
private var mTaskId: Long = -1 |
|
|
|
|
|
|
|
|
|
|
|
internal var receiver: BroadcastReceiver = object : BroadcastReceiver() { |
|
|
|
internal var receiver: BroadcastReceiver = object : BroadcastReceiver() { |
|
|
|
override fun onReceive( |
|
|
|
override fun onReceive( |
|
|
@ -104,7 +104,7 @@ class KotlinDownloadActivity : BaseActivity<ActivitySingleKotlinBinding>() { |
|
|
|
.get(HttpDownloadModule::class.java) |
|
|
|
.get(HttpDownloadModule::class.java) |
|
|
|
mModule!!.getHttpDownloadInfo(this) |
|
|
|
mModule!!.getHttpDownloadInfo(this) |
|
|
|
.observe(this, Observer { entity -> |
|
|
|
.observe(this, Observer { entity -> |
|
|
|
if (entity == null || entity.id < 0) { |
|
|
|
if (entity == null) { |
|
|
|
return@Observer |
|
|
|
return@Observer |
|
|
|
} |
|
|
|
} |
|
|
|
if (entity.state == IEntity.STATE_STOP) { |
|
|
|
if (entity.state == IEntity.STATE_STOP) { |
|
|
@ -286,14 +286,21 @@ class KotlinDownloadActivity : BaseActivity<ActivitySingleKotlinBinding>() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun startD() { |
|
|
|
private fun startD() { |
|
|
|
Aria.download(this) |
|
|
|
if (mTaskId == -1L) { |
|
|
|
.load(mUrl!!) |
|
|
|
|
|
|
|
//.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3") |
|
|
|
mTaskId = Aria.download(this) |
|
|
|
//.addHeader("Accept-Encoding", "gzip, deflate") |
|
|
|
.load(mUrl!!) |
|
|
|
//.addHeader("DNT", "1") |
|
|
|
//.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3") |
|
|
|
//.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0") |
|
|
|
//.addHeader("Accept-Encoding", "gzip, deflate") |
|
|
|
.setFilePath(mFilePath!!, true) |
|
|
|
//.addHeader("DNT", "1") |
|
|
|
.create() |
|
|
|
//.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0") |
|
|
|
|
|
|
|
.setFilePath(mFilePath!!, true) |
|
|
|
|
|
|
|
.create() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Aria.download(this) |
|
|
|
|
|
|
|
.load(mTaskId) |
|
|
|
|
|
|
|
.resume() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onStop() { |
|
|
|
override fun onStop() { |
|
|
|