mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 23:07:26 -04:00
Fixed: Duplicate resume/cancel buttons in download notification.
* When there is a single download running, and we pause the download from the notification then we push a custom notification and update the foreground service notification. So when we are pushing our custom notification it is performing on the IO thread, and when we are setting it on the foreground service, then instead of updating the same notification it creates a new notification and shows it, and in the meantime, our pushing the cancel notification finishes and push a second notification. Due to the same notification ID, it updates the same notification but its actions(resume/cancel) are added twice. * We fixed it by synchronizing the process. Now, it first pushes the notification for paused download, and then if there is no other downloading going then it will set the current notification to foreground service.
This commit is contained in:
parent
b025813607
commit
765da6b651
@ -58,10 +58,7 @@ import com.tonyodev.fetch2.R.drawable
|
||||
import com.tonyodev.fetch2.R.string
|
||||
import com.tonyodev.fetch2.Status
|
||||
import com.tonyodev.fetch2.util.DEFAULT_NOTIFICATION_TIMEOUT_AFTER_RESET
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.kiwix.kiwixmobile.core.CoreApp
|
||||
import org.kiwix.kiwixmobile.core.Intents
|
||||
@ -212,14 +209,11 @@ class FetchDownloadNotificationManager @Inject constructor(
|
||||
|
||||
fun showDownloadPauseNotification(
|
||||
fetch: Fetch,
|
||||
download: Download,
|
||||
dispatcher: CoroutineDispatcher = Dispatchers.IO
|
||||
download: Download
|
||||
) {
|
||||
CoroutineScope(dispatcher).launch {
|
||||
val notificationBuilder = getNotificationBuilder(download.id, download.id)
|
||||
val cancelNotification = getCancelNotification(fetch, download, notificationBuilder)
|
||||
downloadNotificationManager.notify(download.id, cancelNotification)
|
||||
}
|
||||
val notificationBuilder = getNotificationBuilder(download.id, download.id)
|
||||
val cancelNotification = getCancelNotification(fetch, download, notificationBuilder)
|
||||
downloadNotificationManager.notify(download.id, cancelNotification)
|
||||
}
|
||||
|
||||
@Suppress("InjectDispatcher")
|
||||
|
Loading…
x
Reference in New Issue
Block a user