优化
This commit is contained in:
@@ -250,12 +250,12 @@ class DownloadService : BaseService() {
|
|||||||
.setSubText(getString(R.string.action_download))
|
.setSubText(getString(R.string.action_download))
|
||||||
.setContentTitle(content)
|
.setContentTitle(content)
|
||||||
.setContentIntent(
|
.setContentIntent(
|
||||||
servicePendingIntent<DownloadService>(IntentAction.play) {
|
servicePendingIntent<DownloadService>(IntentAction.play, downloadId.toInt()) {
|
||||||
putExtra("downloadId", downloadId)
|
putExtra("downloadId", downloadId)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.setDeleteIntent(
|
.setDeleteIntent(
|
||||||
servicePendingIntent<DownloadService>(IntentAction.stop) {
|
servicePendingIntent<DownloadService>(IntentAction.stop, downloadId.toInt()) {
|
||||||
putExtra("downloadId", downloadId)
|
putExtra("downloadId", downloadId)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ inline fun <reified T : Service> Context.stopService() {
|
|||||||
@SuppressLint("UnspecifiedImmutableFlag")
|
@SuppressLint("UnspecifiedImmutableFlag")
|
||||||
inline fun <reified T : Service> Context.servicePendingIntent(
|
inline fun <reified T : Service> Context.servicePendingIntent(
|
||||||
action: String,
|
action: String,
|
||||||
|
requestCode: Int = 0,
|
||||||
configIntent: Intent.() -> Unit = {}
|
configIntent: Intent.() -> Unit = {}
|
||||||
): PendingIntent? {
|
): PendingIntent? {
|
||||||
val intent = Intent(this, T::class.java)
|
val intent = Intent(this, T::class.java)
|
||||||
@@ -73,7 +74,7 @@ inline fun <reified T : Service> Context.servicePendingIntent(
|
|||||||
} else {
|
} else {
|
||||||
FLAG_UPDATE_CURRENT
|
FLAG_UPDATE_CURRENT
|
||||||
}
|
}
|
||||||
return getService(this, 0, intent, flags)
|
return getService(this, requestCode, intent, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnspecifiedImmutableFlag")
|
@SuppressLint("UnspecifiedImmutableFlag")
|
||||||
|
|||||||
Reference in New Issue
Block a user