0
0
mirror of https://github.com/markusfisch/BinaryEye.git synced 2024-09-20 12:02:17 +02:00

Get the Context only once and put in a val

Instead of (silently) invoking getters multiple times.
This commit is contained in:
Markus Fisch 2021-08-09 21:21:25 +02:00
parent 3ec8c4b5d7
commit 210cdfc171

View File

@ -214,9 +214,10 @@ class BarcodeFragment : Fragment() {
} }
private fun share(bitmap: Bitmap) { private fun share(bitmap: Bitmap) {
val ctx = context ?: return
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
val file = File( val file = File(
context.externalCacheDir, ctx.externalCacheDir,
"shared_barcode.png" "shared_barcode.png"
) )
val success = try { val success = try {
@ -229,9 +230,9 @@ class BarcodeFragment : Fragment() {
} }
launch(Dispatchers.Main) { launch(Dispatchers.Main) {
if (success) { if (success) {
shareFile(context, file, "image/png") shareFile(ctx, file, "image/png")
} else { } else {
activity?.toast(R.string.error_saving_file) ctx.toast(R.string.error_saving_file)
} }
} }
} }