Move blocking stuff to background thread
This commit is contained in:
parent
da6354c9a1
commit
417a37bbb4
|
@ -5,6 +5,7 @@ import android.net.Uri
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.smsmessenger.R
|
import com.simplemobiletools.smsmessenger.R
|
||||||
import com.simplemobiletools.smsmessenger.extensions.*
|
import com.simplemobiletools.smsmessenger.extensions.*
|
||||||
import kotlinx.android.synthetic.main.item_attachment_document.view.*
|
import kotlinx.android.synthetic.main.item_attachment_document.view.*
|
||||||
|
@ -25,16 +26,18 @@ fun View.setupDocumentPreview(
|
||||||
filename.text = title
|
filename.text = title
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachment) {
|
ensureBackgroundThread {
|
||||||
try {
|
try {
|
||||||
val size = context.getFileSizeFromUri(uri)
|
val size = context.getFileSizeFromUri(uri)
|
||||||
file_size.beVisible()
|
post {
|
||||||
file_size.text = size.formatSize()
|
file_size.beVisible()
|
||||||
|
file_size.text = size.formatSize()
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
file_size.beGone()
|
post {
|
||||||
|
file_size.beGone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
file_size.beGone()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val textColor = context.getProperTextColor()
|
val textColor = context.getProperTextColor()
|
||||||
|
|
Loading…
Reference in New Issue