@@ -8,7 +8,11 @@ import android.os.Bundle
8
8
import android.widget.Toast
9
9
import androidx.fragment.app.DialogFragment
10
10
import java.io.File
11
- import kotlinx.coroutines.*
11
+ import kotlinx.coroutines.CoroutineScope
12
+ import kotlinx.coroutines.Deferred
13
+ import kotlinx.coroutines.Dispatchers
14
+ import kotlinx.coroutines.async
15
+ import kotlinx.coroutines.runBlocking
12
16
import quanti.com.kotlinlog.R
13
17
import quanti.com.kotlinlog.utils.copyLogsTOSDCard
14
18
import quanti.com.kotlinlog.utils.getFormattedFileNameDayNow
@@ -121,19 +125,16 @@ class SendLogDialogFragment : DialogFragment() {
121
125
*/
122
126
@Suppress(" UNUSED_PARAMETER" )
123
127
private fun positiveButtonClick (dialog : DialogInterface , which : Int ) =
124
- CoroutineScope ( Dispatchers . Main ).launch {
128
+ runBlocking {
125
129
val appContext = this @SendLogDialogFragment.requireContext().applicationContext
126
130
127
131
val addresses = requireArguments().getStringArray(SEND_EMAIL_ADDRESSES )
128
132
val subject =
129
133
getString(R .string.logs_email_subject) + " " + getFormattedFileNameDayNow()
130
134
val bodyText = getString(R .string.logs_email_text)
131
-
132
- // await non block's current thread
133
135
val zipFileUri = zipFile?.await()?.getUriForFile(appContext)
134
136
135
137
val intent = Intent (Intent .ACTION_SEND ).apply {
136
- type = " message/rfc822" // email
137
138
type = " message/rfc822" // email
138
139
flags = Intent .FLAG_GRANT_READ_URI_PERMISSION
139
140
putExtra(Intent .EXTRA_EMAIL , addresses)
@@ -159,7 +160,7 @@ class SendLogDialogFragment : DialogFragment() {
159
160
*/
160
161
@Suppress(" UNUSED_PARAMETER" )
161
162
private fun neutralButtonClick (dialog : DialogInterface , which : Int ) =
162
- CoroutineScope ( Dispatchers . Main ).launch {
163
+ runBlocking {
163
164
val appContext = this @SendLogDialogFragment.requireContext().applicationContext
164
165
165
166
val file = zipFile?.await()?.copyLogsTOSDCard(requireContext())
0 commit comments