@@ -44,6 +44,7 @@ import androidx.core.view.WindowCompat
44
44
import androidx.core.view.WindowInsetsCompat
45
45
import androidx.core.view.updatePadding
46
46
import androidx.lifecycle.Observer
47
+ import androidx.lifecycle.lifecycleScope
47
48
import androidx.loader.app.LoaderManager
48
49
import androidx.loader.content.Loader
49
50
import androidx.recyclerview.widget.LinearLayoutManager
@@ -53,6 +54,9 @@ import com.bumptech.glide.Glide
53
54
import com.bumptech.glide.RequestManager
54
55
import com.squareup.phrase.Phrase
55
56
import dagger.hilt.android.AndroidEntryPoint
57
+ import kotlinx.coroutines.Dispatchers
58
+ import kotlinx.coroutines.launch
59
+ import kotlinx.coroutines.withContext
56
60
import network.loki.messenger.R
57
61
import network.loki.messenger.databinding.MediaPreviewActivityBinding
58
62
import network.loki.messenger.databinding.MediaViewPageBinding
@@ -455,7 +459,7 @@ class MediaPreviewActivity : ScreenLockActionBarActivity(), RecipientModifiedLis
455
459
456
460
// If we have an attachment then we can take the filename from it, otherwise we have to take the
457
461
// more expensive route of looking up or synthesizing a filename from the MediaItem's Uri.
458
- var mediaFilename = " "
462
+ var mediaFilename: String? = null
459
463
if (mediaItem.attachment != null ) {
460
464
mediaFilename = mediaItem.attachment.filename
461
465
}
@@ -529,8 +533,10 @@ class MediaPreviewActivity : ScreenLockActionBarActivity(), RecipientModifiedLis
529
533
}
530
534
531
535
DeleteMediaPreviewDialog .show(this ){
532
- AttachmentUtil .deleteAttachment(applicationContext, mediaItem.attachment)
533
- finish()
536
+ lifecycleScope.launch(Dispatchers .Default ) {
537
+ AttachmentUtil .deleteAttachment(applicationContext, mediaItem.attachment)
538
+ withContext(Dispatchers .Main ){ finish() }
539
+ }
534
540
}
535
541
}
536
542
0 commit comments