diff --git a/EpcQrCodeAndroidApp/src/main/java/net/codinux/banking/epcqrcode/MainActivity.kt b/EpcQrCodeAndroidApp/src/main/java/net/codinux/banking/epcqrcode/MainActivity.kt index 0d1d492..abb8350 100644 --- a/EpcQrCodeAndroidApp/src/main/java/net/codinux/banking/epcqrcode/MainActivity.kt +++ b/EpcQrCodeAndroidApp/src/main/java/net/codinux/banking/epcqrcode/MainActivity.kt @@ -32,7 +32,10 @@ class MainActivity : AppCompatActivity() { private fun generateQrCode() { hideKeyboard(edtxtReference) - val param = EpcQrCodeConfig(edtxtReceiver.string, edtxtIban.string, edtxtBic.string, edtxtAmount.string, edtxtReference.string) + val density = resources.displayMetrics.density + val heightAndWidth = (350 * density).toInt() + + val param = EpcQrCodeConfig(edtxtReceiver.string, edtxtIban.string, edtxtBic.string, edtxtAmount.string, edtxtReference.string, qrCodeHeightAndWidth = heightAndWidth) generateQrCodeAsync(param) { createdQrCode -> imgGeneratedQrCode.setImageBitmap(createdQrCode) @@ -41,10 +44,7 @@ class MainActivity : AppCompatActivity() { private fun generateQrCodeAsync(param: EpcQrCodeConfig, done: (Bitmap) -> Unit) { GlobalScope.launch(Dispatchers.IO) { - val density = resources.displayMetrics.density - val heightAndWidth = (350 * density).toInt() - - val epcQrCode = EpcQrCodeGenerator().generateEpcQrCode(param, heightAndWidth) + val epcQrCode = EpcQrCodeGenerator().generateEpcQrCode(param) withContext(Dispatchers.Main) { done(epcQrCode.androidBitmap)