Renamed CreatorParam to EpcQrCodeConfig

This commit is contained in:
dankito 2022-03-13 21:52:09 +01:00
parent 06a1ac0b95
commit 93c3b915bf
6 changed files with 11 additions and 11 deletions

View File

@ -1,7 +1,7 @@
package net.codinux.banking.epcqrcode package net.codinux.banking.epcqrcode
open class CreatorParam( open class EpcQrCodeConfig(
var receiverName: String = "", var receiverName: String = "",

View File

@ -8,7 +8,7 @@ open class EpcQrCodeCreator {
// } // }
open fun generate(param: CreatorParam): EpcQrCode { open fun generate(param: EpcQrCodeConfig): EpcQrCode {
return EpcQrCode( return EpcQrCode(
EpcQrCode.ServiceTagDefaultValue, EpcQrCode.ServiceTagDefaultValue,
EpcQrCodeVersion.Version2, EpcQrCodeVersion.Version2,
@ -26,7 +26,7 @@ open class EpcQrCodeCreator {
) )
} }
open fun generateAsString(param: CreatorParam): String { open fun generateAsString(param: EpcQrCodeConfig): String {
val epcQrCode = generate(param) val epcQrCode = generate(param)
val epcQrCodeBuilder = StringBuilder() val epcQrCodeBuilder = StringBuilder()

View File

@ -20,14 +20,14 @@ class MainActivity : AppCompatActivity() {
private fun generateQrCode() { private fun generateQrCode() {
hideKeyboard(edtxtReference) hideKeyboard(edtxtReference)
val param = CreatorParam(edtxtReceiver.string, edtxtIban.string, edtxtBic.string, map(edtxtAmount.string), edtxtReference.string) val param = EpcQrCodeConfig(edtxtReceiver.string, edtxtIban.string, edtxtBic.string, map(edtxtAmount.string), edtxtReference.string)
generateQrCodeAsync(param) { createdQrCode -> generateQrCodeAsync(param) { createdQrCode ->
imgGeneratedQrCode.setImageBitmap(createdQrCode) imgGeneratedQrCode.setImageBitmap(createdQrCode)
} }
} }
private fun generateQrCodeAsync(param: CreatorParam, done: (Bitmap) -> Unit) { private fun generateQrCodeAsync(param: EpcQrCodeConfig, done: (Bitmap) -> Unit) {
thread { thread {
val density = resources.displayMetrics.density val density = resources.displayMetrics.density
val config = EncodeToQrCodeConfig((EncodeToQrCodeConfig.DefaultWidth * density).toInt(), (EncodeToQrCodeConfig.DefaultHeight * density).toInt()) val config = EncodeToQrCodeConfig((EncodeToQrCodeConfig.DefaultWidth * density).toInt(), (EncodeToQrCodeConfig.DefaultHeight * density).toInt())

View File

@ -267,7 +267,7 @@ class MainWindow : View(FX.messages["application.title"]) {
} }
private fun generateQrCode() { private fun generateQrCode() {
val param = CreatorParam(receiver.value, iban.value, bic.value, map(amount.value), reference.value) val param = EpcQrCodeConfig(receiver.value, iban.value, bic.value, map(amount.value), reference.value)
val qrCodeContent = EpcQrCodeCreator().generateAsString(param) val qrCodeContent = EpcQrCodeCreator().generateAsString(param)
generatedQrCodeImage.value = generateQrCode(qrCodeContent) generatedQrCodeImage.value = generateQrCode(qrCodeContent)

View File

@ -1,6 +1,6 @@
package net.codinux.banking.epcqrcode.rest package net.codinux.banking.epcqrcode.rest
import net.codinux.banking.epcqrcode.CreatorParam import net.codinux.banking.epcqrcode.EpcQrCodeConfig
import net.codinux.banking.epcqrcode.EncodeToQrCodeConfig import net.codinux.banking.epcqrcode.EncodeToQrCodeConfig
import net.codinux.banking.epcqrcode.EpcQrCodeCreator import net.codinux.banking.epcqrcode.EpcQrCodeCreator
import net.codinux.banking.epcqrcode.QrCodeGenerator import net.codinux.banking.epcqrcode.QrCodeGenerator
@ -31,7 +31,7 @@ class EpcQrCodeResource {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
fun createEpcQrCode(requestDto: GenerateEpcQrCodeRequestDto): Response { fun createEpcQrCode(requestDto: GenerateEpcQrCodeRequestDto): Response {
try { try {
val qrCodeContent = epcQrCodeCreator.generateAsString(mapToCreatorParam(requestDto)) val qrCodeContent = epcQrCodeCreator.generateAsString(mapToEpcQrCodeConfig(requestDto))
val qrCodeBytes = qrCodeGenerator.generateQrCode(qrCodeContent, map(requestDto)) val qrCodeBytes = qrCodeGenerator.generateQrCode(qrCodeContent, map(requestDto))
return Response.ok(GenerateEpcQrCodeResponseDto(qrCodeBytes)) return Response.ok(GenerateEpcQrCodeResponseDto(qrCodeBytes))
@ -46,8 +46,8 @@ class EpcQrCodeResource {
} }
} }
private fun mapToCreatorParam(dto: GenerateEpcQrCodeRequestDto): CreatorParam { private fun mapToEpcQrCodeConfig(dto: GenerateEpcQrCodeRequestDto): EpcQrCodeConfig {
return CreatorParam( return EpcQrCodeConfig(
dto.receiverName, dto.receiverName,
dto.iban, dto.iban,
dto.bic, dto.bic,

View File

@ -82,7 +82,7 @@ struct ContentView: View {
private func generateQRCode() { private func generateQRCode() {
let creator = EpcQrCodeCreator() let creator = EpcQrCodeCreator()
let param = CreatorParam(receiverName: receiver, iban: iban, bic: bic, amount: map(amount), reference: reference, noteToUser: nil, encoding: .utf8) let param = EpcQrCodeConfig(receiverName: receiver, iban: iban, bic: bic, amount: map(amount), reference: reference, noteToUser: nil, encoding: .utf8)
let qrCodeContent = creator.generateAsString(param: param) let qrCodeContent = creator.generateAsString(param: param)