From d931dfeff9b0ebd8aa6eab4ce0afbec9119495e2 Mon Sep 17 00:00:00 2001 From: Ighor Moura Date: Wed, 23 Jul 2025 18:18:18 -0400 Subject: [PATCH] alterando notificacao --- .../mypos/services/AditumSdkService.kt | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/example/mypos/services/AditumSdkService.kt b/app/src/main/java/com/example/mypos/services/AditumSdkService.kt index 3c56bd6..b297710 100644 --- a/app/src/main/java/com/example/mypos/services/AditumSdkService.kt +++ b/app/src/main/java/com/example/mypos/services/AditumSdkService.kt @@ -53,49 +53,44 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) { private val _pinLengthFlow = MutableStateFlow(0) val pinLengthFlow: StateFlow = _pinLengthFlow.asStateFlow() - fun register(listener: PaymentRegister) { + init { coroutineScope.launch { - val callback = object : IPaymentCallback.Stub() { - override fun notification( - message: String?, - transactionStatus: TransactionStatus?, - command: AbecsCommands? - ) { - Log.d(TAG, "\nnotification - ${ message ?: "" }") - if (message != null) { - _messageFlow.value = message.replace("\\s+".toRegex(), " ").trim() - } - listener.notification( - message?.replace("\\s+".toRegex(), " ")?.trim(), - transactionStatus, - command - ) - } + paymentApplication.communicationService?.registerPaymentCallback(paymentCallback) + } + } - override fun pinNotification(message: String?, length: Int) { - _pinLengthFlow.value = length - } - - override fun startGetClearData( - clearDataRequest: GetClearDataRequest?, - finished: GetClearDataFinishedCallback? - ) { - TODO("Not yet implemented") - } - - override fun startGetMenuSelection( - menuSelectionRequest: GetMenuSelectionRequest?, - finished: GetMenuSelectionFinishedCallback? - ) { - TODO("Not yet implemented") - } - - override fun qrCodeGenerated(qrCode: String?, expirationTime: Int) { - Log.d(TAG, "\nqrCode - ${ qrCode ?: "" }\nexpirationTime - $expirationTime") - } + val paymentCallback = object : IPaymentCallback.Stub() { + override fun notification( + message: String?, + transactionStatus: TransactionStatus?, + command: AbecsCommands? + ) { + Log.i(TAG, "\nnotification - ${ message ?: "" }") + if (message != null) { + _messageFlow.value = message.replace("\\s+".toRegex(), " ").trim() } + } - paymentApplication.communicationService?.registerPaymentCallback(callback) + override fun pinNotification(message: String?, length: Int) { + _pinLengthFlow.value = length + } + + override fun startGetClearData( + clearDataRequest: GetClearDataRequest?, + finished: GetClearDataFinishedCallback? + ) { + TODO("Not yet implemented") + } + + override fun startGetMenuSelection( + menuSelectionRequest: GetMenuSelectionRequest?, + finished: GetMenuSelectionFinishedCallback? + ) { + TODO("Not yet implemented") + } + + override fun qrCodeGenerated(qrCode: String?, expirationTime: Int) { + Log.d(TAG, "\nqrCode - ${ qrCode ?: "" }\nexpirationTime - $expirationTime") } }