Fix attachment service listeners

This commit is contained in:
J-Jamet
2020-09-13 16:18:46 +02:00
parent 8267e13d22
commit 83740f77bb

View File

@@ -58,15 +58,9 @@ class AttachmentFileNotificationService: LockNotificationService() {
fun addActionTaskListener(actionTaskListener: ActionTaskListener) {
mActionTaskListeners.add(actionTaskListener)
attachmentNotificationList.forEach {
it.attachmentFileAction?.listener = attachmentFileActionListener
}
}
fun removeActionTaskListener(actionTaskListener: ActionTaskListener) {
attachmentNotificationList.forEach {
it.attachmentFileAction?.listener = null
}
mActionTaskListeners.remove(actionTaskListener)
}
}
@@ -278,7 +272,9 @@ class AttachmentFileNotificationService: LockNotificationService() {
mainScope.launch {
AttachmentFileAction(attachmentNotification,
contentResolver).executeAction()
contentResolver).apply {
listener = attachmentFileActionListener
}.executeAction()
}
}
} catch (e: Exception) {
@@ -300,15 +296,18 @@ class AttachmentFileNotificationService: LockNotificationService() {
}
suspend fun executeAction() {
TimeoutHelper.temporarilyDisableTimeout()
// on pre execute
attachmentNotification.attachmentFileAction = this
CoroutineScope(Dispatchers.Main).launch {
TimeoutHelper.temporarilyDisableTimeout()
attachmentNotification.attachmentFileAction = this@AttachmentFileAction
attachmentNotification.entryAttachmentState.apply {
downloadState = AttachmentState.START
downloadProgression = 0
}
listener?.onUpdate(attachmentNotification)
}
withContext(Dispatchers.IO) {
// on Progress with thread