pull/34/head
kunfei 5 years ago
parent 0e9e9a842d
commit ba179cfee8
  1. 9
      app/src/main/java/io/legado/app/help/IntentHelp.kt
  2. 2
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  3. 2
      app/src/main/java/io/legado/app/service/CheckSourceService.kt

@ -29,4 +29,13 @@ object IntentHelp {
PendingIntent.FLAG_UPDATE_CURRENT PendingIntent.FLAG_UPDATE_CURRENT
) )
} }
inline fun <reified T> activityPendingIntent(context: Context, action: String): PendingIntent? {
return PendingIntent.getActivity(
context,
0,
Intent(context, T::class.java).apply { this.action = action },
PendingIntent.FLAG_UPDATE_CURRENT
)
}
} }

@ -291,7 +291,7 @@ abstract class BaseReadAloudService : BaseService(),
.setContentTitle(nTitle) .setContentTitle(nTitle)
.setContentText(nSubtitle) .setContentText(nSubtitle)
.setContentIntent( .setContentIntent(
IntentHelp.servicePendingIntent<ReadBookActivity>(this, "activity") IntentHelp.activityPendingIntent<ReadBookActivity>(this, "activity")
) )
if (pause) { if (pause) {
builder.addAction( builder.addAction(

@ -36,7 +36,7 @@ class CheckSourceService : BaseService() {
.setContentTitle(getString(R.string.check_book_source)) .setContentTitle(getString(R.string.check_book_source))
.setContentText(msg) .setContentText(msg)
.setContentIntent( .setContentIntent(
IntentHelp.servicePendingIntent<BookSourceActivity>(this, "activity") IntentHelp.activityPendingIntent<BookSourceActivity>(this, "activity")
) )
.addAction( .addAction(
R.drawable.ic_stop_black_24dp, R.drawable.ic_stop_black_24dp,

Loading…
Cancel
Save