pull/1194/head
parent
38e262393e
commit
94d4d15e7d
@ -1,25 +1,23 @@ |
|||||||
package io.legado.app.service.help |
package io.legado.app.service.help |
||||||
|
|
||||||
import android.content.Context |
import android.content.Context |
||||||
import android.content.Intent |
|
||||||
import io.legado.app.constant.IntentAction |
import io.legado.app.constant.IntentAction |
||||||
import io.legado.app.service.DownloadService |
import io.legado.app.service.DownloadService |
||||||
|
import io.legado.app.utils.startService |
||||||
|
|
||||||
object Download { |
object Download { |
||||||
|
|
||||||
fun start(context: Context, downloadId: Long, fileName: String) { |
fun start(context: Context, downloadId: Long, fileName: String) { |
||||||
Intent(context, DownloadService::class.java).let { |
context.startService<DownloadService> { |
||||||
it.action = IntentAction.start |
action = IntentAction.start |
||||||
it.putExtra("downloadId", downloadId) |
putExtra("downloadId", downloadId) |
||||||
it.putExtra("fileName", fileName) |
putExtra("fileName", fileName) |
||||||
context.startService(it) |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
fun stop(context: Context) { |
fun stop(context: Context) { |
||||||
Intent(context, DownloadService::class.java).let { |
context.startService<DownloadService> { |
||||||
it.action = IntentAction.stop |
action = IntentAction.stop |
||||||
context.startService(it) |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
Loading…
Reference in new issue