mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 13:48:55 +03:00
fix pause button duplication
This commit is contained in:
parent
283576336a
commit
64d737433f
1 changed files with 13 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.tachiyomi.data.download.anime
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
|
@ -77,6 +78,7 @@ internal class AnimeDownloadNotifier(private val context: Context) {
|
|||
*
|
||||
* @param download download object containing download information.
|
||||
*/
|
||||
@SuppressLint("RestrictedApi")
|
||||
fun onProgressChange(download: AnimeDownload) {
|
||||
val notificationId = download.episode.id.hashCode()
|
||||
|
||||
|
@ -112,18 +114,19 @@ internal class AnimeDownloadNotifier(private val context: Context) {
|
|||
}
|
||||
setOngoing(true)
|
||||
|
||||
// Add pause action if not already added
|
||||
if (!paused) {
|
||||
addAction(
|
||||
R.drawable.ic_pause_24dp,
|
||||
context.getString(R.string.action_pause),
|
||||
NotificationReceiver.pauseAnimeDownloadsPendingBroadcast(context),
|
||||
)
|
||||
paused = true
|
||||
}
|
||||
|
||||
show(notificationId)
|
||||
}
|
||||
|
||||
// Add pause action if not already added
|
||||
val pauseActionAdded = progressNotificationBuilder.mActions.any { it.icon == R.drawable.ic_pause_24dp }
|
||||
if (!paused && !pauseActionAdded) {
|
||||
progressNotificationBuilder.addAction(
|
||||
R.drawable.ic_pause_24dp,
|
||||
context.getString(R.string.action_pause),
|
||||
NotificationReceiver.pauseAnimeDownloadsPendingBroadcast(context),
|
||||
)
|
||||
paused = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue